Skip to content
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

Set ZERO_AR_DATE=1 for deterministic static libraries on macOS #494

Closed
luser opened this issue May 4, 2020 · 3 comments
Closed

Set ZERO_AR_DATE=1 for deterministic static libraries on macOS #494

luser opened this issue May 4, 2020 · 3 comments

Comments

@luser
Copy link

luser commented May 4, 2020

Just the other day I learned that Apple's ar tool has an undocumented environment variable that you can use to get it to zero out timestamps so you get reproducible archives! Setting ZERO_AR_DATE=1 apparently triggers this behavior.

Here's the source for reference:
https://opensource.apple.com/source/cctools/cctools-949.0.1/misc/libtool.c.auto.html

It's also mentioned in this LLVM blog post:
http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html

This would help fix mozilla/sccache#169 .

@alexcrichton
Copy link
Member

This was actually already added in 555e773, although did I forget a different place we need to put that?

FWIW I didn't know this env var affected the linker, but if so then we should probably update rust-lang/rust to set this env var for the linker unconditionally.

@luser
Copy link
Author

luser commented May 5, 2020

Oh nice! I did search the repo for issues but didn't search the code so I didn't see that. Oops!

FWIW I didn't know this env var affected the linker, but if so then we should probably update rust-lang/rust to set this env var for the linker unconditionally.

Good point! I hadn't looked into that but apparently it makes ld64 zero out timestamps in the N_OSO stabs it writes that point back to object files (that dsymutil uses to link debug info):
https://github.com/apple-opensource/ld64/blob/fd3feabb0a1eb18ab5d7910f3c3a5eed99cef6ab/src/ld/Options.cpp#L4420

I'll open an issue on the Rust repo for that!

@luser luser closed this as completed May 5, 2020
@luser
Copy link
Author

luser commented May 5, 2020

Oh you already filed one a while back and someone mentioned this there, hah:
rust-lang/rust#47086 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants