summaryrefslogtreecommitdiff
path: root/usr/src/Makefile.master
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/Makefile.master')
-rw-r--r--usr/src/Makefile.master13
1 files changed, 13 insertions, 0 deletions
diff --git a/usr/src/Makefile.master b/usr/src/Makefile.master
index 501853a6ed..5321004bff 100644
--- a/usr/src/Makefile.master
+++ b/usr/src/Makefile.master
@@ -372,6 +372,17 @@ CCNOREORDER= \
-_gcc7=-fno-reorder-functions \
-_gcc8=-fno-reorder-functions
+#
+# gcc has a rather aggressive optimization on by default that infers loop
+# bounds based on undefined behavior (!!). This can lead to some VERY
+# surprising optimizations -- ones that may be technically correct in the
+# strictest sense but also result in incorrect program behavior. We turn
+# this optimization off, with extreme prejudice.
+#
+CCNOAGGRESSIVELOOPS= \
+ -_gcc7=-fno-aggressive-loop-optimizations \
+ -_gcc8=-fno-aggressive-loop-optimizations
+
# One optimization the compiler might perform is to turn this:
# #pragma weak foo
# extern int foo;
@@ -601,10 +612,12 @@ $(SRCDBGBLD)CCSOURCEDEBUGFLAGS = $(CCGDEBUG) -xs
CFLAGS= $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG) \
$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
+ $(CCNOAGGRESSIVELOOPS) \
$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
CFLAGS64= $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG64) \
$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
+ $(CCNOAGGRESSIVELOOPS) \
$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
#
# Flags that are used to build parts of the code that are subsequently