From: Arran Cudbard-Bell Date: Thu, 28 Oct 2021 18:49:12 +0000 (-0400) Subject: macOS doesn't require --unwindlib and complaints bitterly X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9395b43594e8cdef0a35432f56f8e4ef22d0d2e;p=thirdparty%2Ffreeradius-server.git macOS doesn't require --unwindlib and complaints bitterly --- diff --git a/configure b/configure index b2fc62d29a3..50eaba40fc6 100755 --- 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="" diff --git a/configure.ac b/configure.ac index 0cab1095b56..6cb6ffd611e 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/m4/ax_cc.m4 b/m4/ax_cc.m4 index 5a3afc6328e..16732748d63 100644 --- a/m4/ax_cc.m4 +++ b/m4/ax_cc.m4 @@ -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 #