Bug 1438876 Enable Control Flow Guard everywhere draft
authorTom Ritter <tom@mozilla.com>
Thu, 15 Feb 2018 20:31:25 -0600
changeset 756189 83b67257f4e6d92c0261088387ff09deb36f38d8
parent 755833 994a8d6eccbcdc6106794705bd77e3ac5f031be2
child 762508 5451cfd3e9f5e3240391b373f0f03b26651c459d
push id99413
push userbmo:tom@mozilla.com
push dateFri, 16 Feb 2018 15:36:50 +0000
bugs1438876
milestone60.0a1
Bug 1438876 Enable Control Flow Guard everywhere MozReview-Commit-ID: FZrSA3ND2vA
browser/app/moz.build
js/src/old-configure.in
mozglue/build/moz.build
old-configure.in
old mode 100644
new mode 100755
--- a/browser/app/moz.build
+++ b/browser/app/moz.build
@@ -79,21 +79,16 @@ if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_
         'sandbox_s',
     ]
 
     DELAYLOAD_DLLS += [
         'winmm.dll',
         'user32.dll',
     ]
 
-    if CONFIG['CC_TYPE'] == "msvc":
-        CFLAGS += ['-guard:cf']
-        CXXFLAGS += ['-guard:cf']
-        LDFLAGS += ['-guard:cf']
-
 # Control the default heap size.
 # This is the heap returned by GetProcessHeap().
 # As we use the CRT heap, the default size is too large and wastes VM.
 #
 # The default heap size is 1MB on Win32.
 # The heap will grow if need be.
 #
 # Set it to 256k.  See bug 127069.
old mode 100644
new mode 100755
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -189,16 +189,21 @@ case "$target" in
             # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level
             CXXFLAGS="$CXXFLAGS -w15038"
         fi
 
         _CC_SUITE=14
         MSVC_C_RUNTIME_DLL=vcruntime140.dll
         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
 
+        # Enable Control Flow Guard
+        CFLAGS="$CFLAGS -guard:cf"
+        CXXFLAGS="$CXXFLAGS -guard:cf"
+        LDFLAGS="$LDFLAGS -guard:cf"
+
         # C5026: move constructor was implicitly defined as deleted
         CXXFLAGS="$CXXFLAGS -wd5026"
 
         # C5027: move assignment operator was implicitly defined as deleted
         CXXFLAGS="$CXXFLAGS -wd5027"
 
         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
old mode 100644
new mode 100755
--- a/mozglue/build/moz.build
+++ b/mozglue/build/moz.build
@@ -26,21 +26,16 @@ if CONFIG['MOZ_ASAN']:
 
 if CONFIG['OS_TARGET'] == 'WINNT':
     DEFFILE = 'mozglue.def'
     # We'll break the DLL blocklist if we immediately load user32.dll
     DELAYLOAD_DLLS += [
         'user32.dll',
     ]
 
-    if CONFIG['CC_TYPE'] == "msvc":
-        CFLAGS += ['-guard:cf']
-        CXXFLAGS += ['-guard:cf']
-        LDFLAGS += ['-guard:cf']
-
 if CONFIG['MOZ_WIDGET_TOOLKIT']:
 
     if CONFIG['MOZ_MEMORY'] and FORCE_SHARED_LIB:
         pass
         # TODO: SHARED_LIBRARY_LIBS go here
     else:
         # Temporary, until bug 662814 lands
         NoVisibilityFlags()
old mode 100644
new mode 100755
--- a/old-configure.in
+++ b/old-configure.in
@@ -182,16 +182,21 @@ case "$target" in
         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
 
         _CC_SUITE=14
         MSVC_C_RUNTIME_DLL=vcruntime140.dll
         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
 
+        # Enable Control Flow Guard
+        CFLAGS="$CFLAGS -guard:cf"
+        CXXFLAGS="$CXXFLAGS -guard:cf"
+        LDFLAGS="$LDFLAGS -guard:cf"
+
         MOZ_CHECK_HEADER(dia2.h, MSVC_HAS_DIA_SDK=1)
         if test -n "$MSVC_HAS_DIA_SDK"; then
             AC_DEFINE(MSVC_HAS_DIA_SDK)
         fi
 
         if test "$_MSC_VER" -ge "1910"; then # VS2017+
             # C5038: Enable initializer list order warnings
             # The -w1#### flag treats warning C#### as if it was a warning level