Skip to content

Commit 1c0561a

Browse files
authored
Rollup merge of #101072 - tmandry:llvm-is-vanilla, r=Mark-Simulacrum
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. This simplifies the logic in `is_rust_llvm` a bit; it doesn't need to check for download-ci-llvm because we would have already errored if both that and llvm-config were specified on the host platform.
2 parents b05f97d + 73958fd commit 1c0561a

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ no_llvm_build
4646
/dist/
4747
/unicode-downloads
4848
/target
49+
/src/bootstrap/target
4950
/src/tools/x/target
5051
# Created by default with `src/ci/docker/run.sh`
5152
/obj/

config.toml.example

+4
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

+3
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>,
@@ -733,6 +734,7 @@ define_config! {
733734
default_linker: Option<PathBuf> = "default-linker",
734735
linker: Option<String> = "linker",
735736
llvm_config: Option<String> = "llvm-config",
737+
llvm_has_rust_patches: Option<bool> = "llvm-has-rust-patches",
736738
llvm_filecheck: Option<String> = "llvm-filecheck",
737739
llvm_libunwind: Option<String> = "llvm-libunwind",
738740
android_ndk: Option<String> = "android-ndk",
@@ -1109,6 +1111,7 @@ impl Config {
11091111
if let Some(ref s) = cfg.llvm_config {
11101112
target.llvm_config = Some(config.src.join(s));
11111113
}
1114+
target.llvm_has_rust_patches = cfg.llvm_has_rust_patches;
11121115
if let Some(ref s) = cfg.llvm_filecheck {
11131116
target.llvm_filecheck = Some(config.src.join(s));
11141117
}

src/bootstrap/lib.rs

+7-5
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

@@ -839,12 +840,13 @@ impl Build {
839840
///
840841
/// If no custom `llvm-config` was specified then Rust's llvm will be used.
841842
fn is_rust_llvm(&self, target: TargetSelection) -> bool {
842-
if self.config.llvm_from_ci && target == self.config.build {
843-
return true;
844-
}
845-
846843
match self.config.target_config.get(&target) {
847-
Some(ref c) => c.llvm_config.is_none(),
844+
Some(Target { llvm_has_rust_patches: Some(patched), .. }) => *patched,
845+
Some(Target { llvm_config, .. }) => {
846+
// If the user set llvm-config we assume Rust is not patched,
847+
// but first check to see if it was configured by llvm-from-ci.
848+
(self.config.llvm_from_ci && target == self.config.build) || llvm_config.is_none()
849+
}
848850
None => true,
849851
}
850852
}

0 commit comments

Comments
 (0)