ghc: check for targetPlatform.linker to determine if gold is available#126205
Conversation
There was a problem hiding this comment.
What does targetPlatform.linker == "bfd" mean?
(Also, why does this mean that gold should be used?)
One other question I had: what made you want to change/fix this? Were you seeing a problem that targetPlatform.useLLVM wasn't catching?
Ideally I guess there would be a comment here explaining the reasoning for the check. At the very least, I don't know what is going on here (although I did sort of understand the !useLLVM check).
There was a problem hiding this comment.
ld.bfd is the classic GNU ld that uses the bfd library which was (at least historically) behind most of binutils and gdb. ld.gold is the alternative one that is a bit odd that it is even part of the binutils project at all. Had it been started a few years later, I assume it would have been an LLVM instead (and been more like LLD).
There was a problem hiding this comment.
There was a problem hiding this comment.
Interestingly, if we moved it to a separate package too, it would probably be easier to implement linker == "gold".
There was a problem hiding this comment.
One other question I had: what made you want to change/fix this? Were you seeing a problem that targetPlatform.useLLVM wasn't catching?
useLLVM implies linker == "lld", but we recently made it (theoretically) possible to have something like useLLVM without linker == "lld" (which was when linker was introduced in the first place). Thus checking linker is more accurate and future proof.
bfd implies the binutils package is used for bintools which contains ld.gold at least in nixpkgs.
|
|
Not sure if I quite understood you correctly, is 7babbf76889 what you had in mind? |
|
@sternenseemann Yes that is what i was thinking, and i added some suggestions for a few other nits. |
7babbf7 to
6d4a3e8
Compare
useLdGold previously just checked for useLLVM which (currently) implies `linker == "lld"`. However more accurate is to check the `linker` of the `targetPlatform` as it actually tells us which bintools package we can expect. `linker == "bfd"` implies that we are using the `binutils` package, so gold is available, so we can use it unless musl is the libc. `linker == "gold"` implies that gold is the default linker already and we should absolutely use it.
6d4a3e8 to
036eef1
Compare
useLdGold previously just checked for useLLVM which (currently) implies
linker == "lld". However more accurate is to check thelinkerof thetargetPlatformas it actually tells us which bintools package we canexpect.
I'm not handling
linker == "gold"so far. This doesn't seem to happenin any case so far, so it is hard to tell what it would imply. Maybe
${bintools}/bin/ldwould be gold in that case, so it'd be wrong topass
-fuse-ld=gold?Motivation for this change
Things done
sandboxinnix.confon non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)