Bug 1417452 Do not add FORTIFY_SOURCE if --enable-optimize is not set r?glandium draft
authorTom Ritter <tom@mozilla.com>
Thu, 16 Nov 2017 13:42:20 -0600
changeset 699209 0fde22e51170062ec2c8d82be3d7e91fc1a94693
parent 699096 a3f183201f7f183c263d554bfb15fbf0b0ed2ea4
child 740562 32dc08b42874b51eaa148349e920596d41321dc6
push id89493
push userbmo:tom@mozilla.com
push dateThu, 16 Nov 2017 20:13:39 +0000
reviewersglandium
bugs1417452
milestone59.0a1
Bug 1417452 Do not add FORTIFY_SOURCE if --enable-optimize is not set r?glandium MozReview-Commit-ID: EMjeTvqdME3
js/src/old-configure.in
old-configure.in
--- 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"