Print this page
10468 __ctype_mask[EOF] has been working by accident
10469 GCC's -faggressive-loop-optimizations is too aggressive
10470 array over-read in has_saved_fp()
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: John Levon <john.levon@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/Makefile.master
          +++ new/usr/src/Makefile.master
↓ open down ↓ 364 lines elided ↑ open up ↑
 365  365  # GCC may put functions in different named sub-sections of .text based on
 366  366  # their presumed calling frequency.  At least in the kernel, where we actually
 367  367  # deliver relocatable objects, we don't want this to happen.
 368  368  #
 369  369  # Since at present we don't benefit from this even in userland, we disable it globally,
 370  370  # but the application of this may move into usr/src/uts/ in future.
 371  371  CCNOREORDER=    \
 372  372          -_gcc7=-fno-reorder-functions \
 373  373          -_gcc8=-fno-reorder-functions
 374  374  
      375 +#
      376 +# gcc has a rather aggressive optimization on by default that infers loop
      377 +# bounds based on undefined behavior (!!).  This can lead to some VERY
      378 +# surprising optimizations -- ones that may be technically correct in the
      379 +# strictest sense but also result in incorrect program behavior.  We turn
      380 +# this optimization off, with extreme prejudice.
      381 +#
      382 +CCNOAGGRESSIVELOOPS= \
      383 +        -_gcc7=-fno-aggressive-loop-optimizations \
      384 +        -_gcc8=-fno-aggressive-loop-optimizations
      385 +
 375  386  # One optimization the compiler might perform is to turn this:
 376  387  #       #pragma weak foo
 377  388  #       extern int foo;
 378  389  #       if (&foo)
 379  390  #               foo = 5;
 380  391  # into
 381  392  #       foo = 5;
 382  393  # Since we do some of this (foo might be referenced in common kernel code
 383  394  # but provided only for some cpu modules or platforms), we disable this
 384  395  # optimization.
↓ open down ↓ 209 lines elided ↑ open up ↑
 594  605  CCUSERFLAGS64           = $(CCUSERFLAGS)
 595  606  
 596  607  CSOURCEDEBUGFLAGS       =
 597  608  CCSOURCEDEBUGFLAGS      =
 598  609  $(SRCDBGBLD)CSOURCEDEBUGFLAGS   = $(CCGDEBUG) -xs
 599  610  $(SRCDBGBLD)CCSOURCEDEBUGFLAGS  = $(CCGDEBUG) -xs
 600  611  
 601  612  CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
 602  613                  $(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG) \
 603  614                  $(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
      615 +                $(CCNOAGGRESSIVELOOPS) \
 604  616                  $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
 605  617  CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
 606  618                  $(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG64) \
 607  619                  $(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
      620 +                $(CCNOAGGRESSIVELOOPS) \
 608  621                  $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
 609  622  #
 610  623  # Flags that are used to build parts of the code that are subsequently
 611  624  # run on the build machine (also known as the NATIVE_BUILD).
 612  625  #
 613  626  NATIVE_CFLAGS=  $(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
 614  627                  $(ILDOFF) $(CERRWARN) $(CSTD) $($(NATIVE_MACH)_CCUNBOUND) \
 615  628                  $(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE) \
 616  629                  $(CCNOREORDER) $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
 617  630  
↓ open down ↓ 620 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX