Print this page
9939 Need to stop GCC reordering functions

Split Close
Expand all
Collapse all
          --- old/usr/src/Makefile.master
          +++ new/usr/src/Makefile.master
↓ open down ↓ 333 lines elided ↑ open up ↑
 334  334  
 335  335  # GCC, especially, is increasingly beginning to auto-inline functions and
 336  336  # sadly does so separately not under the general -fno-inline-functions
 337  337  # Additionally, we wish to prevent optimisations which cause GCC to clone
 338  338  # functions -- in particular, these may cause unhelpful symbols to be
 339  339  # emitted instead of function names
 340  340  CCNOAUTOINLINE= \
 341  341          -_gcc=-fno-inline-small-functions \
 342  342          -_gcc=-fno-inline-functions-called-once \
 343  343          -_gcc=-fno-ipa-cp \
 344      -        -_gcc6=-fno-ipa-icf \
 345  344          -_gcc7=-fno-ipa-icf \
 346  345          -_gcc8=-fno-ipa-icf \
 347      -        -_gcc6=-fno-clone-functions \
 348  346          -_gcc7=-fno-clone-functions \
 349      -        -_gcc8=-fno-clone-functions
      347 +        -_gcc8=-fno-clone-functions \
      348 +
      349 +# GCC may put functions in different named sub-sections of .text based on
      350 +# their presumed calling frequency.  At least in the kernel, where we actually
      351 +# deliver relocatable objects, we don't want this to happen.
      352 +#
      353 +# Since at present we don't benefit from this even in userland, we disable it globally,
      354 +# but the application of this may move into usr/src/uts/ in future.
      355 +CCNOREORDER=    \
      356 +        -_gcc7=-fno-reorder-functions \
      357 +        -_gcc8=-fno-reorder-functions
 350  358  
 351  359  # One optimization the compiler might perform is to turn this:
 352  360  #       #pragma weak foo
 353  361  #       extern int foo;
 354  362  #       if (&foo)
 355  363  #               foo = 5;
 356  364  # into
 357  365  #       foo = 5;
 358  366  # Since we do some of this (foo might be referenced in common kernel code
 359  367  # but provided only for some cpu modules or platforms), we disable this
↓ open down ↓ 199 lines elided ↑ open up ↑
 559  567  CCUSERFLAGS             =
 560  568  CCUSERFLAGS64           = $(CCUSERFLAGS)
 561  569  
 562  570  CSOURCEDEBUGFLAGS       =
 563  571  CCSOURCEDEBUGFLAGS      =
 564  572  $(SRCDBGBLD)CSOURCEDEBUGFLAGS   = -g -xs
 565  573  $(SRCDBGBLD)CCSOURCEDEBUGFLAGS  = -g -xs
 566  574  
 567  575  CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
 568  576                  $(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG) \
 569      -                $(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
 570      -                $(CUSERFLAGS)
      577 +                $(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
      578 +                $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
 571  579  CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
 572  580                  $(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG64) \
 573      -                $(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
 574      -                $(CUSERFLAGS64)
      581 +                $(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
      582 +                $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
 575  583  #
 576  584  # Flags that are used to build parts of the code that are subsequently
 577  585  # run on the build machine (also known as the NATIVE_BUILD).
 578  586  #
 579  587  NATIVE_CFLAGS=  $(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
 580  588                  $(ILDOFF) $(CERRWARN) $(CSTD) $($(NATIVE_MACH)_CCUNBOUND) \
 581  589                  $(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE) \
 582      -                $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
      590 +                $(CCNOREORDER) $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
 583  591  
 584  592  DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"       # For messaging.
 585  593  DTS_ERRNO=-D_TS_ERRNO
 586  594  CPPFLAGS.first= # Please keep empty.  Only lower makefiles should set this.
 587  595  CPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
 588  596          $(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
 589  597          $(ADJUNCT_PROTO:%=-I%/usr/include)
 590  598  CPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
 591  599                  $(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
 592  600  CPPFLAGS=       $(CPPFLAGS.first) $(CPPFLAGS.master)
↓ open down ↓ 599 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX