Skip to content
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

Error message for transitive artifact dependencies with targets the package doesn't directly interact with #11643

Merged
merged 7 commits into from
Feb 25, 2023

Conversation

jofas
Copy link
Contributor

@jofas jofas commented Jan 28, 2023

Address #11260. Produces an error message like described by @weihanglo here:

error: could not find specification for target "x86_64-windows-msvc"
  Dependency `bar v0.1.0` requires to build for target "x86_64-windows-msvc".

Note that this is not a complete fix for #11260.

@rustbot
Copy link
Collaborator

rustbot commented Jan 28, 2023

r? @ehuss

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 28, 2023
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really neat and complete! Love to see people putting more doc comments during development! Thank you!

Just some picky styling issues left. Let me know if you disagree or have a better idea :)

tests/testsuite/artifact_dep.rs Show resolved Hide resolved
src/cargo/core/compiler/compilation.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/compilation.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/compilation.rs Show resolved Hide resolved
src/cargo/core/compiler/compilation.rs Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Jan 28, 2023

I suggest that this doesn't entirely fix #11260. I would expect artifact dependencies to work, not generate an error message.

@weihanglo
Copy link
Member

Oops that's my fault. I though it was just target spec not found but it turns out not. Cargo should learn all targets required by artifact dependencies, probably after unit graph is created.

Thanks Eric for calling out and sorry for the wrong pointer, @jofas 😞.

@jofas
Copy link
Contributor Author

jofas commented Jan 28, 2023

I would expect artifact dependencies to work

Me too 😅

sorry for the wrong pointer

No worries. In the issue it sounded like getting all the necessary targets for building transitive artifact dependencies isn't trivial and I assumed a change like that required some more procedural overhead than a simple PR (does cargo have RFCs as well?). With some more hints on where I need to look in order to add the required targets for transitive artifact dependencies to RustcTargetData, I'd love to extent this PR!

@jofas
Copy link
Contributor Author

jofas commented Jan 30, 2023

fn artifact_targets(package: &Package) -> impl Iterator<Item = CompileKind> + '_ {
package
.manifest()
.dependencies()
.iter()
.filter_map(|d| d.artifact()?.target()?.to_compile_kind())
}

AFAICT, if we make this function recursive and call it for each dependency, we should get all the necessary targets for transitive dependencies, no? I haven't found a way yet to get the Package or Manifest objects from Dependency. Maybe from the BuildContext.packages? If we could pass BuildContext down to the RustcTargetData::new, that is. I'll keep digging and see if I can find something more concrete. Any thoughts on my idea?

@weihanglo
Copy link
Member

if we make this function recursive and call it for each dependency, we should get all the necessary targets for transitive dependencies, no?

I am afraid it won't work, or requests for too many targets then it really needs. We should also consider optional dependencies and the feature resolution. I believe Cargo doesn't need every disabled target platform toolchain to exist on the host machine.

jofas and others added 4 commits February 6, 2023 14:24
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
…+ incorporated changes into corresponding test
@jofas
Copy link
Contributor Author

jofas commented Feb 6, 2023

I am afraid it won't work, or requests for too many targets then it really needs. We should also consider optional dependencies and the feature resolution. I believe Cargo doesn't need every disabled target platform toolchain to exist on the host machine.

Will that really be a problem? Sure, creating TargetInfo (which is where rustc must be executed) seems to be computationally expensive, so it would be unfortunate if we get it for more targets than needed during compilation. But it is "just" performance, whereas now we struggle with correctness. I'm asking, because I can't see how we'd be able to use the UnitGraph (which I'm assuming is the graph containing all the dependencies and how to compile them) for choosing the right targets for RustcTargetData, as for creating the UnitGraph, we need RustcTargetData.

@weihanglo
Copy link
Member

r? @weihanglo

@rustbot rustbot assigned weihanglo and unassigned ehuss Feb 24, 2023
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jofas! As ehuss said, this is not a complete fix for #11260, but we can still ship this nicer error message. For fixing the root issue, I'll take a deep look next week and see if I can find anything useful.

