Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 737178

Summary: sys-devel/clang: add default-lld USE
Product: Gentoo Linux Reporter: jyhpsycho
Component: Current packagesAssignee: LLVM support project <llvm>
Status: RESOLVED FIXED    
Severity: normal CC: mgorny, sam
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Patch file for adding default-lld flag

Description jyhpsycho 2020-08-15 03:59:05 UTC
Created attachment 654674 [details, diff]
Patch file for adding default-lld flag

I'm testing musl-clang toolchain, for eliminating GNU toolchain(binutils, gcc, glibc) from stage3. Although llvm package itself provides most of tools like ar, as, nm, ranlib, etc. (which is provided by binutils), but ld is not included, as it's separated to lld package.

Because of specifying LD environment variable causes annoying side-effects(even does not work with some package), the correct way to build the toolchain is, change the default linker used by clang. Fortunately, clang package supports it, by setting -CMAKE_DEFAULT_LINKER CMake flag with linker name(the default value is zero-length string, which means "Use ld provided by binutils").

Thus, please add default-lld USE flags to clang ebuild, as it has same concept with default-compiler-rt and default-libcxx flags, which is not required for normal use, but provides more convenient way to build llvm toolchain which is not depend on GNU toolchain.
Comment 1 jyhpsycho 2020-08-15 04:00:41 UTC
CMAKE_DEFAULT_LINKER is typo, use CLANG_DEFAULT_LINKER.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-08-16 06:27:22 UTC
Nope, the correct way is to set CFLAGS='-fuse-ld=lld' etc.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-08-16 06:27:40 UTC
(and LDFLAGS most importantly)
Comment 4 jyhpsycho 2020-08-17 01:18:35 UTC
I know there's an option like that, but build system of some package which mis-implementd handling variables (i.e. do not append provided option but just substitute, or just ignore it) should be patched independently if some option should be passed for using specific linker. I think it's better to set default linker than track and patch all of side effects on packages.
Comment 5 jyhpsycho 2020-08-17 03:56:25 UTC
Specifying -fuse-ld=lld in CFLAGS, LDFLAGS, etc. may causes unwanted behavior on traditional systems, i.e. GCC using lld instead of bfd or gold. Per-package configuration is also possible though, I think that's not clean way to using LLVM+musl toolchain.
Comment 6 Larry the Git Cow gentoo-dev 2020-08-18 16:51:50 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=905d7440aed62f76289b2306479685bfc1040466

commit 905d7440aed62f76289b2306479685bfc1040466
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2020-08-18 15:22:12 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2020-08-18 16:51:41 +0000

    sys-devel/clang: Add USE=default-lld
    
    Closes: https://bugs.gentoo.org/737178
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 sys-devel/clang/clang-10.0.1.ebuild      | 8 +++++---
 sys-devel/clang/clang-11.0.0.9999.ebuild | 8 +++++---
 sys-devel/clang/clang-11.0.0_rc1.ebuild  | 8 +++++---
 sys-devel/clang/clang-12.0.0.9999.ebuild | 8 +++++---
 sys-devel/clang/metadata.xml             | 1 +
 5 files changed, 21 insertions(+), 12 deletions(-)