- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.7k
 
          artifact deps should works when target field specified coexists with optional = true
          #11434
        
          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
          
     Merged
      
      
    Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | 
           r? @ehuss (rustbot has picked a reviewer for you, use r? to override)  | 
    
> Adapted from rust-lang#11183 Previously, `is_dep_activated` depends on `activated_dependencies`, which is a map of `PackageFeaturesKey` to its own activated `DepFeature`s. `PackageFeaturesKey` in feature resolver is always comprised of * A `PackageId` of a given dependency, and * A enum value that helps decoupling activated features for that dependency. Currently depending on the type of given dependency. Looking into issue 10526, it has an `activated_dependencies` of ``` { (mycrate, NormalOrDev) -> [dep:mybindep] } ``` However, this [line][1] accidentally use a parent's `pkgid` and a dependency's `FeaturesFor` to compose a key: ``` (mycrate, ArtifactDep("x86_64-unknown-linux-gnu")) ``` That is never a valid key to query features for artifacts dependency. A valid key should be comprised of components both from the parent: ``` (mycrate, NormalOrDev) ``` Or both from the dependency itself: ``` (mybindep, ArtifactDep("x86_64-unknown-linux-gnu")) ``` This `unit_for` is from parent and should already contain its own artifact dep information inside `artifact_target_for_features`, so we don't need to map any dependency artifact from `dep.artifact()`. [1]: https://github.com/rust-lang/cargo/blob/a2ea66bea6fe8156444144e98911d073d56c2c0c/src/cargo/core/compiler/unit_dependencies.rs#L1106-L1107
`{ …, artifact = "bin", target = "target" }` should also be considered
to being built for `FeaturesFor::ArtifactDep` instead of `NormalOrDev`.
[This line][1] requests for `ArtifactDep` but [here][2] Cargo ignore
assumed host target of artifact dep.
Change it to explicit set host target triple when
- `{ …, target = "target" }`, and
- `--target` is not presented, meaning it would be build on host platform.
[1]: https://github.com/rust-lang/cargo/blob/1382b44e431f58199afdffc2b757962b0e163602/src/cargo/core/compiler/unit_dependencies.rs#L887
[2]: https://github.com/rust-lang/cargo/blob/1382b44e431f58199afdffc2b757962b0e163602/src/cargo/core/resolver/features.rs#L857
    ce9d5ff    to
    5b8985a      
    Compare
  
    
              
                    ehuss
  
              
              reviewed
              
                  
                    Dec 13, 2022 
                  
              
              
            
            
| 
           Was a regression test ever added that would catch the regression in #11330?  | 
    
| 
           I believe the regression test was done in #11342  | 
    
| 
           Thanks! @bors r+  | 
    
| 
           ☀️ Test successful - checks-actions  | 
    
    
  weihanglo 
      added a commit
        to weihanglo/rust
      that referenced
      this pull request
    
      Dec 14, 2022 
    
    
      
  
    
      
    
  
8 commits in 70898e522116f6c23971e2a554b2dc85fd4c84cd..cc0a320879c17207bbfb96b5d778e28a2c62030d 2022-12-05 19:43:44 +0000 to 2022-12-14 14:46:57 +0000 - artifact deps should works when target field specified coexists with `optional = true` (rust-lang/cargo#11434) - Add `home` crate to cargo crates (rust-lang/cargo#11359) - Use proper git URL for GitHub repos (rust-lang/cargo#11475) - Fixes flock(fd, LOCK_UN) emulation on Solaris. (rust-lang/cargo#11474) - Allow Check targets needed for optional doc-scraping to fail without killing the build (rust-lang/cargo#11450) - fix: gleaning rustdocflags from `target.cfg(…)` is not supported (rust-lang/cargo#11323) - Fix typo (rust-lang/cargo#11470) - resolver.md: Fix naming in example (rust-lang/cargo#11469)
    
  bors 
      added a commit
        to rust-lang-ci/rust
      that referenced
      this pull request
    
      Dec 14, 2022 
    
    
      
  
    
      
    
  
Update cargo 8 commits in 70898e522116f6c23971e2a554b2dc85fd4c84cd..cc0a320879c17207bbfb96b5d778e28a2c62030d 2022-12-05 19:43:44 +0000 to 2022-12-14 14:46:57 +0000 - artifact deps should works when target field specified coexists with `optional = true` (rust-lang/cargo#11434) - Add `home` crate to cargo crates (rust-lang/cargo#11359) - Use proper git URL for GitHub repos (rust-lang/cargo#11475) - Fixes flock(fd, LOCK_UN) emulation on Solaris. (rust-lang/cargo#11474) - Allow Check targets needed for optional doc-scraping to fail without killing the build (rust-lang/cargo#11450) - fix: gleaning rustdocflags from `target.cfg(…)` is not supported (rust-lang/cargo#11323) - Fix typo (rust-lang/cargo#11470) - resolver.md: Fix naming in example (rust-lang/cargo#11469) r? `@ghost`
  
    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. 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
What does this PR try to resolve?
Another attempt to fix #10526 after #11183 failed.
You can find an explanation of the bug in #11183 or in the commit message.
How should we test and review this PR?
This first two commits log the current "incorrect" behaviour.
Other commits contain fixes respectively.
You may find more details in the commit messages.