Let's merge this. Thank you!

@weihanglo
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 25, 2023

📌 Commit 4bdface has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2023
@bors
Copy link
Contributor

bors commented Feb 25, 2023

⌛ Testing commit 4bdface with merge 816772b...

bors added a commit that referenced this pull request Feb 25, 2023
Error message for transitive artifact dependencies with targets the package doesn't directly interact with

Address #11260. Produces an error message like described by `@weihanglo` [here](#11260 (comment)):

```
error: could not find specification for target "x86_64-windows-msvc"
  Dependency `bar v0.1.0` requires to build for target "x86_64-windows-msvc".
```

Note that this is not a complete fix for #11260.
@bors
Copy link
Contributor

bors commented Feb 25, 2023

💔 Test failed - checks-actions

@bors bors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 25, 2023
@bors bors added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 25, 2023
@ehuss
Copy link
Contributor

ehuss commented Feb 25, 2023

I posted #11766 to fix the issue with CI failing.

@weihanglo
Copy link
Member

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2023
@bors
Copy link
Contributor

bors commented Feb 25, 2023

⌛ Testing commit 4bdface with merge 524231f...

@bors
Copy link
Contributor

bors commented Feb 25, 2023

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 524231f to master...

@bors bors merged commit 524231f into rust-lang:master Feb 25, 2023
@jofas
Copy link
Contributor Author

jofas commented Feb 25, 2023

For fixing the root issue, I'll take a deep look next week and see if I can find anything useful.

Great, please let me know if you find anything I could help with.

weihanglo added a commit to weihanglo/rust that referenced this pull request Feb 28, 2023
10 commits in 9d5b32f503fc099c4064298465add14d4bce11e6..9880b408a3af50c08fab3dbf4aa2a972df71e951
2023-02-22 23:04:16 +0000 to 2023-02-28 19:39:39 +0000

- bump jobserver to respect `--jobserver-auth=fifo:PATH` (rust-lang/cargo#11767)
- Addition of support for -F as an alias for --features (rust-lang/cargo#11774)
- Added documentation for the configuration discovery of `cargo install` to the man pages (rust-lang/cargo#11763)
- Fix Cargo removing the sparse+ prefix from sparse URLs in .crates.toml (rust-lang/cargo#11756)
- Fix warning with tempfile (rust-lang/cargo#11771)
- Error message for transitive artifact dependencies with targets the package doesn't directly interact with (rust-lang/cargo#11643)
- Fix tests with nondeterministic ordering (rust-lang/cargo#11766)
- Make some blocking tests non-blocking (rust-lang/cargo#11650)
- Suggest cargo add when installing library crate (rust-lang/cargo#11410)
- chore: bump is-terminal to 0.4.4 (rust-lang/cargo#11759)
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 1, 2023
Update cargo

10 commits in 9d5b32f503fc099c4064298465add14d4bce11e6..9880b408a3af50c08fab3dbf4aa2a972df71e951 2023-02-22 23:04:16 +0000 to 2023-02-28 19:39:39 +0000

- bump jobserver to respect `--jobserver-auth=fifo:PATH` (rust-lang/cargo#11767)
- Addition of support for -F as an alias for --features (rust-lang/cargo#11774)
- Added documentation for the configuration discovery of `cargo install` to the man pages (rust-lang/cargo#11763)
- Fix Cargo removing the sparse+ prefix from sparse URLs in .crates.toml (rust-lang/cargo#11756)
- Fix warning with tempfile (rust-lang/cargo#11771)
- Error message for transitive artifact dependencies with targets the package doesn't directly interact with (rust-lang/cargo#11643)
- Fix tests with nondeterministic ordering (rust-lang/cargo#11766)
- Make some blocking tests non-blocking (rust-lang/cargo#11650)
- Suggest cargo add when installing library crate (rust-lang/cargo#11410)
- chore: bump is-terminal to 0.4.4 (rust-lang/cargo#11759)

r? `@ghost`
@ehuss ehuss added this to the 1.69.0 milestone Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants