-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gcc: Add mold variant to use mold for linking #44117
base: develop
Are you sure you want to change the base?
Conversation
🎉 |
I need to check this bit: # Binutils
if spec.satisfies("+binutils"):
binutils = spec["binutils"].prefix.bin
options.extend(
[
"--with-gnu-ld",
"--with-ld=" + binutils.ld,
"--with-gnu-as",
"--with-as=" + binutils.join("as"),
]
) which I believe is not entirely correct in that is uses absolute paths instead of file names, although now that I'm reading GCC's docs it does look sensible... (https://gcc.gnu.org/install/configure.html#with-as) In any case, it's likely we can delete those lines because we have this other Also I'm OK with |
Allowing |
@@ -129,6 +129,7 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage, CompilerPackage): | |||
description="Compilers and runtime libraries to build", | |||
) | |||
variant("binutils", default=False, description="Build via binutils") | |||
variant("mold", default=False, description="Use mold as the linker by default") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting as a reminder to revisit before merging. Maybe add
variant("mold", default=False, description="Use mold as the linker by default") | |
variant("mold", default=False, description="Use mold as the linker by default", when="@12:") |
or
variant("mold", default=False, description="Use mold as the linker by default") | |
variant("mold", default=False, description="Use mold as the linker by default") | |
conflicts("+mold", when="@:11") |
@alalazo knows a way to prepend. Notice that +binutils also adds an assembler, and mold is only a linker, so we should be able to have both. |
Triggered by #44034 (comment).
This adds a
mold
variant togcc
which, when enabled, addsmold
to GCC's search paths and-fuse-ld=mold
to usemold
without a user having to specify it themselves. With these changes I'm able to create an executable that reports:It might make sense to add conflicts for when the
-fuse-ld=mold
flag doesn't work. The fallback option would be to use mold'sld
alias inlibexec/mold
and only set-B
. From what I can tell the current approach does not allow overriding the linker with a manually provided-fuse-ld
, which may be a problem for some users but I don't know how much of a problem it is as long as the mold variant is off by default.From mold's README:
Note: clang also supports
-fuse-ld=mold
, but I don't know how to enable that the same way in thellvm
package, so I'm not going to deal with that (at least in this PR...).