Skip to content

Commit 769f984

Browse files
committed
Add test
1 parent 6d949a7 commit 769f984

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ impl Step for RustAnalyzerProcMacroSrv {
986986
/// Compile the `llvm-bitcode-linker` tool for `target`.
987987
/// It is a compiler host tool used to link specific targets using LLVM.
988988
/// It is used by `rustc` at runtime.
989-
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
989+
#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
990990
pub struct LlvmBitcodeLinker {
991991
pub target: TargetSelection,
992992
}

src/bootstrap/src/core/builder/tests.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use llvm::prebuilt_llvm_config;
77
use super::*;
88
use crate::Flags;
99
use crate::core::build_steps::doc::DocumentationFormat;
10+
use crate::core::build_steps::tool::LlvmBitcodeLinker;
1011
use crate::core::config::Config;
1112
use crate::utils::tests::git::{GitCtx, git_test};
1213

@@ -1233,3 +1234,29 @@ fn any_debug() {
12331234
// Downcasting to the underlying type should succeed.
12341235
assert_eq!(x.downcast_ref::<MyStruct>(), Some(&MyStruct { x: 7 }));
12351236
}
1237+
1238+
/// Check that during a non-cross-compiling stage 2 build, we only compile rustc host tools
1239+
/// (such as llvm-bitcode-linker) only once.
1240+
#[test]
1241+
fn llvm_bitcode_linker_compile_once() {
1242+
let mut cache = run_build(
1243+
&[],
1244+
configure_with_args(
1245+
&[
1246+
"build".to_string(),
1247+
"--stage".to_string(),
1248+
"2".to_string(),
1249+
"--set".to_string(),
1250+
"rust.llvm-bitcode-linker=true".to_string(),
1251+
],
1252+
&[TEST_TRIPLE_1],
1253+
&[TEST_TRIPLE_2],
1254+
),
1255+
);
1256+
1257+
// Check that llvm-bitcode-linker was built only once, and for host, not target
1258+
assert_eq!(
1259+
first(cache.all::<LlvmBitcodeLinker>()),
1260+
&[LlvmBitcodeLinker { target: TargetSelection::from_user(TEST_TRIPLE_1) }]
1261+
);
1262+
}

0 commit comments

Comments
 (0)