Skip to content

fix(ar): deterministic archives with D modifier#1697

Merged
NobodyXu merged 2 commits intorust-lang:mainfrom
weihanglo:ar
Apr 2, 2026
Merged

fix(ar): deterministic archives with D modifier#1697
NobodyXu merged 2 commits intorust-lang:mainfrom
weihanglo:ar

Conversation

@weihanglo
Copy link
Copy Markdown
Member

Try the D modifier which zeros out timestamps in archive headers.
Fall back to the previous behavior if not supported.

Fixes #1696

Copy link
Copy Markdown
Contributor

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I've got some feedback for you, hopefully we can get this merged and released this Friday/Weekend

cc @madsmtm

Comment thread src/lib.rs Outdated
// Not all ar implementations support it, so we try with `D` first
// and fall back without it.
if !run_silent(cmd.arg("cqD").arg(dst).args(objs)) {
let (mut cmd, _, _) = self.try_get_archiver_and_flags()?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we already set this, just before the if?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command doesn't implemented Clone, unfortunately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, in that case shall we remove that env setting, given that we use option D then?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the simplified version :)

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
The `cq` path already sets this for determinism on macOS,
but the subsequent `ar s` step was missing it.
Copy link
Copy Markdown
Member Author

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also drop the macOS probe failure suppression, which is just one command failure and I think it is fine.
(I don't like the code complexlity in 400a5a8)

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
// Not all ar implementations support it, so we try with `D` first
// and fall back without it.
if !run_silent(cmd.arg("cqD").arg(dst).args(objs)) {
let (mut cmd, _, _) = self.try_get_archiver_and_flags()?;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command doesn't implemented Clone, unfortunately.

@weihanglo weihanglo requested a review from NobodyXu April 2, 2026 00:34
Comment thread src/lib.rs Outdated
Try the `D` modifier which zeros out timestamps in archive headers.
Fall back to the previous behavior if not supported.

See <rust-lang#1696>
Copy link
Copy Markdown
Contributor

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, LGTM!

@NobodyXu NobodyXu merged commit 025d046 into rust-lang:main Apr 2, 2026
79 checks passed
@weihanglo weihanglo deleted the ar branch April 2, 2026 12:37
@jcamiel
Copy link
Copy Markdown

jcamiel commented Apr 5, 2026

Hi, I maintain the project https://github.com/Orange-OpenSource/hurl, I try to identify some new warnings on macOS / Sequoia:

$ cargo build 
...
warning: [email protected]: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: illegal option -- D
warning: [email protected]: usage:  ar -d [-TLsv] archive file ...
warning: [email protected]: 	ar -m [-TLsv] archive file ...
warning: [email protected]: 	ar -m [-abiTLsv] position archive file ...
warning: [email protected]: 	ar -p [-TLsv] archive [file ...]
warning: [email protected]: 	ar -q [-cTLsv] archive file ...
warning: [email protected]: 	ar -r [-cuTLsv] archive file ...
warning: [email protected]: 	ar -r [-abciuTLsv] position archive file ...
warning: [email protected]: 	ar -t [-TLsv] archive [file ...]
warning: [email protected]: 	ar -x [-ouTLsv] archive [file ...]
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.03s

This warning happens when I'm upgrading cc from 1.2.58 to 1.2.59:

With 1.2.58:

$ cargo build                        
   Compiling cc v1.2.58
   Compiling openssl-sys v0.9.112
   Compiling libz-sys v1.1.25
   Compiling curl-sys v0.4.87+curl-8.19.0
   Compiling hurl v8.0.0-SNAPSHOT (/Users/jc/Documents/Dev/hurl/packages/hurl)
   Compiling curl v0.4.49
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.17s

Just updating to 1.2.59:

$ cargo build
    Updating crates.io index
     Locking 1 package to latest compatible version
    Updating cc v1.2.58 -> v1.2.59
warning: [email protected]: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: illegal option -- D
warning: [email protected]: usage:  ar -d [-TLsv] archive file ...
warning: [email protected]: 	ar -m [-TLsv] archive file ...
warning: [email protected]: 	ar -m [-abiTLsv] position archive file ...
warning: [email protected]: 	ar -p [-TLsv] archive [file ...]
warning: [email protected]: 	ar -q [-cTLsv] archive file ...
warning: [email protected]: 	ar -r [-cuTLsv] archive file ...
warning: [email protected]: 	ar -r [-abciuTLsv] position archive file ...
warning: [email protected]: 	ar -t [-TLsv] archive [file ...]
warning: [email protected]: 	ar -x [-ouTLsv] archive [file ...]
   Compiling hurl v8.0.0-SNAPSHOT (/Users/jc/Documents/Dev/hurl/packages/hurl)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.73s

I've this impression that this issue is related to this PR, but maybe I'm mistaken...

jcamiel added a commit to Orange-OpenSource/hurl that referenced this pull request Apr 5, 2026
@weihanglo
Copy link
Copy Markdown
Member Author

Yes. That is from this PR. We might need to suppress the first probe invocation, if failed.

@weihanglo
Copy link
Copy Markdown
Member Author

The warning doesn't really matter on macOS for the default archiver though. No need to revert unless you feel annoyed by those should-be-silented warnings

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

Successfully merging this pull request may close these issues.

Non-deterministic archives on Linux due to timestamps

3 participants