Skip to content

Commit b77ee99

Browse files
authored
Unrolled build for #146518
Rollup merge of #146518 - madsmtm:ld-reproducible-doc, r=SparrowLii Improve the documentation around `ZERO_AR_DATE` In particular, document why we don't use the new `-reproducible` flag. I went through [the source for Apple's old linker](https://github.com/apple-oss-distributions/ld64), and compared the versions with [the mapping to Xcode versions on Wikipedia](https://en.wikipedia.org/wiki/Xcode) to find the relevant Xcode versions for these features. r? compiler
2 parents fa3155a + 9969622 commit b77ee99

File tree

1 file changed

+13
-3
lines changed
  • compiler/rustc_target/src/spec/base/apple

1 file changed

+13
-3
lines changed

compiler/rustc_target/src/spec/base/apple/mod.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,22 @@ pub(crate) fn base(
158158
SplitDebuginfo::Off,
159159
]),
160160

161+
// Tell the linker that we would like it to avoid irreproducible binaries.
162+
//
161163
// This environment variable is pretty magical but is intended for
162164
// producing deterministic builds. This was first discovered to be used
163165
// by the `ar` tool as a way to control whether or not mtime entries in
164-
// the archive headers were set to zero or not. It appears that
165-
// eventually the linker got updated to do the same thing and now reads
166-
// this environment variable too in recent versions.
166+
// the archive headers were set to zero or not.
167+
//
168+
// In `ld64-351.8`, shipped with Xcode 9.3, the linker was updated to
169+
// read this flag too. Linker versions that don't support this flag
170+
// may embed modification timestamps in binaries (especially in debug
171+
// information).
172+
//
173+
// A cleaner alternative would be to pass the `-reproducible` flag,
174+
// though that is only supported since `ld64-819.6` shipped with Xcode
175+
// 14, which is too new for our minimum supported version:
176+
// https://doc.rust-lang.org/rustc/platform-support/apple-darwin.html#host-tooling
167177
//
168178
// For some more info see the commentary on #47086
169179
link_env: Cow::Borrowed(&[(Cow::Borrowed("ZERO_AR_DATE"), Cow::Borrowed("1"))]),

0 commit comments

Comments
 (0)