Skip to content

Commit c14ab13

Browse files
committedNov 25, 2018
Auto merge of rust-lang#56194 - eddyb:top-unhack, r=alexcrichton
Try to make top-level Cargo.toml work without __CARGO_TEST_ROOT. The last failures I noticed before adding the `__CARGO_TEST_ROOT` hack were in `src/test/run-make/thumb-none-{cortex-m,qemu}`, and had to do with the fact that the top-level `Cargo.toml` uses nightly Cargo features. If that's the only problem, this PR should work, and we can figure out how to unbreak RLS.

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed
 

‎Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ members = [
2626
]
2727
exclude = [
2828
"src/tools/rls/test_data",
29+
"build",
30+
# HACK(eddyb) This hardcodes the fact that our CI uses `/checkout/obj`.
31+
"obj",
2932
]
3033

3134
# Curiously, LLVM 7.0 will segfault if compiled with opt-level=3

‎src/bootstrap/test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,6 @@ impl Step for Distcheck {
19341934
.arg("generate-lockfile")
19351935
.arg("--manifest-path")
19361936
.arg(&toml)
1937-
.env("__CARGO_TEST_ROOT", &dir)
19381937
.current_dir(&dir),
19391938
);
19401939
}

‎src/bootstrap/tool.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ macro_rules! tool {
264264
$name:ident, $path:expr, $tool_name:expr, $mode:expr
265265
$(,llvm_tools = $llvm:expr)*
266266
$(,is_external_tool = $external:expr)*
267-
$(,cargo_test_root = $cargo_test_root:expr)*
268267
;
269268
)+) => {
270269
#[derive(Copy, PartialEq, Eq, Clone)]
@@ -288,15 +287,6 @@ macro_rules! tool {
288287
$(Tool::$name => false $(|| $llvm)*,)+
289288
}
290289
}
291-
292-
/// Whether this tool requires may run Cargo for test crates,
293-
/// which currently needs setting the environment variable
294-
/// `__CARGO_TEST_ROOT` to separate it from the workspace.
295-
pub fn needs_cargo_test_root(&self) -> bool {
296-
match self {
297-
$(Tool::$name => false $(|| $cargo_test_root)*,)+
298-
}
299-
}
300290
}
301291

302292
impl<'a> Builder<'a> {
@@ -372,9 +362,8 @@ tool!(
372362
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::ToolBootstrap;
373363
Tidy, "src/tools/tidy", "tidy", Mode::ToolBootstrap;
374364
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::ToolBootstrap;
375-
CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap, cargo_test_root = true;
376-
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap,
377-
llvm_tools = true, cargo_test_root = true;
365+
CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap;
366+
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true;
378367
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
379368
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
380369
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap,
@@ -693,11 +682,6 @@ impl<'a> Builder<'a> {
693682
}
694683
}
695684

696-
// Set `__CARGO_TEST_ROOT` to the build directory if needed.
697-
if tool.needs_cargo_test_root() {
698-
cmd.env("__CARGO_TEST_ROOT", &self.config.out);
699-
}
700-
701685
add_lib_path(lib_paths, cmd);
702686
}
703687

‎src/test/run-make/thumb-none-cortex-m/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ all:
3232
mkdir -p $(WORK_DIR)
3333
-cd $(WORK_DIR) && rm -rf $(CRATE)
3434
cd $(WORK_DIR) && bash -x $(HERE)/../git_clone_sha1.sh $(CRATE) $(CRATE_URL) $(CRATE_SHA1)
35-
cd $(WORK_DIR) && cd $(CRATE) && $(CARGO) build --target $(TARGET) -v
35+
# HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
36+
# These come from the top-level Rust workspace, that this crate is not a
37+
# member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
38+
cd $(WORK_DIR) && cd $(CRATE) && env RUSTC_BOOTSTRAP=1 $(CARGO) build --target $(TARGET) -v
3639
else
3740

3841
all:

‎src/test/run-make/thumb-none-qemu/script.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ pushd $WORK_DIR
88
rm -rf $CRATE || echo OK
99
cp -a $HERE/example .
1010
pushd $CRATE
11-
env RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" \
11+
# HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
12+
# These come from the top-level Rust workspace, that this crate is not a
13+
# member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
14+
env RUSTC_BOOTSTRAP=1 RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" \
1215
$CARGO run --target $TARGET | grep "x = 42"
13-
env RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" \
16+
env RUSTC_BOOTSTRAP=1 RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" \
1417
$CARGO run --target $TARGET --release | grep "x = 42"
1518
popd
1619
popd

0 commit comments

Comments
 (0)
Please sign in to comment.