-
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 env/cfg set for cargo test
and cargo run
.
#9122
Conversation
r? @Eh2406 (rust-highfive has picked a reviewer for you, use r? to override) |
@@ -51,7 +51,7 @@ pub struct BuildOutput { | |||
/// `Unit` because this structure needs to be shareable between threads. | |||
#[derive(Default)] | |||
pub struct BuildScriptOutputs { | |||
outputs: HashMap<(PackageId, Metadata), BuildOutput>, | |||
outputs: HashMap<Metadata, BuildOutput>, |
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.
I changed this to just be keyed off the Metadata to simplify things. I don't remember why I originally included PackageId
, as the PackageId hash is already included in the Metadata
. If we are uncomfortable with the possibility of a hash collision, I can switch it back, or we can consider using a stronger hash (like siphash 128?).
65bae6d
to
3b6b612
Compare
I was also wondering if we should update the documentation for how environment variables are set for |
3b6b612
to
f6f274d
Compare
f6f274d
to
d8673d9
Compare
Looks good to me, thanks! I think it makes sense to go ahead and document this but discourage usage. We've already got users depending on it (probably accidentally?) so I don't think that we can change it anyway. If you'd prefer to do doc updates in a future PR that's ok too, r=me on this regardless. |
Ok, I added a small note. Thanks Alex! 😄 @bors r=alexcrichton |
📌 Commit 1607a68 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 5 commits in e099df243bb2495b9b197f79c19f124032b1e778..34170fcd6e0947808a1ac63ac85ffc0da7dace2f 2021-02-01 16:24:34 +0000 to 2021-02-04 15:52:52 +0000 - Fix permission issue with `cargo vendor`. (rust-lang/cargo#9131) - Add split-debuginfo profile option (rust-lang/cargo#9112) - Add RegistryBuilder for tests, and update crates-io error handling. (rust-lang/cargo#9126) - Add some documentation for index and registry stuff. (rust-lang/cargo#9125) - Fix env/cfg set for `cargo test` and `cargo run`. (rust-lang/cargo#9122)
There are some situations where a build script may need to run multiple times for the same package during the same
cargo
session. There was a bug in that some of the values in theCompilation
struct didn't handle this case. The solution here is to be more careful about how this extra data is associated withUnit
s, instead of assuming a package's build script only runs once.The things that were not being handled properly:
Compilation::extra_env
, which is the output ofcargo:rustc-env
in build scripts. The solution here is to use theMetadata
hash which is used elsewhere for distinguishing build script outputs.Compilation::cfgs
, which is the output ofcargo:rustc-cfg
in build scripts and the features to be set, and this is only used for doctests. The solution here is to just add those--cfg
flags directly in theDoctest
struct.The situations that cause a build script to be run multiple times:
host
) and a cyclical dev dependency, but there are many other ways to trigger this.Fixes #9100