@@ -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
@@ -611,7 +633,7 @@ case $host in
611
633
esac
612
634
fi
613
635
614
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-headerpad_max_install_names] ] , [ LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"] )
636
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-headerpad_max_install_names] ] , [ LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"] ,, [ [ $LDFLAG_WERROR ] ] )
615
637
CPPFLAGS="$CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0"
616
638
OBJCXXFLAGS="$CXXFLAGS"
617
639
;;
@@ -707,8 +729,8 @@ if test x$use_glibc_compat != xno; then
707
729
[ fdelt_type="long int"] )
708
730
AC_MSG_RESULT ( $fdelt_type )
709
731
AC_DEFINE_UNQUOTED ( FDELT_TYPE , $fdelt_type ,[ parameter and return value type for __fdelt_chk] )
710
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--wrap=__divmoddi4] ] , [ COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"] )
711
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--wrap=log2f] ] , [ COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log2f"] )
732
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--wrap=__divmoddi4] ] , [ COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"] ,, [ [ $LDFLAG_WERROR ] ] )
733
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--wrap=log2f] ] , [ COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log2f"] ,, [ [ $LDFLAG_WERROR ] ] )
712
734
else
713
735
AC_SEARCH_LIBS ( [ clock_gettime] ,[ rt] )
714
736
fi
@@ -756,11 +778,11 @@ if test x$use_hardening != xno; then
756
778
] )
757
779
fi
758
780
759
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--dynamicbase] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"] )
760
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--nxcompat] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"] )
761
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--high-entropy-va] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"] )
762
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-z,relro] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"] )
763
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-z,now] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"] )
781
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--dynamicbase] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"] ,, [ [ $LDFLAG_WERROR ] ] )
782
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--nxcompat] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"] ,, [ [ $LDFLAG_WERROR ] ] )
783
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--high-entropy-va] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"] ,, [ [ $LDFLAG_WERROR ] ] )
784
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-z,relro] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"] ,, [ [ $LDFLAG_WERROR ] ] )
785
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-z,now] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"] ,, [ [ $LDFLAG_WERROR ] ] )
764
786
AX_CHECK_LINK_FLAG ( [ [ -fPIE -pie] ] , [ PIE_FLAGS="-fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"] ,, [ [ $CXXFLAG_WERROR] ] )
765
787
766
788
case $host in
@@ -774,14 +796,14 @@ dnl These flags are specific to ld64, and may cause issues with other linkers.
774
796
dnl For example: GNU ld will intepret -dead_strip as -de and then try and use
775
797
dnl "ad_strip" as the symbol for the entry point.
776
798
if test x$TARGET_OS = xdarwin; then
777
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-dead_strip] ] , [ LDFLAGS="$LDFLAGS -Wl,-dead_strip"] )
778
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-dead_strip_dylibs] ] , [ LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs"] )
779
- AX_CHECK_LINK_FLAG ( [ [ -Wl,-bind_at_load] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-bind_at_load"] )
799
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-dead_strip] ] , [ LDFLAGS="$LDFLAGS -Wl,-dead_strip"] ,, [ [ $LDFLAG_WERROR ] ] )
800
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-dead_strip_dylibs] ] , [ LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs"] ,, [ [ $LDFLAG_WERROR ] ] )
801
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,-bind_at_load] ] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-bind_at_load"] ,, [ [ $LDFLAG_WERROR ] ] )
780
802
fi
781
803
782
804
if test x$enable_determinism = xyes; then
783
805
if test x$TARGET_OS = xwindows; then
784
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--no-insert-timestamp] ] , [ LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"] )
806
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--no-insert-timestamp] ] , [ LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"] ,, [ [ $LDFLAG_WERROR ] ] )
785
807
fi
786
808
fi
787
809
1213
1235
1214
1236
if test x$use_reduce_exports = xyes; then
1215
1237
CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
1216
- AX_CHECK_LINK_FLAG ( [ [ -Wl,--exclude-libs,ALL] ] , [ RELDFLAGS="-Wl,--exclude-libs,ALL"] )
1238
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--exclude-libs,ALL] ] , [ RELDFLAGS="-Wl,--exclude-libs,ALL"] ,, [ [ $LDFLAG_WERROR ] ] )
1217
1239
fi
1218
1240
1219
1241
if test x$use_tests = xyes; then
0 commit comments