Skip to content

DEP_* env variable not set in nightly test run #9063

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
kamulos opened this issue Jan 11, 2021 · 3 comments · Fixed by #9065
Closed

DEP_* env variable not set in nightly test run #9063

kamulos opened this issue Jan 11, 2021 · 3 comments · Fixed by #9065
Labels
regression-from-stable-to-beta Regression in beta that previously worked in stable.

Comments

@kamulos
Copy link

kamulos commented Jan 11, 2021

This happens with the nightly version, but not with the stable.

> cargo +nightly version
cargo 1.51.0-nightly (329895f5b 2021-01-06)

Reproduce

Cargo.toml

[package]
name = "asdf"
version = "0.1.0"
authors = ["xyxy"]
edition = "2018"

[dependencies]
libsodium-sys = "0.2"

[build-dependencies]
cc = "1.0"

test.c

void test() {}

build.rs

fn main() {
    cc::Build::new()
        .file("test.c")
        .include(std::env::var_os("DEP_SODIUM_INCLUDE").expect("DEP_SODIUM_INCLUDE is not set"))
        .compile("test.a");
}

Now just run cargo +nighly test. With stable this works perfectly, with nightly the DEP_SODIUM_INCLUDE env variable is not set.

@ehuss
Copy link
Contributor

ehuss commented Jan 11, 2021

@alexcrichton I think this was caused by #8969. When running cargo test, the test unit has a dependency edge to the local build script. Since tests got disconnected, that causes the build script to start building too early (before the libsodium-sys build script runs).

@ehuss ehuss added the regression-from-stable-to-beta Regression in beta that previously worked in stable. label Jan 11, 2021
@alexcrichton
Copy link
Member

Thanks for the report! I think this should be fixed by #9065. Sorry about the breakage!

bors added a commit that referenced this issue Jan 12, 2021
Fix `links` vars showing up for testing packages

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 #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
@rylev
Copy link
Member

rylev commented Jan 12, 2021

FYI: This caused only one breakage in the latest crater run.

@bors bors closed this as completed in 21a5efb Jan 12, 2021
alexcrichton added a commit to alexcrichton/cargo that referenced this issue Jan 12, 2021
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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
regression-from-stable-to-beta Regression in beta that previously worked in stable.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants