]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
macOS doesn't require --unwindlib and complaints bitterly
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 28 Oct 2021 18:49:12 +0000 (14:49 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 28 Oct 2021 18:49:12 +0000 (14:49 -0400)
configure
configure.ac
m4/ax_cc.m4

index b2fc62d29a36c5b902793e2b3bad17fe21bc51ec..50eaba40fc631e015ab82a7443170915ed0ef2d8 100755 (executable)
--- a/configure
+++ b/configure
@@ -3099,6 +3099,9 @@ ac_config_headers="$ac_config_headers src/include/autoconf.h"
 
 
 
+
+
+
 
 
 
@@ -5839,9 +5842,60 @@ fi
 printf "%s\n" "$ax_cv_cc_clang" >&6; }
 
 if test "x$ax_cv_cc_clang" = "xyes"; then
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the compiler accepts --unwindlib" >&5
+printf %s "checking if the compiler accepts --unwindlib... " >&6; }
+if test ${ax_cv_cc_unwindlib_arg+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+    CFLAGS_SAVED=$CFLAGS
+    CFLAGS="$CFLAGS -Werror --unwindlib=libunwind"
+
+    if test "$cross_compiling" = yes
+then :
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+        int main(int argc, char **argv) {
+          return 0;
+        }
+
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
+then :
+  ax_cv_cc_unwindlib_arg=yes
+else $as_nop
+  ax_cv_cc_unwindlib_arg=no
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+    CFLAGS="$CFLAGS_SAVED"
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_unwindlib_arg" >&5
+printf "%s\n" "$ax_cv_cc_unwindlib_arg" >&6; }
+
   clang_path="$CC"
 
-    LDFLAGS="$LDFLAGS --rtlib=compiler-rt --unwindlib=libunwind"
+
+    LDFLAGS="$LDFLAGS --rtlib=compiler-rt"
+
+  if test "x$ax_cv_cc_unwindlib_arg" = "xyes"; then
+    LDFLAGS="$LDFLAGS --unwindlib=libunwind"
+  fi
 else
   clang_path=""
 
index 0cab1095b56927be69c54aaf1b096196eececcd7..6cb6ffd611ece3dcfe3278040b6f8725785747b5 100644 (file)
@@ -248,9 +248,15 @@ dnl #  Definitive check for whether the compiler is clang
 dnl #
 AX_CC_IS_CLANG
 if test "x$ax_cv_cc_clang" = "xyes"; then
+  AX_CC_UNWINDLIB_ARG
   AC_SUBST(clang_path, "$CC")
+
   dnl # Needed for builtins to function correctly (https://bugs.gentoo.org/702344)
-  LDFLAGS="$LDFLAGS --rtlib=compiler-rt --unwindlib=libunwind"
+  LDFLAGS="$LDFLAGS --rtlib=compiler-rt"
+
+  if test "x$ax_cv_cc_unwindlib_arg" = "xyes"; then
+    LDFLAGS="$LDFLAGS --unwindlib=libunwind"
+  fi
 else
   AC_SUBST(clang_path, "")
 fi
index 5a3afc6328ee3acd910dc81ac94ae2004e9f52cc..16732748d634b9a6e6098d0cf7983f4dcbe7396c 100644 (file)
@@ -58,6 +58,32 @@ AC_DEFUN([AX_CC_STD_C11],[
   ])
 ])
 
+dnl #
+dnl # clang and gcc originally used different flags to specify c11 support
+dnl #
+AC_DEFUN([AX_CC_UNWINDLIB_ARG],[
+  AC_CACHE_CHECK([if the compiler accepts --unwindlib], [ax_cv_cc_unwindlib_arg],[
+    CFLAGS_SAVED=$CFLAGS
+    CFLAGS="$CFLAGS -Werror --unwindlib=libunwind"
+
+    AC_RUN_IFELSE(
+    [
+      AC_LANG_SOURCE(
+      [
+        int main(int argc, char **argv) {
+          return 0;
+        }
+      ])
+    ],
+      [ax_cv_cc_unwindlib_arg=yes],
+      [ax_cv_cc_unwindlib_arg=no]
+    )
+
+    CFLAGS="$CFLAGS_SAVED"
+  ])
+])
+
+
 dnl #
 dnl #  Check if we have the _Generic construct
 dnl #