]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Better detection of whether ipcrypt2 will compile
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 2 Feb 2026 12:01:20 +0000 (13:01 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 3 Feb 2026 11:41:48 +0000 (12:41 +0100)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/configure.ac
pdns/dnsdistdist/ext/ipcrypt2/meson.build
pdns/dnsdistdist/m4/pdns_check_aarch64_uint64x2_t.m4 [deleted file]
pdns/dnsdistdist/m4/pdns_enable_ipcrypt2.m4

index b8f223270f3fe0e0270ae8a5d0054e0b6a09532b..f8ea4202a87e19a0a9399271f9784783ce144dee 100644 (file)
@@ -144,7 +144,6 @@ DNSDIST_WITH_CDB
 PDNS_CHECK_LMDB
 PDNS_ENABLE_IPCIPHER
 PDNS_ENABLE_IPCRYPT2
-PDNS_CHECK_AARCH64_UINT64X2_T
 
 AX_CXX_COMPILE_STDCXX_17([noext], [mandatory])
 
index 41d3fde95a22147022855df51108366714c786a1..e996c0bf289b27562fd00f28bb2a08916e0c2530 100644 (file)
@@ -18,24 +18,33 @@ int main() {
   can_build = compiler.compiles(code, name: 'uint64x2_t tests')
 endif
 
+if target_machine.cpu_family() in ['x86', 'x86_64']
+  funcs = ['_mm_loadu_si64']
+  foreach func: funcs
+    has = cxx.has_header_symbol('emmintrin.h', func)
+    if not has
+      can_build = false
+    endif
+  endforeach
+endif
 
 dep_ipcrypt2 = declare_dependency()
 
 if can_build
-lib_ipcrypt2 = static_library(
-  'ipcrypt2',
-  'ipcrypt2.c',
-  extra_files: [
-    'include/ipcrypt2.h',
-    'LICENSE',
-    'README.md',
-  ],
-)
+  lib_ipcrypt2 = static_library(
+    'ipcrypt2',
+    'ipcrypt2.c',
+    extra_files: [
+      'include/ipcrypt2.h',
+      'LICENSE',
+      'README.md',
+    ],
+  )
 
-dep_ipcrypt2 = declare_dependency(
-  link_with: lib_ipcrypt2,
-  include_directories: include_directories('./include'),
-)
+  dep_ipcrypt2 = declare_dependency(
+    link_with: lib_ipcrypt2,
+    include_directories: include_directories('./include'),
+  )
 endif
 
 if not can_build and opt_ipcrypt2.enabled()
diff --git a/pdns/dnsdistdist/m4/pdns_check_aarch64_uint64x2_t.m4 b/pdns/dnsdistdist/m4/pdns_check_aarch64_uint64x2_t.m4
deleted file mode 100644 (file)
index a6cbf2d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-AC_DEFUN([PDNS_CHECK_AARCH64_UINT64X2_T], [
-  AC_CANONICAL_BUILD()
-  AS_IF([test "$build_cpu" = "aarch64"], [
-    AC_MSG_CHECKING([whether the compiler supports calculations with uint64x2_t])
-    AC_LANG_PUSH([C++])
-    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
-#    if defined(_MSC_VER) && defined(_M_ARM64)
-#        include <arm64_neon.h>
-#    else
-#        include <arm_neon.h>
-#    endif
-int main() {
-  uint64x2_t foo = {0, 0};
-  uint64x2_t bar = vshrq_n_u8(foo, 1);
-  return 0;
-}
-    ])],[
-    dnl We just define this. Proper detection is only done in Meson
-    AC_DEFINE([HAVE_IPCRYPT2], [1], [Define to 1 to build with IPCrypt2])
-    AC_MSG_RESULT([ok])
-    ],[
-    AC_MSG_FAILURE([no])
-    ])
-    AC_LANG_POP()
-  ])
-])
index e4897d96464fbd769915a231fbe5716fad40a03e..9351af5850119e94d74b2831f70f6c0744a2c2c0 100644 (file)
@@ -1,13 +1,69 @@
 AC_DEFUN([PDNS_ENABLE_IPCRYPT2], [
   AC_MSG_CHECKING([whether to enable ipcrypt2 support])
   AC_ARG_ENABLE([ipcrypt2],
-    AS_HELP_STRING([--enable-ipcrypt2], [enable ipcrypt2 support @<:@default=yes@:>@]),
+    AS_HELP_STRING([--enable-ipcrypt2], [enable ipcrypt2 support @<:@default=auto@:>@]),
     [enable_ipcrypt2=$enableval],
-    [enable_ipcrypt2=yes]
+    [enable_ipcrypt2=auto]
   )
+
   AC_MSG_RESULT([$enable_ipcrypt2])
 
-  AM_CONDITIONAL([HAVE_IPCRYPT2], [test "x$enable_ipcrypt2" != "xno"])
+  HAVE_IPCRYPT2=0
+
+  AS_IF([test "x$enable_ipcrypt2" != "xno"], [
+    AC_CANONICAL_BUILD()
+    AS_IF([test "$build_cpu" = "aarch64"], [
+      AC_MSG_CHECKING([whether the compiler supports calculations with uint64x2_t and _mm_loadu_si64])
+      AC_LANG_PUSH([C++])
+      AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#    if defined(_MSC_VER) && defined(_M_ARM64)
+#        include <arm64_neon.h>
+#    else
+#        include <arm_neon.h>
+#    endif
+#include <emmintrin.h>
+int main() {
+  uint64x2_t foo = {0, 0};
+  uint64x2_t bar = vshrq_n_u8(foo, 1);
+  void *a = (void*) &_mm_loadu_si64;
+  long long b = (long long) a;
+  return (int) b;
+}
+        ])],[
+        [HAVE_IPCRYPT2=1]
+        AC_MSG_RESULT([ok])
+      ], [
+        AC_MSG_RESULT([no])
+      ])
+      AC_LANG_POP()
+    ], [
+      AC_MSG_CHECKING([whether the compiler supports _mm_loadu_si64])
+      AC_LANG_PUSH([C++])
+      AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#include <emmintrin.h>
+int main() {
+  void *a = (void*) &_mm_loadu_si64;
+  long long b = (long long) a;
+  return (int) b;
+}
+        ])],[
+        [HAVE_IPCRYPT2=1]
+        AC_MSG_RESULT([ok])
+      ], [
+        AC_MSG_RESULT([no])
+      ])
+      AC_LANG_POP()
+    ])
+  ])
+
+  AM_CONDITIONAL([HAVE_IPCRYPT2], [test "x$HAVE_IPCRYPT2" != "x0"])
+
+  AS_IF([test "x$enable_ipcrypt2" = "xyes"], [
+    AS_IF([test x"$HAVE_IPCRYPT2" = "x0"], [
+      AC_MSG_ERROR([ipcrypt2 support requested but is not available])
+    ])
+  ])
+
   AM_COND_IF([HAVE_IPCRYPT2], [
     AC_DEFINE([HAVE_IPCRYPT2], [1], [Define to 1 if you enable ipcrypt2 support])
   ])