From: Todd C. Miller Date: Mon, 18 Jun 2012 18:10:50 +0000 (-0400) Subject: Move the check for -static-libgcc until after AC_LANG_WERROR X-Git-Tag: SUDO_1_8_6^2~129 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=af8a211e4b320b29aa764eebfac22ed9f51c83c0;p=sudo Move the check for -static-libgcc until after AC_LANG_WERROR has been called and use AX_CHECK_COMPILE_FLAG(). --- diff --git a/configure b/configure index e978051d3..4df7fd855 100755 --- a/configure +++ b/configure @@ -14628,43 +14628,6 @@ else as_fn_error $? "Your C compiler doesn't support variadic macros, try building with gcc instead" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -if test X"$with_gnu_ld" != "yes" -a -n "$GCC"; then - _CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -static-libgcc" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -static-libgcc" >&5 -$as_echo_n "checking whether $CC understands -static-libgcc... " >&6; } -if ${sudo_cv_var_gcc_static_libgcc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - sudo_cv_var_gcc_static_libgcc=yes -else - sudo_cv_var_gcc_static_libgcc=no - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_var_gcc_static_libgcc" >&5 -$as_echo "$sudo_cv_var_gcc_static_libgcc" >&6; } - CFLAGS="$_CFLAGS" - if test "$sudo_cv_var_gcc_static_libgcc" = "yes"; then - LT_LDFLAGS="$LT_LDFLAGS -Wc,-static-libgcc" - fi -fi for ac_prog in 'bison -y' byacc do @@ -20080,6 +20043,45 @@ $as_echo "$iolog_dir" >&6; } ac_c_werror_flag=yes + +if test -n "$GCC" -a "$lt_cv_prog_gnu_ld" != "yes" -a -n "$GCC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -static-libgcc" >&5 +$as_echo_n "checking whether C compiler accepts -static-libgcc... " >&6; } +if ${ax_cv_check_cflags___static_libgcc+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -static-libgcc" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___static_libgcc=yes +else + ax_cv_check_cflags___static_libgcc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___static_libgcc" >&5 +$as_echo "$ax_cv_check_cflags___static_libgcc" >&6; } +if test x"$ax_cv_check_cflags___static_libgcc" = xyes; then : + LT_LDFLAGS="$LT_LDFLAGS -Wc,-static-libgcc" +else + : +fi + +fi + as_CACHEVAR=`$as_echo "ax_cv_check_cflags__-fvisibility=hidden" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fvisibility=hidden" >&5 $as_echo_n "checking whether C compiler accepts -fvisibility=hidden... " >&6; } diff --git a/configure.in b/configure.in index a87d38147..265a78dd4 100644 --- a/configure.in +++ b/configure.in @@ -1975,23 +1975,6 @@ AC_INCLUDES_DEFAULT # define sudo_fprintf(fp, ...) fprintf((fp), __VA_ARGS__) #endif ], [sudo_fprintf(stderr, "a %s", "test");])], [], [AC_MSG_ERROR([Your C compiler doesn't support variadic macros, try building with gcc instead])]) -if test X"$with_gnu_ld" != "yes" -a -n "$GCC"; then - _CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -static-libgcc" - AC_CACHE_CHECK([whether $CC understands -static-libgcc], - [sudo_cv_var_gcc_static_libgcc], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[]], [[]])], - [sudo_cv_var_gcc_static_libgcc=yes], - [sudo_cv_var_gcc_static_libgcc=no] - ) - ] - ) - CFLAGS="$_CFLAGS" - if test "$sudo_cv_var_gcc_static_libgcc" = "yes"; then - LT_LDFLAGS="$LT_LDFLAGS -Wc,-static-libgcc" - fi -fi dnl dnl Program checks @@ -3169,11 +3152,25 @@ SUDO_TIMEDIR SUDO_IO_LOGDIR dnl -dnl Check for gcc 4.0-style symbol visibility support. -dnl This must be towards the end as it turns warnings -dnl into fatal errors (and there is no way to undo that) +dnl Turn warnings into errors. +dnl All compiler/loader tests after this point will fail if +dnl a warning is displayed (nornally, warnings are not fata). dnl AC_LANG_WERROR + +dnl +dnl If compiler supports the -static-libgcc flag use it unless we have +dnl GNU ld (which can avoid linking in libgcc when it is not needed). +dnl This test relies on AC_LANG_WERROR +dnl +if test -n "$GCC" -a "$lt_cv_prog_gnu_ld" != "yes" -a -n "$GCC"; then + AX_CHECK_COMPILE_FLAG([-static-libgcc], [LT_LDFLAGS="$LT_LDFLAGS -Wc,-static-libgcc"]) +fi + +dnl +dnl Check for symbol visibility support. +dnl This test relies on AC_LANG_WERROR +dnl AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [ AC_DEFINE(HAVE_DSO_VISIBILITY) CFLAGS="${CFLAGS} -fvisibility=hidden" @@ -3202,6 +3199,7 @@ AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [ dnl dnl If the compiler doesn't have symbol visibility support, it may dnl support version scripts (only GNU and Solaris ld). +dnl This test relies on AC_LANG_WERROR dnl if test -n "$LT_LDEXPORTS"; then if test "$lt_cv_prog_gnu_ld" = "yes"; then @@ -3241,8 +3239,7 @@ fi dnl dnl Check for -fstack-protector and -z relro support -dnl This after the call to AC_LANG_WERROR so that warnings -dnl are treated as fatal errors. +dnl This test relies on AC_LANG_WERROR dnl if test "$enable_hardening" != "no"; then AX_CHECK_COMPILE_FLAG([-fstack-protector], [