Bug 1417452 Do not add FORTIFY_SOURCE if --enable-optimize is not set r?glandium
MozReview-Commit-ID: EMjeTvqdME3
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -555,24 +555,29 @@ case "$host" in
esac
MOZ_DOING_LTO(lto_is_enabled)
dnl ========================================================
dnl Add optional and non-optional hardening flags
dnl ========================================================
+dnl In at least glibc-2.25, _FORTIFY_SOURCE requires compiling
+dnl with optimization (Bug 1417452)
+
dnl Note that in the top-level old-configure.in, we don't enable
dnl FORTIFY_SOURCE on Android. But in js/ we *can* enable it on
dnl Android, so we do.
-if test "$GNU_CC" -o -n "${CLANG_CC}${CLANG_CL}"; then
- CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
- CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
- CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
+if test -n "$MOZ_OPTIMIZE"; then
+ if test "$GNU_CC" -o -n "${CLANG_CC}${CLANG_CL}"; then
+ CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
+ CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
+ CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
+ fi
fi
dnl ========================================================
dnl System overrides of the defaults for target
dnl ========================================================
case "$target" in
*-darwin*)
--- a/old-configure.in
+++ b/old-configure.in
@@ -502,29 +502,33 @@ fi
dnl ========================================================
dnl Add optional and non-optional hardening flags
dnl ========================================================
CFLAGS="$CFLAGS $HARDENING_CFLAGS"
CPPFLAGS="$CPPFLAGS $HARDENING_CFLAGS"
CXXFLAGS="$CXXFLAGS $HARDENING_CFLAGS"
-if test "$GNU_CC" -o -n "${CLANG_CC}${CLANG_CL}"; then
- case $OS_TARGET in
- Android)
- dnl FORTIFY_SOURCE is not supported on Android on the
- dnl top-level old-configure.in at this time.
- dnl See Bug 1415595
- ;;
- *)
- CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
- CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
- CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
- ;;
- esac
+dnl In at least glibc-2.25, _FORTIFY_SOURCE requires compiling
+dnl with optimization (Bug 1417452)
+if test -n "$MOZ_OPTIMIZE"; then
+ if test "$GNU_CC" -o -n "${CLANG_CC}${CLANG_CL}"; then
+ case $OS_TARGET in
+ Android)
+ dnl FORTIFY_SOURCE is not supported on Android on the
+ dnl top-level old-configure.in at this time.
+ dnl See Bug 1415595
+ ;;
+ *)
+ CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
+ CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
+ CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
+ ;;
+ esac
+ fi
fi
dnl ========================================================
dnl GNU specific defaults
dnl ========================================================
if test "$GNU_CC"; then
MMX_FLAGS="-mmmx"
SSE_FLAGS="-msse"