bintools-wrapper: Set ZERO_AR_DATE and re-enable LC_UUID on Darwin#188347
bintools-wrapper: Set ZERO_AR_DATE and re-enable LC_UUID on Darwin#188347lovesegfault merged 1 commit intoNixOS:stagingfrom
Conversation
The LC_UUID is a hash over the output file contents.
|
Last year I ran across this PR when looking for a way to enable debug symbols on Darwin. Today, I encountered the same need and found this again. Do you remember if there is any additional work or testing left to do? |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
While Darwin will be using |
|
I can spend some time testing if this still works. Do I understand correctly:
|
|
I think this is ready for review and testing already. To reduce the blast radius, we could gate the removal of |
I don’t think anything is reverting back to Edit: Also, I didn’t notice that ld64 also respects this variable. It’s worth setting for that as well. |
|
I've been using a bintools-wrapper with this patch applied for 7 months now – it hasn't caused any problems and works for getting debuggable outputs. I haven't done any formal verification of their reproducibility though. |
|
Let's see how it cooks in staging :) |
Background
(See #178366)
macOS uses UUIDs to associate binaries with the corresponding debug symbol bundles (
.dSYM). #77632 added-no_uuidto the linker flags in the wrapper so UUIDs aren't added in order to improve reproducibility. This breaks normal symbolication for debugging and profiling.However, the UUIDs generated by
ld64should be deterministic by default, based on the contents of the output file. See related discussion in the Chromium list: https://groups.google.com/a/chromium.org/g/security-dev/c/xAL44GDnaVI/m/qJJm5mNkAAAJWhy is the UUID not deterministic?
Since
LC_UUIDis supposed to be deterministic, there must be some differences in the input. I builtlibuvtwice, and here is the diffoscope output against the two build directories.Immediately we see the values of the SymDebugTable symbols (
N_STAB) are different:Symbol { Name: /private/tmp/nix-build-libuv-1.44.2.drv-1/source/src/.libs/libuv_la-fs-poll.o (12596) Type: SymDebugTable (0x66) Section: (0x0) RefType: ReferenceFlagUndefinedLazy (0x1) Flags [ (0x0) ] - Value: 0x6307EE91 + Value: 0x6307F1B8 }This
0x6307F1B8value is a timestamp generated here. To disable it, we can simply setZERO_AR_DATE.But a
--checkbuild still shows differences!Sadly, without sandboxing,
--checkbuilds expose a different$outto the builder, leading to a different UUID in the resulting binaries (logs). If--keep-failedis used, the different build directories for subsequent builds also cause the UUID to change (e.g.,/private/tmp/nix-build-libuv-1.44.2.drv-0and/private/tmp/nix-build-libuv-1.44.2.drv-1).The UUIDs seem to be stable across initial builds and
--checkbuilds with the same build directory.How do I test that this works without rebuilding stdenv?
I have a branch with an overridden stdenv (
stdenvWip) that uses a modifiedbintools-wrapper: https://github.com/zhaofengli/nixpkgs/commits/darwin-uuid-wip. To test:Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes