-
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
Partially revert dep changes in #5651 #5711
Conversation
r? @matklad (rust_highfive has picked a reviewer for you, use r? to override) |
r? @ehuss The bug here was that a |
There was an obscure issue where this would poison the deps map with incorrect entries where I need to head out for a bit, but I should be back in a couple hours. When I get back I'll try to write a test to explain what I mean. |
Ah ok no worries! If you're unsuccessful in a test I'll try to dig deeper as well |
If you look at the test I've always thought this method of creating a "tmp" unit to find dependencies to be a little strange. If it just so happens to select a "test" target, then you end up with the same problem of infinite recursion. It's just lucky that the "lib" target is usually first. I've been trying to think of some different solutions. Here's a few different ideas:
--- a/src/cargo/core/compiler/context/unit_dependencies.rs
+++ b/src/cargo/core/compiler/context/unit_dependencies.rs
@@ -205,11 +205,11 @@ fn compute_deps_custom_build<'a, 'cfg>(
.expect("can't find package deps")
.1;
Ok(deps.iter()
- .filter_map(|unit| {
- if !unit.target.linkable() || unit.pkg.manifest().links().is_none() {
+ .filter_map(|dep_unit| {
+ if dep_unit.pkg == unit.pkg || !dep_unit.target.linkable() || dep_unit.pkg.manifest().links().is_none() {
return None;
}
- dep_build_script(unit, bcx)
+ dep_build_script(dep_unit, bcx)
})
.chain(Some((
new_unit(
I'm going to keep thinking about this. |
I'm thinking it would be best to go with this change now (and on beta!), and then look at a different approach for fixing the |
I thought of yet another possible solution: ehuss@df8118d |
Hey sorry was a bit swamped today and wasn't able to get around to this. Thanks for diagnoising a failing test for this, I think that probably means we shouldn't merge this as-is! One thing I'm a little uncomfortable about with the current construction is that it relies on the current state of the The idea of a postprocessing pass to draw more dependency edges I think may work though. One reason that's not done is that in drawing an edge it may futher generate more work as well. Instead though for build scripts we're basically just drawing edges from an existing build script execution to other build script executions. That, I think, should definitely be possible to do after-the-fact. I would also prefer to avoid using I'll look into making this a postprocessing step tomorrow, although if you've got some spare time and want to give a crack at it feel free! |
899e7ad
to
b362fcd
Compare
✌️ @ehuss can now approve this pull request |
This is excellent, much cleaner! Would you mind adding a test to ensure that diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs
index 17541233..039a8c52 100644
--- a/tests/testsuite/build_script.rs
+++ b/tests/testsuite/build_script.rs
@@ -3080,9 +3080,12 @@ fn panic_abort_with_build_scripts() {
execs().with_status(0),
);
+ p.root().join("target").rm_rf();
+
assert_that(
- p.cargo("test --release"),
+ p.cargo("test --release -v"),
execs().with_status(0)
+ .with_stderr_does_not_contain("[..]panic[..]")
);
} |
b362fcd
to
b2e8ed0
Compare
Certainly, done! |
This comment has been minimized.
This comment has been minimized.
Some logic which was tweaked around the dependencies of build script targets was tweaked slightly in a way that causes cargo to stack overflow by accientally adding a dependency loop. This commit implements one of the strategies discussed in rust-lang#5711 to fix this situation. The problem here is that when calculating the deps of a build script we need the build scripts of *other* packages, but the exact profile is somewhat difficult to guess at the moment we're generating our build script unit. To solve this the dependencies towards other build scripts' executions is added in a different pass after all other units have been assembled. At this point we should know for sure that all build script executions are in the dependency graph, and we just need to add a few more edges. Closes rust-lang#5708
b2e8ed0
to
f9d4927
Compare
(rebased) |
@bors: r+ Thanks for doing this! Do you want to backport the same change on beta, or use the original revert change? |
📌 Commit f9d4927 has been approved by |
Partially revert dep changes in #5651 Some logic which was tweaked around the dependencies of build script targets was tweaked slightly in a way that causes cargo to stack overflow by accientally adding a dependency loop. This commit implements one of the strategies discussed in #5711 to fix this situation. The problem here is that when calculating the deps of a build script we need the build scripts of *other* packages, but the exact profile is somewhat difficult to guess at the moment we're generating our build script unit. To solve this the dependencies towards other build scripts' executions is added in a different pass after all other units have been assembled. At this point we should know for sure that all build script executions are in the dependency graph, and we just need to add a few more edges. Closes #5708
I think we probably want to backport this patch to beta as otherwise we'd just have the same bug you fixed already on beta, and this method hopefully solves both! |
☀️ Test successful - status-appveyor, status-travis |
Some logic which was tweaked around the dependencies of build script targets was tweaked slightly in a way that causes cargo to stack overflow by accientally adding a dependency loop. This commit implements one of the strategies discussed in rust-lang#5711 to fix this situation. The problem here is that when calculating the deps of a build script we need the build scripts of *other* packages, but the exact profile is somewhat difficult to guess at the moment we're generating our build script unit. To solve this the dependencies towards other build scripts' executions is added in a different pass after all other units have been assembled. At this point we should know for sure that all build script executions are in the dependency graph, and we just need to add a few more edges. Closes rust-lang#5708
Cleanup tests When working on #11738 I noticed a few tests that needed to be cleaned up. It [was suggested](#11738 (comment)) to split the test changes into their own PR. - `bad_config::bad1` - This was trying to match `config` which would get matched in the wrong place due to the test name having `config` in it - Fixed by making the match `/config` - `build_script::panic_abort_with_build_scripts` - This test was failing as it was making sure `panic` was not in the output. After this change, it could match the test name and fail. - To fix this I updated it to look at `panic=abort` which appears to be what it was originally looking for (#5711). `@ehuss` please let me know if I misread what the test was testing. - `cargo_command::cargo_subcommand_args` - This test had `#[test]` above `#[cargo_test]` which caused it to throw an error removing it fixed the issue During this time I also ran into issues with `cargo_remove` tests being named `fn case()` which is different from how tests are normally named. I talked with `@epage` and it was decided that `fn case()` should probably be used for all `snapbox` tests since the unique test name is already the folder name. I went ahead and renamed all tests within `cargo_add/` and `init/` to match this style. This PR should be reviewed commit by commit.
Some logic which was tweaked around the dependencies of build script targets was
tweaked slightly in a way that causes cargo to stack overflow by accientally
adding a dependency loop. This commit implements one of the strategies discussed
in #5711 to fix this situation.
The problem here is that when calculating the deps of a build script we need the
build scripts of other packages, but the exact profile is somewhat difficult
to guess at the moment we're generating our build script unit. To solve this the
dependencies towards other build scripts' executions is added in a different
pass after all other units have been assembled. At this point we should know for
sure that all build script executions are in the dependency graph, and we just
need to add a few more edges.
Closes #5708