From: Remi Gacogne Date: Mon, 2 Feb 2026 12:01:20 +0000 (+0100) Subject: dnsdist: Better detection of whether ipcrypt2 will compile X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f172f4cda72516eb6285f534f11bccdc36490a0a;p=thirdparty%2Fpdns.git dnsdist: Better detection of whether ipcrypt2 will compile Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/configure.ac b/pdns/dnsdistdist/configure.ac index b8f223270f..f8ea4202a8 100644 --- a/pdns/dnsdistdist/configure.ac +++ b/pdns/dnsdistdist/configure.ac @@ -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]) diff --git a/pdns/dnsdistdist/ext/ipcrypt2/meson.build b/pdns/dnsdistdist/ext/ipcrypt2/meson.build index 41d3fde95a..e996c0bf28 100644 --- a/pdns/dnsdistdist/ext/ipcrypt2/meson.build +++ b/pdns/dnsdistdist/ext/ipcrypt2/meson.build @@ -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 index a6cbf2dfdb..0000000000 --- a/pdns/dnsdistdist/m4/pdns_check_aarch64_uint64x2_t.m4 +++ /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 -# else -# include -# 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() - ]) -]) diff --git a/pdns/dnsdistdist/m4/pdns_enable_ipcrypt2.m4 b/pdns/dnsdistdist/m4/pdns_enable_ipcrypt2.m4 index e4897d9646..9351af5850 100644 --- a/pdns/dnsdistdist/m4/pdns_enable_ipcrypt2.m4 +++ b/pdns/dnsdistdist/m4/pdns_enable_ipcrypt2.m4 @@ -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 +# else +# include +# endif +#include +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 +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]) ])