Skip to content

Commit 7eb8f60

Browse files
committed
add is_system_llvm function and invoke from parse_inner
1 parent 111a0e8 commit 7eb8f60

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/bootstrap/src/core/config/config.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,14 @@ impl Config {
13151315
);
13161316
}
13171317

1318-
if config.lld_enabled && config.is_system_llvm(config.host_target) {
1318+
if config.lld_enabled
1319+
&& is_system_llvm(
1320+
&config.host_target,
1321+
config.llvm_from_ci,
1322+
&config.target_config,
1323+
config.host_target,
1324+
)
1325+
{
13191326
panic!("Cannot enable LLD with `rust.lld = true` when using external llvm-config.");
13201327
}
13211328

@@ -2700,3 +2707,28 @@ pub fn submodules_(submodules: &Option<bool>, rust_info: &channel::GitInfo) -> b
27002707
// submodules if we're currently inside a git repository.
27012708
submodules.unwrap_or(rust_info.is_managed_git_subrepository())
27022709
}
2710+
2711+
/// Returns `true` if this is an external version of LLVM not managed by bootstrap.
2712+
/// In particular, we expect llvm sources to be available when this is false.
2713+
///
2714+
/// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set.
2715+
pub fn is_system_llvm(
2716+
host_target: &TargetSelection,
2717+
llvm_from_ci: bool,
2718+
target_config: &HashMap<TargetSelection, Target>,
2719+
target: TargetSelection,
2720+
) -> bool {
2721+
match target_config.get(&target) {
2722+
Some(Target { llvm_config: Some(_), .. }) => {
2723+
let ci_llvm = llvm_from_ci && is_host_target(host_target, &target);
2724+
!ci_llvm
2725+
}
2726+
// We're building from the in-tree src/llvm-project sources.
2727+
Some(Target { llvm_config: None, .. }) => false,
2728+
None => false,
2729+
}
2730+
}
2731+
2732+
pub fn is_host_target(host_target: &TargetSelection, target: &TargetSelection) -> bool {
2733+
host_target == target
2734+
}

0 commit comments

Comments
 (0)