Skip to content

Commit

Permalink
Update default compiler flags
Browse files Browse the repository at this point in the history
Enable -fno-semantic-interposition by default
Add off by default define for -fno-common
Reference #164
  • Loading branch information
InBetweenNames committed Nov 4, 2018
1 parent d445c93 commit 087b6f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ Regardless of which approach you choose, you should ensure that `CXXFLAGS` is se
and your Portage profile's `LDFLAGS` are respected. I also enable `-Wl,--hash-style=gnu` as it
can help catch packages that don't respect `LDFLAGS`, but this is optional.

Additionally, you may want to set environment variables for other languages compiled by GCC as well, for
cross-language LTO:

~~~
FCFLAGS="${CFLAGS}"
FFLAGS="${CFLAGS}"
OBJCFLAGS="${CFLAGS}"
OBJCXXFLAGS="${CFLAGS}"
~~~

It is strongly recommended to use the latest GCC (8.2.0 at the time of writing), latest binutils (2.31.1 currently), and latest glibc (2.28 currently).

When you find a problem, whether it's a package not playing nice with -O3, Graphite, or LTO, consider opening an issue here or sending a pull request with the overrides needed to get the package working. Over time, we should be able to achieve full coverage of `/usr/portage` this way and provide a one size fits all solution, and not to mention help improve some open source software through the bug reports that will no doubt be generated!
Expand Down
12 changes: 1 addition & 11 deletions sys-config/ltoize/files/make.conf.lto
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@

#CXXFLAGS="${CFLAGS}"

#In addition, you may want to modify the environment variables for other languages compiled with GCC as well:

#FCFLAGS="${CFLAGS}"
#FFLAGS="${CFLAGS}"
#OBJCFLAGS="${CFLAGS}"
#OBJCXXFLAGS="${CFLAGS}"

#This list is pulled from the autotools documentation:
#https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Environment-Variable-Index.html

#Your LDFLAGS should contain *ALL* of your CFLAGS for LTO to work. It must receieve all optimization options, march, etc.
#package.cflags takes care of this for you--no need to manually add your {C,CXX}FLAGS here.
#It's usually a good idea to enable -Wl,--hash-style=gnu as well to help find packages which don't respect LDFLAGS
Expand Down Expand Up @@ -81,7 +71,7 @@ source make.conf.lto.defines

#Thanks to issue #49, no action necessary for preventing stripping of static libraries

CFLAGS="-O3 ${GRAPHITE} ${IPA} ${FLTO} -fuse-linker-plugin"
CFLAGS="-O3 ${GRAPHITE} ${IPA} ${SEMINTERPOS} ${FLTO} -fuse-linker-plugin"

#Your CXXFLAGS should be a superset of your CFLAGS. Most people will never need to add anything extra to their CXXFLAGS.
#CXXFLAGS="${CFLAGS}"
Expand Down
9 changes: 9 additions & 0 deletions sys-config/ltoize/files/make.conf.lto.defines
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ IPA="-fipa-pta"
#IPA contains -fipa* opts that are disabled by default in GCC. These are interprocedural optimizations. For now this is only -fipa-pta.
#This option increases compile times, but can potentially produce better binaries, especially with LTO.
#Essentially, it allows the compiler to look into called function bodies when performing alias analysis

SEMINTERPOS="-fno-semantic-interposition"

# With -fno-semantic-interposition the compiler assumes that if interposition happens for functions the overwriting function will have precisely the same semantics (and side effects). Similarly if interposition happens for variables, the constructor of the variable will be the same. The flag has no effect for functions explicitly declared inline (where it is never allowed for interposition to change semantics) and for symbols explicitly declared weak.

NOCOMMON="-fno-common"

# This option only affects C code. Only non-conformant C code needs -fcommon, which is enabled by default. Clear Linux leaves this flag off by default.
# We may enable this at some point. For now, there's a lot of breakages to work through.

0 comments on commit 087b6f7

Please sign in to comment.