Conversation
|
would be totally neat if this got merged |
|
I tested the following under
|
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/1100 |
| mv $out/bin/mold $out/bin/.mold | ||
|
|
||
| export prog=$out/bin/.mold |
There was a problem hiding this comment.
Why not use wrapProgram or makeWrapper?
There was a problem hiding this comment.
i don't understand how those tools would help solve the problem in a better way.
There was a problem hiding this comment.
I don't think this would help here.
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
|
Linkers in nixpkgs are left unwrapped intentionally – our wrapper scripts are quite invasive and we want users to be able to deal with more low-level situations manually as well – outside of Therefore, you work should be split into |
|
Can I help to get this merged? |
|
I don't have any capacity to work on this at the moment. Fell free to open a new PR and work in the suggestions from @sternenseemann. |
|
@RaitoBezarius I've poked at using wrapBintools for this for a proof of concept for work. One big issue with it is that it's less than helpful on macOS without some patching. Further, it's hard to test since changing the original file will be a world rebuild. We should possibly introduce a new parameter to it or use a postInstall hook or something to work around this issue. { mold
, stdenv
, libcCross
, callPackage
, darwin
}:
let wrapBintoolsWith2 =
{ bintools
, libc ? if stdenv.targetPlatform != stdenv.hostPlatform then libcCross else stdenv.cc.libc
, ...
} @ extraArgs:
callPackage ./pkgs/build-support/bintools-wrapper2 (
let self = {
nativeTools = stdenv.targetPlatform == stdenv.hostPlatform && stdenv.cc.nativeTools or false;
nativeLibc = stdenv.targetPlatform == stdenv.hostPlatform && stdenv.cc.nativeLibc or false;
nativePrefix = stdenv.cc.nativePrefix or "";
noLibc = (self.libc == null);
inherit bintools libc;
inherit (darwin) postLinkSignHook signingUtils;
} // extraArgs; in self
);
in
wrapBintoolsWith2 {
bintools = mold;
}I've patched binutils-wrapper2/default.nix like so: |
|
Here is the updated self contained version of the hack that people can vendor (don't use The wrapper injected that flag because it was supported on the ELF targeting one, which is wrong. Cause: # Kinda evil wrapper for mold to get all the nix flags but whatever, it works
{ mold
, wrapBintoolsWith
, path
}:
(wrapBintoolsWith {
bintools = mold;
}).overrideAttrs (old: {
# for baffling reasons postInstall is not getting run. no idea, buddy.
installPhase = old.installPhase + ''
for variant in ld.mold ld64.mold; do
# XXX: probably broken with cross compilation, w/e
local underlying=$ldPath/$variant
[[ -e "$underlying" ]] || continue
wrap $variant ${path}/pkgs/build-support/bintools-wrapper/ld-wrapper.sh $underlying
done
'';
}) |
|
fyi: on Linux you don't need any of that override stuff, and I think that Linux-only is an ok starting point for now! |
|
Anything blocking this? |
|
i think #216383 replaces the need for this pr |
Description of changes
Wrapping mold so it can find libraries from the nix build environment.
See #24744 for additional context. The situation with lld is very similar, but mold was easier to fix.
Demo:
check in a
nix-shellwith additional dependenciesverify that this doesn't involuntarily break linking when used with rust
Built on platform(s)
For non-Linux: Is
sandbox = trueset innix.conf? (See Nix manual)Tested, as applicable:
Tested compilation of all packages that depend on this change using
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usageTested basic functionality of all binary files (usually in
./result/bin/)22.05 Release Notes (or backporting 21.11 Release notes)
nixos/doc/manual/md-to-db.shto update generated release notesFits CONTRIBUTING.md.