Skip to content

Commit 11268dc

Browse files
committed
bootstrap: move is_rust_llvm() function from lib to config
1 parent ab65486 commit 11268dc

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/bootstrap/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
872872
&& (builder.kind != Kind::Check
873873
|| crate::native::prebuilt_llvm_config(builder, target).is_ok())
874874
{
875-
if builder.is_rust_llvm(target) {
875+
if builder.config.is_rust_llvm(target) {
876876
cargo.env("LLVM_RUSTLLVM", "1");
877877
}
878878
let native::LlvmResult { llvm_config, .. } = builder.ensure(native::Llvm { target });

src/bootstrap/config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,21 @@ impl Config {
16061606
})
16071607
}
16081608

1609+
/// Returns `true` if no custom `llvm-config` is set for the specified target.
1610+
///
1611+
/// If no custom `llvm-config` was specified then Rust's llvm will be used.
1612+
pub fn is_rust_llvm(&self, target: TargetSelection) -> bool {
1613+
match self.target_config.get(&target) {
1614+
Some(Target { llvm_has_rust_patches: Some(patched), .. }) => *patched,
1615+
Some(Target { llvm_config, .. }) => {
1616+
// If the user set llvm-config we assume Rust is not patched,
1617+
// but first check to see if it was configured by llvm-from-ci.
1618+
(self.llvm_from_ci && target == self.build) || llvm_config.is_none()
1619+
}
1620+
None => true,
1621+
}
1622+
}
1623+
16091624
pub fn submodules(&self, rust_info: &GitInfo) -> bool {
16101625
self.submodules.unwrap_or(rust_info.is_managed_git_subrepository())
16111626
}

src/bootstrap/lib.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::str;
2828

2929
use build_helper::ci::CiEnv;
3030
use channel::GitInfo;
31-
use config::{DryRun, Target};
31+
use config::DryRun;
3232
use filetime::FileTime;
3333
use once_cell::sync::OnceCell;
3434

@@ -831,21 +831,6 @@ impl Build {
831831
INTERNER.intern_path(self.out.join(&*target.triple).join("md-doc"))
832832
}
833833

834-
/// Returns `true` if no custom `llvm-config` is set for the specified target.
835-
///
836-
/// If no custom `llvm-config` was specified then Rust's llvm will be used.
837-
fn is_rust_llvm(&self, target: TargetSelection) -> bool {
838-
match self.config.target_config.get(&target) {
839-
Some(Target { llvm_has_rust_patches: Some(patched), .. }) => *patched,
840-
Some(Target { llvm_config, .. }) => {
841-
// If the user set llvm-config we assume Rust is not patched,
842-
// but first check to see if it was configured by llvm-from-ci.
843-
(self.config.llvm_from_ci && target == self.config.build) || llvm_config.is_none()
844-
}
845-
None => true,
846-
}
847-
}
848-
849834
/// Returns the path to `FileCheck` binary for the specified target
850835
fn llvm_filecheck(&self, target: TargetSelection) -> PathBuf {
851836
let target_config = self.config.target_config.get(&target);

src/bootstrap/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
16351635
.arg(llvm_components.trim());
16361636
llvm_components_passed = true;
16371637
}
1638-
if !builder.is_rust_llvm(target) {
1638+
if !builder.config.is_rust_llvm(target) {
16391639
cmd.arg("--system-llvm");
16401640
}
16411641

0 commit comments

Comments
 (0)