Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 936112 - sys-devel/binutils: masking the "gold" USE flag breaks LTO with Clang
Summary: sys-devel/binutils: masking the "gold" USE flag breaks LTO with Clang
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-15 15:26 UTC by Ștefan Talpalaru
Modified: 2024-07-16 00:41 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ștefan Talpalaru 2024-07-15 15:26:16 UTC
This is how the breakage was introduced: https://github.com/gentoo/gentoo/commit/04d86e2eab73e1bc80940c4cb7630a681172fd1d

"Building with link time optimization requires cooperation from the system linker. LTO support on Linux systems is available via the gold linker which supports LTO via plugins." - https://www.llvm.org/docs/GoldPlugin.html

So Clang needs "ld.gold" on Linux to be able to do LTO.

Reproducible: Always
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-07-15 19:03:19 UTC
No, it doesn't. It works fine with LLD. gold is considered dead upstream and nobody is working on it.
Comment 2 Ștefan Talpalaru 2024-07-15 19:09:54 UTC
> No, it doesn't.

# rg 'fuse-ld=gold' /usr/share/
/usr/share/cmake/Modules/Compiler/Clang.cmake
86:      set(CMAKE_${lang}_LINK_OPTIONS_IPO "-fuse-ld=gold")
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-07-15 20:18:39 UTC
(In reply to Ștefan Talpalaru from comment #2)
> > No, it doesn't.
> 
> # rg 'fuse-ld=gold' /usr/share/
> /usr/share/cmake/Modules/Compiler/Clang.cmake
> 86:      set(CMAKE_${lang}_LINK_OPTIONS_IPO "-fuse-ld=gold")

Quoting a random line from CMake doesn't contradict what I said.
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-07-15 20:19:25 UTC
The region which matches that in there for me is:
```
    if(ANDROID AND NOT CMAKE_ANDROID_NDK_VERSION VERSION_GREATER_EQUAL "22")
      # https://github.com/android-ndk/ndk/issues/242
      set(CMAKE_${lang}_LINK_OPTIONS_IPO "-fuse-ld=gold")
    endif()
```

We are not on Android. Does it match another region for you, or did you make an error?
Comment 5 Ionen Wolkens gentoo-dev 2024-07-16 00:41:11 UTC
Also, llvmgold works just fine with ld.bfd last I know of even if that page does not "recommend" it (imagine that statement is dated) -- albeit, as a sam said, should really be using ld.lld if going to do clang+lto. This is the more tested path, and lld is the default linker on a llvm profile.

(when using clang+lto+lld you do not even need llvmgold installed, albeit doesn't hurt to keep it for the rare packages that really needs ld.bfd, these packages tend to be broken with ld.gold as well)