Repository navigation
Description
Describe the bug
#77632 made builds on darwin reproducible (yay!) in part by causing the darwin stdenv’s cc wrapper to set the -no_uuid linker flag so as to avoid random uuid build-ids being added to all compiled binaries and libraries.
Unfortunately, while setting this flag was effective for improving reproducibility, I think (and will hopefully soon test) that setting it also had the side-effect of breaking symbolication of binaries built with the resulting toolchain, for example, interfering with profiling them with Instruments or debugging them with lldb.
Desired resolution
Ideally, I imagine we’d find a way to set UUIDs deterministically, I suppose a little bit like how placeholder hash insertion works.
Failing that, in the shorter term, I'd love for there to be a well-documented way to remove the -no_uuid flag so that users who want UUIDs can readily obtain them or, I suppose, to add new UUIDs after the fact?
Anyway, what I've found so far is: in simple situations, overriding via an overlay can help, like so:
...
final: prev: rec {
bintools = prev.bintools.overrideAttrs (old: {
postFixup = builtins.replaceStrings ["-no_uuid"] [""] old.postFixup;
});
cc = prev.stdenv.cc.overrideAttrs (old: {
bintools = bintools;
});
stdenv = prev.overrideCC prev.stdenv cc;
sigtool = stdenv.mkDerivation {
inherit name;
src = self;
nativeBuildInputs = [ pkg-config meson ninja ];
buildInputs = [ openssl ];
dontStrip = true;
separateDebugInfo = true;
mesonBuildType = "debug";
ninjaFlags = "-v";
};
...
}however, I'm still struggling to make this approach work well with more complex situations, for example, using https://github.com/oxalica/rust-overlay.
(There, trying to use this simple approach runs in to difficulty because it's not clear where and how to override the darwin stdenv: trying to do so alongside a new build isn't quite enough because (at least the way I'm loading it) the rust-overlay captures the wrong stdenv; however, trying to do so via an earlier overlay runs into challenges with the staged structure of the darwin stdenv, such that the cc = prev.stdenv.cc.overrideAttrs override can fail because prev.stdenv.cc is set to the string "/dev/null" in early stages, and hence has no overrideAttrs attr itself.)
Note: you can test whether or not built binaries have uuids in a variety of ways, including
dwarfdump -u <path>
which exit with success and will print nothing when UUIDs are missing, or by using any of a variety of other DWARF tools, searching for the LC_UUID tag.
Activity
mstone commentedon Jun 21, 2022
Quick update: I managed to work around this issue again in my current project, via two additional project-specific overrides:
but getting all of this worked out was rather painful and involved both quite detailed
nix repl,nix show-derivation, andnix-tree-style investigation as well as carefully reading/grepping some long chains of wrapper shell-scripts, e.g.:and lots of experimentation.
zhaofengli commentedon Aug 25, 2022
This is a problem for us.
-no_uuidmakes debugging so annoying. Some more info from the Chromium/Electron teams:To quote:
From my limited testing on aarch64-darwin, the UUID seems to be stable for
helloandafter removinglibuv-no_uuidfrom the flags. I didn't rebuild stdenv from scratch but just overrode bintools with my modified wrapper.Edit: Actually scratch that, the UUIDs for
libuv.1.dylibdo differ from build to build. Need to look deeper into the root cause...zhaofengli commentedon Aug 26, 2022
I took a stab at the issue and opened #188347.
mstone commentedon Aug 31, 2022
@zhaofengli — thanks for working on this issue!
I haven’t had a chance to test your PR yet but it looks like a really promising approach!
aykevl commentedon Oct 6, 2023
This bug required an ugly workaround for the tinygo package on Darwin: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/tinygo/0003-Use-out-path-as-build-id-on-darwin.patch
If
-no_uuidproduces a non-reproducible build then that's a bug in the linker or the build system. It is supposed to be reproducible.CC @muscaln
builder: generalize build ID fallback to darwin
builder: generalize build ID fallback to darwin
builder: generalize build ID fallback to darwin
builder: generalize build ID fallback to darwin
reckenrode commentedon Jul 8, 2024
#188347 is the default since 23.11. Is this issue resolved now?
reckenrode commentedon Jul 28, 2024
Closing since this should be fixed by #188347.