Skip to content

Commit e136e02

Browse files
committed
bootstrap: Add llvm-has-rust-patches target option
This is so you can check out an upstream commit in src/llvm-project and have everything just work.
1 parent 03d488b commit e136e02

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

config.toml.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ changelog-seen = 2
666666
# target.
667667
#llvm-config = <none> (path)
668668

669+
# Override detection of whether this is a Rust-patched LLVM. This would be used
670+
# in conjunction with either an llvm-config or build.submodules = false.
671+
#llvm-has-rust-patches = if llvm-config { false } else { true }
672+
669673
# Normally the build system can find LLVM's FileCheck utility, but if
670674
# not, you can specify an explicit file name for it.
671675
#llvm-filecheck = "/path/to/llvm-version/bin/FileCheck"

src/bootstrap/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ impl PartialEq<&str> for TargetSelection {
388388
pub struct Target {
389389
/// Some(path to llvm-config) if using an external LLVM.
390390
pub llvm_config: Option<PathBuf>,
391+
pub llvm_has_rust_patches: Option<bool>,
391392
/// Some(path to FileCheck) if one was specified.
392393
pub llvm_filecheck: Option<PathBuf>,
393394
pub llvm_libunwind: Option<LlvmLibunwind>,
@@ -729,6 +730,7 @@ define_config! {
729730
default_linker: Option<PathBuf> = "default-linker",
730731
linker: Option<String> = "linker",
731732
llvm_config: Option<String> = "llvm-config",
733+
llvm_has_rust_patches: Option<bool> = "llvm-has-rust-patches",
732734
llvm_filecheck: Option<String> = "llvm-filecheck",
733735
llvm_libunwind: Option<String> = "llvm-libunwind",
734736
android_ndk: Option<String> = "android-ndk",
@@ -1140,6 +1142,7 @@ impl Config {
11401142
if let Some(ref s) = cfg.llvm_config {
11411143
target.llvm_config = Some(config.src.join(s));
11421144
}
1145+
target.llvm_has_rust_patches = cfg.llvm_has_rust_patches;
11431146
if let Some(ref s) = cfg.llvm_filecheck {
11441147
target.llvm_filecheck = Some(config.src.join(s));
11451148
}

src/bootstrap/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ use std::path::{Path, PathBuf};
112112
use std::process::Command;
113113
use std::str;
114114

115+
use config::Target;
115116
use filetime::FileTime;
116117
use once_cell::sync::OnceCell;
117118

@@ -854,12 +855,13 @@ impl Build {
854855
///
855856
/// If no custom `llvm-config` was specified then Rust's llvm will be used.
856857
fn is_rust_llvm(&self, target: TargetSelection) -> bool {
857-
if self.config.llvm_from_ci && target == self.config.build {
858-
return true;
859-
}
860-
861858
match self.config.target_config.get(&target) {
862-
Some(ref c) => c.llvm_config.is_none(),
859+
Some(Target { llvm_has_rust_patches: Some(patched), .. }) => *patched,
860+
Some(Target { llvm_config, .. }) => {
861+
// If the user set llvm-config we assume Rust is not patched,
862+
// but first check to see if it was configured by llvm-from-ci.
863+
(self.config.llvm_from_ci && target == self.config.build) || llvm_config.is_none()
864+
}
863865
None => true,
864866
}
865867
}

0 commit comments

Comments
 (0)