-
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
Fix: Build only the specified artifact library when multiple types are available #13842
Fix: Build only the specified artifact library when multiple types are available #13842
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
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.
Overall looks good! I added some minor suggestions.
Thanks for your contribution!
a0e5a36
to
9a5cfbc
Compare
Thank you for the patch! @bors r+ |
☀️ Test successful - checks-actions |
test: clean up unnecessary uses of `match_exact` It was found during the review of <#13842 (comment)> We should be happy using `assert_match_exact` directly. The extra arguments to `match_exact` are not necessary for those test cases.
test: clean up unnecessary uses of `match_exact` It was found during the review of <#13842 (comment)> We should be happy using `assert_match_exact` directly. The extra arguments to `match_exact` are not necessary for those test cases.
Update cargo 10 commits in 05364cb2f61a2c2b091e061c1f42b207dfb5f81f..0ca60e940821c311c9b25a6423b59ccdbcea218f 2024-05-03 16:48:59 +0000 to 2024-05-08 01:54:25 +0000 - chore: Add cargo-lints to unstable docs (rust-lang/cargo#13881) - test: clean up unnecessary uses of `match_exact` (rust-lang/cargo#13879) - docs(ref): Correct heading level of `[lints]` documentation (rust-lang/cargo#13878) - Fix: Build only the specified artifact library when multiple types are available (rust-lang/cargo#13842) - docs: add missing CARGO_MAKEFLAGS env for plugins (rust-lang/cargo#13872) - Add more documentation to `cargo::rustc-check-cfg` (rust-lang/cargo#13869) - fix(toml): Remove unstable rejrected frontmatter syntax for cargo script (rust-lang/cargo#13861) - Update UI example code in contributor guide (rust-lang/cargo#13864) - style(test): Remove check-cfg warning (rust-lang/cargo#13865) - Fix global_cache_tracker::max_download_size test flakiness (rust-lang/cargo#13860) r? ghost
What does this PR try to resolve?
Fixes #12109.
TL;DR:
A crate
bar
exposes it's library as both astaticlib
and acdylib
. A second cratefoo
specifies an artifact dependency of typestaticlib
onbar
, meaning cargo should buildbar
as astaticlib
and expose certain environment variables (e.g.CARGO_STATICLIB_FILE_BAR
). However, due to a bug, cargo ends up building (and exposing the associated environment variables) for both thestaticlib
andcdylib
.The same happens if
foo
specifies an artifact dependency of typecdylib
; both artifact types are built.How should we test and review this PR?
The first commit introduces a test which reproduces the issue, the second commit introduces the fix. This setup was recommended by @ehuss.
Additional information
Artifact dependencies: https://rust-lang.github.io/rfcs/3028-cargo-binary-dependencies.html
TL;DR
If a crate
foo
requests an artifact dependency of kind <artifact_kind> from a cratebar
then the following happens:bar
is built with crate-type <artifact_kind> and a directory is created attarget/<profile>/deps/artifact/bar-<build_hash_or_something>/<artifact_kind>
. The binary artifact is placed in this directory.CARGO_<artifact_kind>_FILE_BAR
, which points to the binary artifact that was specified. This environment variable is available at compile time for normal dependencies and at runtime for build-dependencies.If multiple artifact-kinds are requested cargo will create a unit for each, and so they will all be built separately.