-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
LLD linker does not have required nixpkgs wrapper script and flags #24744
Comments
This would be a nice addition to speed up Haskell builds by reducing time in linking phase. |
As part of my work this summer on speeding up Nix Haskell builds for Awake Networks, I'm interested in tackling this issue (and upstreaming a fix). Does it just amount to adding something similar to the code snippet below to
or should I be modifying the |
@taktoa I can't answer conclusively, but I suspect it won't be as trivial as using the exiting scripts. The right approach is likely to first do a proper reads through all things nixpkgs does to For example, I know that |
@taktoa we're interested in this project at https://github.com/input-output-hk as well - maybe we could have quick chat and join some forces :) we invested a bit of time into parallel GC and general GHC option tuning for scaling the compilation into multiple cores: https://github.com/input-output-hk/iohk-nixops/pull/49/files Indeed linking takes a hell lot of time, but |
@taktoa for this particular change, I'd talk to @vcunat or @wkennington |
Assuming the relevant linker options have the same syntax, I'd expect that the same wrapping approach should work. The way cc-wrapper is written now, I'd suggest to first try adding an option that makes it include |
I have now added the for instance, you can run llvm linker:
Also install lld using:
|
@matthewbauer The actionable part from the issue description was:
Concretely, we want to be able to:
If your |
Can't easily override stdenv in haskell #66267, but could be checked by overriding it in nixpkgs and see if darwin builds. |
lld buildInput is still needed for the library. Related: #24744
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:
|
I discovered that the following can be used for incremental development: { pkgs ? import <nixpkgs> {} }:
let
bintools_lld = pkgs.wrapBintoolsWith {
bintools = pkgs.llvmPackages_10.bintools;
};
in pkgs.mkShell {
buildInputs = [ pkgs.stdenv bintools_lld ];
hardeningDisable = [ "fortify" ];
NIX_CFLAGS_LINK = "-fuse-ld=lld";
} It would be great if there was an easier way to achieve that, but I'm unsure of what would be a good way to expose lld. |
You could use |
I marked this as stale due to inactivity. → More info |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/rust-c-link-time-optimization/13276/1 |
Using |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-rpath-works-or-doesnt-on-nixos/18182/1 |
Let me restate the solution more clearly: There are two packages that provide LLD in nixpkgs: |
That raises the question whether |
How did you make it work in the end exactly ?
|
@happysalada https://matklad.github.io/2022/03/14/rpath-or-why-lld-doesnt-work-on-nixos.html includes some notes on debugging. Useful things:
|
for me adding Thanks again for the help! |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/using-mold-as-linker-prevents-libraries-from-being-found/18530/2 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/using-mold-as-linker-prevents-libraries-from-being-found/18530/3 |
I used the following to make # Define settings
# Toolchain.
gccVersion = "13";
gccPkg = pkgs."gcc${gccVersion}";
llvmVersion = "17";
llvmPkgs = pkgs."llvmPackages_${llvmVersion}";
clangStdEnv = pkgs.stdenvAdapters.overrideCC llvmPkgs.stdenv (
llvmPkgs.clang.override {
bintools = llvmPkgs.bintools;
gccForLibs = gccPkg.cc; # This is the unwrapped gcc.
}
);
clangStdEnv.mkDerivation( ... ) |
Here's a wrapped { clangStdenv, lld, path }:
clangStdenv.cc.bintools.override {
extraBuildCommands = ''
for ld in $(find ${lld}/bin -name "ld*" -printf "%f\n"); do
wrap ${clangStdenv.cc.bintools.targetPrefix}$ld \
${path + /pkgs/build-support/bintools-wrapper/ld-wrapper.sh} \
${lld}/bin/$ld
done
'';
} |
@szlend however on linux it shouldn't be using clangStdenv? |
Yeah. For my use case I wanted to use |
Currently using the
lld
linker in nix doesn't work correctly.Executables that it produces have entries in
lld
beingnot found
(rpaths are missing).That's because
ld
andgold
have wrappers that do the following:nixpkgs/pkgs/build-support/cc-wrapper/ld-wrapper.sh
Line 133 in 593b46f
But
lld
currently doesn't have such a wrapper.(I found this via See also #24692 (comment).)
Also this type of patch or setting to
--enable-new-dtags
will likely be needed, and potentially other changes nixpkgs makes told
andgold
.The text was updated successfully, but these errors were encountered: