Skip to content

Commit

Permalink
Update default flags variables
Browse files Browse the repository at this point in the history
Add note about {F,FF,OBJ}FLAGS variables.
Address #162

Signed-off-by: Shane Peelar <lookatyouhacker@gmail.com>
  • Loading branch information
InBetweenNames committed Nov 1, 2018
1 parent df1b544 commit 241e089
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CXXFLAGS="${CFLAGS}"
LDFLAGS="${LDFLAGS} -Wl,--hash-style=gnu"
#Obtained from app-portage/cpuid2cpuflags utility
#Highly recommended to add these
CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
...
~~~
Expand Down Expand Up @@ -72,11 +73,22 @@ LDFLAGS="${LDFLAGS} -Wl,--hash-style=gnu"
...
~~~


For more details, there are extensive comments in both files.
Regardless of which approach you choose, you should ensure that `CXXFLAGS` is set to `CFLAGS`,
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
10 changes: 10 additions & 0 deletions sys-config/ltoize/files/make.conf.lto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@

#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
3 changes: 2 additions & 1 deletion sys-config/ltoize/files/make.conf.lto.defines
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
#* If you want -fipa-pta, include "${IPA}" in your CFLAGS
#* Anything else is up to you, such as -march, -pipe, -O{3,2,s,1}, etc...
#* CXXFLAGS should be set to CFLAGS
#* Optionally, set other *FLAGS for languages compiled with GCC as well (See make.conf.lto)
#* LDFLAGS of your Gentoo profile should be respected. Consider adding -Wl,--hash-style=gnu.
# See make.conf.lto for details.
# See make.conf.lto for more details.

#FLTO is of the form -flto[=n] where n is the number of threads to use during linking.
#It's usually a good idea to set this to the number of hardware threads in your system
Expand Down

0 comments on commit 241e089

Please sign in to comment.