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

artifact deps should works when target field specified coexists with optional = true #11434

Merged
merged 5 commits into from
Dec 14, 2022

Commits on Dec 4, 2022

  1. Configuration menu
    Copy the full SHA
    437bed0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7dcb6da View commit details
    Browse the repository at this point in the history
  3. fix(bindeps): target field specified and optional = true coexist

    > 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
    weihanglo committed Dec 4, 2022
    Configuration menu
    Copy the full SHA
    bf56587 View commit details
    Browse the repository at this point in the history
  4. fix(bindeps): assumed host target and optional = true coexist

    `{ …, 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
    weihanglo committed Dec 4, 2022
    Configuration menu
    Copy the full SHA
    5b8985a View commit details
    Browse the repository at this point in the history

Commits on Dec 13, 2022

  1. Configuration menu
    Copy the full SHA
    eca3e23 View commit details
    Browse the repository at this point in the history