diff options
| author | bit-aloo <sshourya17@gmail.com> | 2025-08-09 07:23:05 +0530 |
|---|---|---|
| committer | bit-aloo <sshourya17@gmail.com> | 2025-08-09 07:23:05 +0530 |
| commit | 7eb8f6001e528e811018824e71e36547ea9b7e50 (patch) | |
| tree | 4be9dd6ed4d1d9d8191c4a4bfbcf25450eb7aafd | |
| parent | 111a0e8f2347c7e5996fe1e63d9ade86fba81e01 (diff) | |
| download | rust-7eb8f6001e528e811018824e71e36547ea9b7e50.tar.gz rust-7eb8f6001e528e811018824e71e36547ea9b7e50.zip | |
add is_system_llvm function and invoke from parse_inner
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index bfee43148c0..56c549297e2 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1315,7 +1315,14 @@ impl Config { ); } - if config.lld_enabled && config.is_system_llvm(config.host_target) { + if config.lld_enabled + && is_system_llvm( + &config.host_target, + config.llvm_from_ci, + &config.target_config, + config.host_target, + ) + { panic!("Cannot enable LLD with `rust.lld = true` when using external llvm-config."); } @@ -2700,3 +2707,28 @@ pub fn submodules_(submodules: &Option<bool>, rust_info: &channel::GitInfo) -> b // submodules if we're currently inside a git repository. submodules.unwrap_or(rust_info.is_managed_git_subrepository()) } + +/// Returns `true` if this is an external version of LLVM not managed by bootstrap. +/// In particular, we expect llvm sources to be available when this is false. +/// +/// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set. +pub fn is_system_llvm( + host_target: &TargetSelection, + llvm_from_ci: bool, + target_config: &HashMap<TargetSelection, Target>, + target: TargetSelection, +) -> bool { + match target_config.get(&target) { + Some(Target { llvm_config: Some(_), .. }) => { + let ci_llvm = llvm_from_ci && is_host_target(host_target, &target); + !ci_llvm + } + // We're building from the in-tree src/llvm-project sources. + Some(Target { llvm_config: None, .. }) => false, + None => false, + } +} + +pub fn is_host_target(host_target: &TargetSelection, target: &TargetSelection) -> bool { + host_target == target +} |
