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

Try to make top-level Cargo.toml work without __CARGO_TEST_ROOT. #56194

Merged
merged 3 commits into from
Nov 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -26,6 +26,9 @@ members = [
]
exclude = [
"src/tools/rls/test_data",
"build",
# HACK(eddyb) This hardcodes the fact that our CI uses `/checkout/obj`.
"obj",
]

# Curiously, LLVM 7.0 will segfault if compiled with opt-level=3
1 change: 0 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
@@ -1934,7 +1934,6 @@ impl Step for Distcheck {
.arg("generate-lockfile")
.arg("--manifest-path")
.arg(&toml)
.env("__CARGO_TEST_ROOT", &dir)
.current_dir(&dir),
);
}
20 changes: 2 additions & 18 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
@@ -264,7 +264,6 @@ macro_rules! tool {
$name:ident, $path:expr, $tool_name:expr, $mode:expr
$(,llvm_tools = $llvm:expr)*
$(,is_external_tool = $external:expr)*
$(,cargo_test_root = $cargo_test_root:expr)*
;
)+) => {
#[derive(Copy, PartialEq, Eq, Clone)]
@@ -288,15 +287,6 @@ macro_rules! tool {
$(Tool::$name => false $(|| $llvm)*,)+
}
}

/// Whether this tool requires may run Cargo for test crates,
/// which currently needs setting the environment variable
/// `__CARGO_TEST_ROOT` to separate it from the workspace.
pub fn needs_cargo_test_root(&self) -> bool {
match self {
$(Tool::$name => false $(|| $cargo_test_root)*,)+
}
}
}

impl<'a> Builder<'a> {
@@ -372,9 +362,8 @@ tool!(
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::ToolBootstrap;
Tidy, "src/tools/tidy", "tidy", Mode::ToolBootstrap;
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::ToolBootstrap;
CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap, cargo_test_root = true;
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap,
llvm_tools = true, cargo_test_root = true;
CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap;
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true;
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap,
@@ -693,11 +682,6 @@ impl<'a> Builder<'a> {
}
}

// Set `__CARGO_TEST_ROOT` to the build directory if needed.
if tool.needs_cargo_test_root() {
cmd.env("__CARGO_TEST_ROOT", &self.config.out);
}

add_lib_path(lib_paths, cmd);
}

5 changes: 4 additions & 1 deletion src/test/run-make/thumb-none-cortex-m/Makefile
Original file line number Diff line number Diff line change
@@ -32,7 +32,10 @@ all:
mkdir -p $(WORK_DIR)
-cd $(WORK_DIR) && rm -rf $(CRATE)
cd $(WORK_DIR) && bash -x $(HERE)/../git_clone_sha1.sh $(CRATE) $(CRATE_URL) $(CRATE_SHA1)
cd $(WORK_DIR) && cd $(CRATE) && $(CARGO) build --target $(TARGET) -v
# HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
# These come from the top-level Rust workspace, that this crate is not a
# member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
cd $(WORK_DIR) && cd $(CRATE) && env RUSTC_BOOTSTRAP=1 $(CARGO) build --target $(TARGET) -v
else

all:
7 changes: 5 additions & 2 deletions src/test/run-make/thumb-none-qemu/script.sh
Original file line number Diff line number Diff line change
@@ -8,9 +8,12 @@ pushd $WORK_DIR
rm -rf $CRATE || echo OK
cp -a $HERE/example .
pushd $CRATE
env RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" \
# HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
# These come from the top-level Rust workspace, that this crate is not a
# member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
env RUSTC_BOOTSTRAP=1 RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" \
$CARGO run --target $TARGET | grep "x = 42"
env RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" \
env RUSTC_BOOTSTRAP=1 RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" \
$CARGO run --target $TARGET --release | grep "x = 42"
popd
popd