Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
lto with gcc 5.4, how exactly?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Sadako
Advocate
Advocate


Joined: 05 Aug 2004
Posts: 3789
Location: sleeping in the bathtub

PostPosted: Thu Mar 23, 2017 5:38 pm    Post subject: lto with gcc 5.4, how exactly? Reply with quote

Hiyas, I haven't been active in quite a while, preparing a fresh install in a chroot.

I want to enable lto system-wide, as I had before, but unsure of the "correct" method as I suspect what I used before is somewhat out of date, and I'm seeing a fair bit of conflicting information online with no clear guides.

I have the following in my old install, with gcc 4.7;
Code:
CFLAGS='-O2 -march=amdfam10 -pipe'
CFLAGS="${CFLAGS} -flto=4"
#CFLAGS="${CFLAGS} -flto=4 -fno-fat-lto-objects"
#CFLAGS="${CFLAGS} -fwhole-program"

CXXFLAGS="${CFLAGS}"

LDFLAGS="${LDFLAGS} ${CFLAGS}"

Is this all that`s really needed?
Is it still necessary to append CFLAGS to LDFLAGS?
Is -fno-fat-lto-objects required/usefull?
I've seen -fuse-linker-plugin mentioned a few times, is it required?
I haven't seen -fwhole-program mentioned anywhere, is that considered pointless or unsupported now?

TY for any help/feedback.

edit: from the gcc docs, wrt -fwhole-program;
"This option should not be used in combination with -flto. Instead relying on a linker plugin should provide safer and more precise information."
Guess that answers that one, at least.
_________________
"You have to invite me in"
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Fri Mar 24, 2017 12:44 am    Post subject: Reply with quote

march native.

And there is a topic from some guys using lto in this forum
https://forums.gentoo.org/viewtopic-t-1056550-highlight-lto.html

Quote:
CFLAGS="-march=native -pipe -Wno-narrowing"# -flto=8"
CXXFLAGS="${CFLAGS} -fno-delete-null-pointer-checks -flifetime-dse=1 -fpermissive"
LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"# -Wl,-flto=8"


Quote:
https://forums.gentoo.org/viewtopic-t-1052716-highlight-lto.html

Title: LTO: We are almost there
Quote:
AR="/usr/bin/gcc-ar"
NM="/usr/bin/gcc-nm"
RANLIB="/usr/bin/gcc-ranlib"

FLTO="-flto=8 -fuse-linker-plugin -fno-fat-lto-objects"
FGRAPHITE="-fgraphite-identity -floop-interchange -floop-strip-mine -floop-block"
CFLAGS="-O2 -pipe -march=native -mtune=skylake -w ${FLTO} ${FGRAPHITE}"
CXXFLAGS="${CFLAGS} -fno-delete-null-pointer-checks -flifetime-dse=1"
LDFLAGS="-Wl,-O1,--sort-common,--hash-style=gnu,--as-needed,-z,now ${CXXFLAGS}"
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3158
Location: Illinois, USA

PostPosted: Fri Mar 24, 2017 12:56 am    Post subject: Reply with quote

Why not just update your present install? How old is it?
Back to top
View user's profile Send private message
Sadako
Advocate
Advocate


Joined: 05 Aug 2004
Posts: 3789
Location: sleeping in the bathtub

PostPosted: Fri Mar 24, 2017 3:48 am    Post subject: Reply with quote

Roman_Gruber wrote:
march native.

And there is a topic from some guys using lto in this forum
https://forums.gentoo.org/viewtopic-t-1056550-highlight-lto.html
I did read through both those threads before posting, and tbh they just raised more questions than answers, for example are the AR, NM, RANLIB variables really needed, and why?
And I keep seeing mentions of the gold linker, but no explanation of how to use it and if or why you should.

I guess I can start with "-flto=4 -fuse-linker-plugin -fno-fat-lto-objects" at least.

I just find it odd that there's no definitive guide or recommendations for using it, even the gentoo wiki article which brings it up doesn't explain how to enable lto, simply that "I think it is safe to also enable LTO at this point.", although they go into good detail on graphite.

Tony0945 wrote:
Why not just update your present install? How old is it?
Last emerge was february 2013, according to emerge.log, so pretty damn old I think. :P

I'm moving to an ssd on that box anyways, and a fresh install would prob be less hassle overall.

Anyways, ty both for your replies.
_________________
"You have to invite me in"
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3158
Location: Illinois, USA

PostPosted: Fri Mar 24, 2017 1:23 pm    Post subject: Reply with quote

Sadako wrote:
Last emerge was february 2013, according to emerge.log, so pretty damn old I think. :P

I'm moving to an ssd on that box anyways, and a fresh install would prob be less hassle overall.

That makes sense. I suggest doing the fresh install on the SSD, copying over your world file, updating world, and then copying /home
You may or may not consider "emerge -e world" since the fresh install will just give you generic amd64 binaries. It is controversial, but it seems most of the advantage of compiling for your particular CPU was in the 32 bit days. There isn't that much difference anymore. I would do it and let run. Anywhere from overnight to four days depending on how "hot" your system is. If it's a gaming rig, it's "hot" and will build fast. If it's an old low power CPU with little memory, it can take up to four days (AMD k6 with 384Meg of memory).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum