@@ -283,8 +283,30 @@ AC_ARG_ENABLE([werror],
283
283
[ enable_werror=no] )
284
284
285
285
AC_LANG_PUSH ( [ C++] )
286
+
287
+ dnl Check for a flag to turn compiler warnings into errors. This is helpful for checks which may
288
+ dnl appear to succeed because by default they merely emit warnings when they fail.
289
+ dnl
290
+ dnl Note that this is not necessarily a check to see if -Werror is supported, but rather to see if
291
+ dnl a compile with -Werror can succeed. This is important because the compiler may already be
292
+ dnl warning about something unrelated, for example about some path issue. If that is the case,
293
+ dnl -Werror cannot be used because all of those warnings would be turned into errors.
286
294
AX_CHECK_COMPILE_FLAG ( [ -Werror] ,[ CXXFLAG_WERROR="-Werror"] ,[ CXXFLAG_WERROR=""] )
287
295
296
+ dnl Check for a flag to turn linker warnings into errors. When flags are passed to linkers via the
297
+ dnl compiler driver using a -Wl,-foo flag, linker warnings may be swallowed rather than bubbling up.
298
+ dnl See note above, the same applies here as well.
299
+ dnl
300
+ dnl LDFLAG_WERROR Should only be used when testing -Wl,*
301
+ case $host in
302
+ *darwin*)
303
+ AX_CHECK_LINK_FLAG ( [ -Wl,-fatal_warnings] ,[ LDFLAG_WERROR="-Wl,-fatal_warnings"] ,[ LDFLAG_WERROR=""] )
304
+ ;;
305
+ *)
306
+ AX_CHECK_LINK_FLAG ( [ -Wl,--fatal-warnings] ,[ LDFLAG_WERROR="-Wl,--fatal-warnings"] ,[ LDFLAG_WERROR=""] )
307
+ ;;
308
+ esac
309
+
288
310
if test "x$enable_debug" = xyes; then
289
311
dnl Clear default -g -O2 flags
290
312
if test "x$CXXFLAGS_overridden" = xno; then
@@ -613,7 +635,7 @@ case $host in
613
635
esac
614
636
fi
615
637
616
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-headerpad_max_install_names] ] , [ LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"] )
638
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-headerpad_max_install_names] ] , [ LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"] ,, [ [ $LDFLAG_WERROR ] ] )
617
639
CPPFLAGS="$CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0"
618
640
OBJCXXFLAGS="$CXXFLAGS"
619
641
;;
@@ -709,8 +731,8 @@ if test x$use_glibc_compat != xno; then
709
731
[ fdelt_type="long int"] )
710
732
AC_MSG_RESULT ( $fdelt_type )
711
733
AC_DEFINE_UNQUOTED ( FDELT_TYPE , $fdelt_type ,[ parameter and return value type for __fdelt_chk] )
712
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--wrap=__divmoddi4] ] , [ COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"] )
713
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--wrap=log2f] ] , [ COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log2f"] )
734
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--wrap=__divmoddi4] ] , [ COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"] ,, [ [ $LDFLAG_WERROR ] ] )
735
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--wrap=log2f] ] , [ COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log2f"] ,, [ [ $LDFLAG_WERROR ] ] )
714
736
else
715
737
AC_SEARCH_LIBS ( [ clock_gettime] ,[ rt] )
716
738
fi
@@ -758,11 +780,11 @@ if test x$use_hardening != xno; then
758
780
] )
759
781
fi
760
782
761
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--dynamicbase] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"] )
762
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--nxcompat] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"] )
763
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--high-entropy-va] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"] )
764
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-z,relro] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"] )
765
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-z,now] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"] )
783
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--dynamicbase] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"] ,, [ [ $LDFLAG_WERROR ] ] )
784
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--nxcompat] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"] ,, [ [ $LDFLAG_WERROR ] ] )
785
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--high-entropy-va] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"] ,, [ [ $LDFLAG_WERROR ] ] )
786
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-z,relro] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"] ,, [ [ $LDFLAG_WERROR ] ] )
787
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-z,now] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"] ,, [ [ $LDFLAG_WERROR ] ] )
766
788
AX_CHECK_LINK_FLAG ( [ [ -fPIE -pie] ] , [ PIE_FLAGS="-fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"] ,, [ [ $CXXFLAG_WERROR] ] )
767
789
768
790
case $host in
@@ -776,14 +798,14 @@ dnl These flags are specific to ld64, and may cause issues with other linkers.
776
798
dnl For example: GNU ld will intepret -dead_strip as -de and then try and use
777
799
dnl "ad_strip" as the symbol for the entry point.
778
800
if test x$TARGET_OS = xdarwin; then
779
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-dead_strip] ] , [ LDFLAGS="$LDFLAGS -Wl,-dead_strip"] )
780
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-dead_strip_dylibs] ] , [ LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs"] )
781
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-bind_at_load] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-bind_at_load"] )
801
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-dead_strip] ] , [ LDFLAGS="$LDFLAGS -Wl,-dead_strip"] ,, [ [ $LDFLAG_WERROR ] ] )
802
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-dead_strip_dylibs] ] , [ LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs"] ,, [ [ $LDFLAG_WERROR ] ] )
803
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-bind_at_load] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-bind_at_load"] ,, [ [ $LDFLAG_WERROR ] ] )
782
804
fi
783
805
784
806
if test x$enable_determinism = xyes; then
785
807
if test x$TARGET_OS = xwindows; then
786
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--no-insert-timestamp] ] , [ LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"] )
808
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--no-insert-timestamp] ] , [ LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"] ,, [ [ $LDFLAG_WERROR ] ] )
787
809
fi
788
810
fi
789
811
1215
1237
1216
1238
if test x$use_reduce_exports = xyes; then
1217
1239
CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
1218
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--exclude-libs,ALL] ] , [ RELDFLAGS="-Wl,--exclude-libs,ALL"] )
1240
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--exclude-libs,ALL] ] , [ RELDFLAGS="-Wl,--exclude-libs,ALL"] ,, [ [ $LDFLAG_WERROR ] ] )
1219
1241
fi
1220
1242
1221
1243
if test x$use_tests = xyes; then
0 commit comments