-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Check if rust-src contains a vendor dir, and patch it in #8834
Conversation
r? @Eh2406 (rust_highfive has picked a reviewer for you, use r? to override) |
05b603a
to
5b1522d
Compare
Note that these two PRs do not need to be synchronized at all.
This adds ~10MB to the uncompressed rust-src component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me! I think it may be difficult to add an automated test for this at this time until it's upstream and published, but can you confirm that this works locally?
Yeah I verified this locally by:
I'm pretty confident it works because this method caught several mistakes I made while writing this! (like needing to copy the lockfile for |
Ok great! I'm realizing now though that we can probably test this locally since we have basically a mock of the rust-std component and I think it should be possible to add a dependency only present in the Also could you add some tests where |
Can you point me to a test I can use as a template for this kind of thing? |
I believe all those tests are housed here |
@alexcrichton it occurs to me that I can tweak the vendored version to not have any hardcoded rustc-std-workspace crates and instead derive everything from the vendor. In theory this would let rust add new rustc-std-workspace crates without changing cargo. Is that desirable? |
That'd be awesome yeah! Less hardcoded stuff in Cargo always sounds good to me |
( |
5b1522d
to
33eb4e2
Compare
New version that derives the existence of the std packages from the vendor pushed up. |
6a96a14
to
ec620e2
Compare
Here's my first crack at testing the vendor logic. |
d8ef553
to
127dd70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One test I think that'd be good to add is to publish a version of the crates.io crate which would break the compilation if used (e.g. invalid syntax), and that way we can be sure Cargo doesn't touch it.
[package] | ||
name = "registry-dep-only-used-by-test" | ||
version = "1.0.0" | ||
authors = ["Alex Crichton <alex@alexcrichton.com>"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well why thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy pasted these xp
This is a good idea, I've added it to the default environment every test uses to ensure all tests incidentally check this. |
I'm a bit confused by the CI failure that happened on |
Are you sure you're testing with a nightly toolchain? Those tests only run on nightly and they're failing locally for me on mac with |
I'll go dig out my macbook and see it it repro's there. |
Ah, cut one too many corners and forgot that git won't add empty directories by default. Worked locally because the dirs still existed. |
Looks great to me, thanks! @ehuss did you want to take a look or shall I r+? |
5afe4e4
to
5eb3535
Compare
Squashed |
…lacrum Vendor libtest's dependencies in the rust-src component This is the Rust side of rust-lang/wg-cargo-std-aware#23 Note that this won't produce a useful result for `cargo -Zbuild-std` if there are multiple versions of a crate vendored, but will otherwise produce a valid vendor dir. See rust-lang/cargo#8834 for the other half of this change.
5eb3535
to
eadb4fc
Compare
Ok, removed the fallback mode |
(this change of course means build_std won't compile until the other rust changes make it into nightly) |
…crum Vendor libtest's dependencies in the rust-src component This is the Rust side of rust-lang/wg-cargo-std-aware#23 Note that this won't produce a useful result for `cargo -Zbuild-std` if there are multiple versions of a crate vendored, but will otherwise produce a valid vendor dir. See rust-lang/cargo#8834 for the other half of this change.
I pushed a small change to add some error context. @bors r+ |
📌 Commit 85b5b18 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 5 commits in d5556aeb8405b1fe696adb6e297ad7a1f2989b62..8662ab427a8d6ad8047811cc4d78dbd20dd07699 2020-11-04 22:20:36 +0000 to 2020-11-12 03:47:53 +0000 - Check if rust-src contains a vendor dir, and patch it in (rust-lang/cargo#8834) - Improve performance of almost fresh builds (rust-lang/cargo#8837) - Use u32/64::to/from_le_bytes instead of bit fiddling (rust-lang/cargo#8847) - Avoid constructing an anyhow::Error when not necessary (rust-lang/cargo#8844) - Skip extracting .cargo-ok files from packages (rust-lang/cargo#8835)
Update cargo 5 commits in d5556aeb8405b1fe696adb6e297ad7a1f2989b62..8662ab427a8d6ad8047811cc4d78dbd20dd07699 2020-11-04 22:20:36 +0000 to 2020-11-12 03:47:53 +0000 - Check if rust-src contains a vendor dir, and patch it in (rust-lang/cargo#8834) - Improve performance of almost fresh builds (rust-lang/cargo#8837) - Use u32/64::to/from_le_bytes instead of bit fiddling (rust-lang/cargo#8847) - Avoid constructing an anyhow::Error when not necessary (rust-lang/cargo#8844) - Skip extracting .cargo-ok files from packages (rust-lang/cargo#8835)
* Bumps the tsan toolchain to rust-nightly-2020-11-14 that has my patches to make -Zbuild-std work in vendored environments: * rust-lang/cargo#8834 * rust-lang/rust#78790 * Passes -Zbuild-std to cargo when MOZ_TSAN is defined (mk_add_options --enable-thread-sanitizer) * Removes generic Rust supressions and adds much more specific ones * One presumed upstream false positive from tsan not understanding the code * One actual upstream bug tsan found (yay!) * One new real issue uncovered * One issue that probably already existed intermittently but I happened to hit Differential Revision: https://phabricator.services.mozilla.com/D97165
* Bumps the tsan toolchain to rust-nightly-2020-11-14 that has my patches to make -Zbuild-std work in vendored environments: * rust-lang/cargo#8834 * rust-lang/rust#78790 * Passes -Zbuild-std to cargo when MOZ_TSAN is defined (mk_add_options --enable-thread-sanitizer) * Removes generic Rust supressions and adds much more specific ones * One presumed upstream false positive from tsan not understanding the code * One actual upstream bug tsan found (yay!) * One new real issue uncovered * One issue that probably already existed intermittently but I happened to hit Differential Revision: https://phabricator.services.mozilla.com/D97165
For the record, as we've been using this patch for sanitizer builds for Firefox, from the original comment: "Note that this design naively assumes there is only one version of each package.", well, this now doesn't work anymore because libstd directly and indirectly depends on two versions of cfg-if. |
This is the cargo side of rust-lang/wg-cargo-std-aware#23
Note that this design naively assumes there is only one version of each package. It does not robustly verify this, and will presumably just cryptically fail to resolve dependencies.
See rust-lang/rust#78790 for the other half of this change.