From e136e02fd97ac5207f1a0d1edd276ef22a1d24c1 Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Fri, 26 Aug 2022 19:24:41 -0700 Subject: [PATCH 1/2] 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. --- config.toml.example | 4 ++++ src/bootstrap/config.rs | 3 +++ src/bootstrap/lib.rs | 12 +++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/config.toml.example b/config.toml.example index b3284050f05..28ccc2c8f14 100644 --- a/config.toml.example +++ b/config.toml.example @@ -666,6 +666,10 @@ changelog-seen = 2 # target. #llvm-config = (path) +# Override detection of whether this is a Rust-patched LLVM. This would be used +# in conjunction with either an llvm-config or build.submodules = false. +#llvm-has-rust-patches = if llvm-config { false } else { true } + # Normally the build system can find LLVM's FileCheck utility, but if # not, you can specify an explicit file name for it. #llvm-filecheck = "/path/to/llvm-version/bin/FileCheck" diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index ea0f78e2a6b..f98f07b8eba 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -388,6 +388,7 @@ fn eq(&self, other: &&str) -> bool { pub struct Target { /// Some(path to llvm-config) if using an external LLVM. pub llvm_config: Option, + pub llvm_has_rust_patches: Option, /// Some(path to FileCheck) if one was specified. pub llvm_filecheck: Option, pub llvm_libunwind: Option, @@ -729,6 +730,7 @@ struct TomlTarget { default_linker: Option = "default-linker", linker: Option = "linker", llvm_config: Option = "llvm-config", + llvm_has_rust_patches: Option = "llvm-has-rust-patches", llvm_filecheck: Option = "llvm-filecheck", llvm_libunwind: Option = "llvm-libunwind", android_ndk: Option = "android-ndk", @@ -1140,6 +1142,7 @@ pub fn parse(args: &[String]) -> Config { if let Some(ref s) = cfg.llvm_config { target.llvm_config = Some(config.src.join(s)); } + target.llvm_has_rust_patches = cfg.llvm_has_rust_patches; if let Some(ref s) = cfg.llvm_filecheck { target.llvm_filecheck = Some(config.src.join(s)); } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index cd421c249d8..751692b46f3 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -112,6 +112,7 @@ use std::process::Command; use std::str; +use config::Target; use filetime::FileTime; use once_cell::sync::OnceCell; @@ -854,12 +855,13 @@ fn md_doc_out(&self, target: TargetSelection) -> Interned { /// /// If no custom `llvm-config` was specified then Rust's llvm will be used. fn is_rust_llvm(&self, target: TargetSelection) -> bool { - if self.config.llvm_from_ci && target == self.config.build { - return true; - } - match self.config.target_config.get(&target) { - Some(ref c) => c.llvm_config.is_none(), + Some(Target { llvm_has_rust_patches: Some(patched), .. }) => *patched, + Some(Target { llvm_config, .. }) => { + // If the user set llvm-config we assume Rust is not patched, + // but first check to see if it was configured by llvm-from-ci. + (self.config.llvm_from_ci && target == self.config.build) || llvm_config.is_none() + } None => true, } } From 73958fdf14d965eac2148991af99f0e0ad0c97ad Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Fri, 26 Aug 2022 19:29:39 -0700 Subject: [PATCH 2/2] Ignore cargo target folder in src/bootstrap Needed after changes in #97513. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a6625ac2ac4..79405e37775 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ no_llvm_build /dist/ /unicode-downloads /target +/src/bootstrap/target /src/tools/x/target # Created by default with `src/ci/docker/run.sh` /obj/