Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

ld.gold, LTO and LDFLAGS

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
fulminemizzega
n00b
n00b
Posts: 12
Joined: Sun Jun 09, 2013 11:32 pm

ld.gold, LTO and LDFLAGS

  • Quote

Post by fulminemizzega » Fri Feb 14, 2014 10:32 pm

Hello!
http://pastebin.com/K7vGY7Vk
I need some advice on setting LDFLAGS and ld debugging.
Until yesterday, I had compiled the most part of @world using gold.
Since I had some weird issues (gnome-shell 3.10 with bluetooth flag compiled but didn't display anything, WiFi losing connection continuosly), I finally decided to rebuild everything. It took quite long, especially because during the emerging I encountered more errors than I thought. First it started with libsndfile (LTO flags), which looks like it doesn't compile with gold. Thus, I discovered that gold can't be used to compile everything (and probably I was also warned). So I switched back to bfd, and libsndfile compiled. This made me realize that gold could have done something wrong to some other packages. I decided to stick with ld.bfd and restarted emerging world from the beginning. This caused more build failures than before, on app-crypt/gcr, mesa, dbus, systemd, and git. I decided to read more about gold, and found that it isn't suited yet for compiling the Linux kernel (an so also other packages) and that it doesn't support all the flags ld.bfd supports, like --as-needed. Since I originally took my CFLAGS and LDFLAGS from http://realnc.blogspot.it/2012/06/build ... 7-and.html , I didn't really mind about what did those LDFLAGS do.
Then I found that --as-needed could be the reason for gcr compiling errors (I think they where "undefined reference ..."). So I disabled it for gcr, and it worked. Mesa failed also, solved disabling --as-needed (lto already disabled, via package.env)

Now to the story: at this point, dbus comes in, compiled with LTO and --as-needed (with bfd).
Systemd didn't compile with bfd. It also was failing for the same reason as gcr, so I thought to disable --as-needed also for systemd. Same error. Then I tried to compile it with gold, and it worked, and I was quite astonished. So I tried to compile it with bfd but with empty CFLAGS and LDFLAGS. Failure. Then I thought that maybe it was dbus that had something missing, for some reason. After a few tries, I found that dbus had to be compiled without LTO I had to create a new conf file in /etc/portage/env with

Code: Select all

CFLAGS="-O2 -pipe -fomit-frame-pointer -march=core-avx2 -mtune=core-avx2"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,--hash-style=gnu"
Now I don't like this solution, but this way systemd compiled (and I think it works...) with bfd and even LTO.
Then I found that git doesn't like --as-needed.
And world had finished emerging.

Differences : now WiFi stays on, many errors in dmesg are gone, my screen brightness control (toshiba laptop) works correctly (they never had...)
Now I still have to compile back bluetooth support in gnome-shell and check the results.
I don't really know if lto, --as-needed or gold had something to do with everything I noticed, but they changed something.

To summarize: mesa, app-crypt/gcr, git do not like --as-needed. Some things compile with gold but not with bfd, unless you change ldflags. Libsndfile does not compile with gold. Some things compiled with gold do not work as expected.

I need your advice: I'd like to stick with LTO, even if it causes a good number of headaches (at least the first time you emerge a new package) but I don't know if I should continue to use --as-needed. From what I have understood, it does a good thing, but it can be dangerous. Do you think dropping it is just safer, and stopping wasting time on it better?
Is it possible that a package compiles with --as-needed but has problems at runtime? Is there any tool to find if ld has removed too many symbols, which ones and a way to fix the breakage?
Then I'd like to understand why dbus and systemd required that ugly workaround.
Last thing: some packages (WebKit-gtk, chromium, Firefox) use all system ram with bfd, that's why I switched to gold. What do you think of gold, whether it can be used system-wide or not, and is there any way to use gold only on a few packages, like cflags with packages.env?
Last edited by fulminemizzega on Sat Feb 15, 2014 10:22 pm, edited 1 time in total.
Top
PaulBredbury
Watchman
Watchman
User avatar
Posts: 7310
Joined: Thu Jul 14, 2005 3:47 pm

Re: ld.gold, LTO and LDFLAGS

  • Quote

Post by PaulBredbury » Fri Feb 14, 2014 11:06 pm

fulminemizzega wrote:I'd like to stick with LTO
LTO is unstable, I no longer bother with it :(
Top
darklegion
Guru
Guru
Posts: 468
Joined: Sun Nov 14, 2004 1:47 am

Re: ld.gold, LTO and LDFLAGS

  • Quote

Post by darklegion » Sat Feb 15, 2014 1:03 am

PaulBredbury wrote:
fulminemizzega wrote:I'd like to stick with LTO
LTO is unstable, I no longer bother with it :(
I don't blame you; it's usually the first thing I check if something fails to compile. Distcc and and "-jX" are the other ones. Hopefully all of those will get sorted out eventually.

The good thing is that we have package.env these days which makes things a lot easier to workaround at least.
Top
fulminemizzega
n00b
n00b
Posts: 12
Joined: Sun Jun 09, 2013 11:32 pm

  • Quote

Post by fulminemizzega » Sat Feb 15, 2014 10:48 pm

Compiled back bluetooth support in gnome-shell, everything is working as expected.
Since you had some experience on using LTO, what do you think of ld.gold, and is there anyway to use it only on a few packages like cflags with packages.env?
About the --as-needed LDFLAG, have you had some experience with it?
Top
Post Reply

4 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic