From b3d0eeb38203b404abf2d63150049cc879d9ad3d Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 17 Nov 2023 09:09:09 -0600 Subject: [PATCH 1/3] refactor(compile): Always add base args first This will make it less likely that anything that depends on them will get moved before them and makes it easier to consistently add logic that depends on them. --- src/cargo/core/compiler/mod.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 47dce5357f1..c4eded0ef85 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -662,6 +662,15 @@ fn prepare_rustc(cx: &Context<'_, '_>, unit: &Unit) -> CargoResult, unit: &Unit) -> CargoResult Date: Fri, 17 Nov 2023 09:25:34 -0600 Subject: [PATCH 2/3] test(compiler): Make inner test names more specific This will make it easier to verify other env variables later --- tests/testsuite/build.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 8ec05061e82..4b58b90b051 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1584,7 +1584,7 @@ fn crate_env_vars() { } #[test] - fn env() { + fn unit_env_cargo_target_tmpdir() { // Check that CARGO_TARGET_TMPDIR isn't set for unit tests assert!(option_env!("CARGO_TARGET_TMPDIR").is_none()); env::var("CARGO_TARGET_TMPDIR").unwrap_err(); @@ -1612,7 +1612,7 @@ fn crate_env_vars() { "tests/env.rs", r#" #[test] - fn env() { + fn integration_env_cargo_target_tmpdir() { foo::check_tmpdir(option_env!("CARGO_TARGET_TMPDIR")); } "#, @@ -1627,7 +1627,7 @@ fn crate_env_vars() { use test::Bencher; #[bench] - fn env(_: &mut Bencher) { + fn bench_env_cargo_target_tmpdir(_: &mut Bencher) { foo::check_tmpdir(option_env!("CARGO_TARGET_TMPDIR")); } "#, From e81d84cc17d7df6a249e60cbc620f25edbe782db Mon Sep 17 00:00:00 2001 From: Yerkebulan Tulibergenov Date: Mon, 29 May 2023 19:18:49 -0700 Subject: [PATCH 3/3] feat: Add `CARGO_RUSTC_CURRENT_DIR` This is an alternative to #12158's `CARGO_WORKSPACE_DIR` that was implementing the solution to #3946 that previously discussed in the cargo team meeting. `CARGO_WORKSPACE_DIR` is a bit awkward to document / describe because its the effective workspace directory of the thing being built. If the thing being built doesn't have a workspace, it falls back to `CARGO_MANIFEST_DIR`. It would also be hard to take into account what the `CARGO_WORKSPACE_DIR` would be for path dependencies into foreign workspaces *and* it wouldn't solve the problem the user is having. What the user really wants is the CWD of rustc when it is invoked. This is much simpler to describe and is accurate when using a path dependency to a foreign package. Because the CWD is a much simpler mechanism to talk about, I figured we could diverge from our prior consensus and make it always present, rather than limiting it to tests. Remaining work for #3946: get this stabilized --- src/cargo/core/compiler/mod.rs | 10 + .../src/reference/environment-variables.md | 1 + tests/testsuite/build.rs | 206 +++++++++++++++++- 3 files changed, 213 insertions(+), 4 deletions(-) diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index c4eded0ef85..0801783dc7b 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -680,6 +680,16 @@ fn prepare_rustc(cx: &Context<'_, '_>, unit: &Unit) -> CargoResult