-
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 links
vars showing up for testing packages
#9065
Conversation
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
tests/testsuite/build_script.rs
Outdated
|
||
#[cargo_test] | ||
fn test_with_dep_metadata() { | ||
// rerun-if-changed of a directory should rerun if any file in the directory changes. |
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/paste error?
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.
Oops, indeed!
If a package is tested and the library for the package wasn't built (e.g. only tested or it wasn't present) then the `links` env vars from dependencies weren't showing up to the build script by accident. This was an accidental regression from rust-lang#8969. The intention of rust-lang#8969 was to exclude connections to build scripts connected via dev-dependencies, but it only applied a heuristic because the unit graph doesn't retain information about dev-dependencies. The fix here is to instead actually retain information about dev-dependencies which is only used for constructing the unit graph and connecting build script executions to one another. Closes rust-lang#9063
fa3c945
to
21a5efb
Compare
Ugh, I see what you were saying about this on Zulip. I've been trying various different approaches such as fundamentally revisiting #5711, but every solution I can think of is as complex as this or worse. This is a precarious path to go down, where it will be near impossible to understand this file in the future. That being said, we can't remove or redesign these features from Cargo, and I don't see many other options. At least things are pretty well commented. 😄 @bors r+ @alexcrichton Do you want to backport this to beta? |
📌 Commit 21a5efb has been approved by |
Indeed yeah the code at this point definitely doesn't speak for itself and we're really only left to rely on comments and tests at this point... I wish I knew a better way out of this quagmire! Sure yeah though, I'll do the backport |
☀️ Test successful - checks-actions |
[BETA] Fix `links` vars showing up for testing packages This is a beta backport of #9065
Update cargo 10 commits in 329895f5b52a358e5d9ecb26215708b5cb31d906..a73e5b7d567c3036b296fc6b33ed52c5edcd882e 2021-01-06 00:01:52 +0000 to 2021-01-12 23:45:39 +0000 - Sort available binaries when multiple (rust-lang/cargo#9066) - Fix misspelling of environment variable (rust-lang/cargo#9067) - Remove statement that opt-level 0 turns on debug (rust-lang/cargo#9070) - Fix `links` vars showing up for testing packages (rust-lang/cargo#9065) - Fix unit_for computation on proc-macros in shared workspace. (rust-lang/cargo#9059) - Document `could not find the github team` error on `cargo owner --add` (rust-lang/cargo#9000) - Unstable section of cargo/config.toml takes bools (rust-lang/cargo#9057) - [doc] add note about empty environment variables for missing manifest keys (rust-lang/cargo#9053) - another round of clippy lint fixes (rust-lang/cargo#9051) - Updated display message of cargo metadata --help (rust-lang/cargo#9050)
If a package is tested and the library for the package wasn't built
(e.g. only tested or it wasn't present) then the
links
env vars fromdependencies weren't showing up to the build script by accident. This
was an accidental regression from #8969.
The intention of #8969 was to exclude connections to build scripts
connected via dev-dependencies, but it only applied a heuristic because
the unit graph doesn't retain information about dev-dependencies. The
fix here is to instead actually retain information about
dev-dependencies which is only used for constructing the unit graph and
connecting build script executions to one another.
Closes #9063