mirror of https://github.com/rust-lang/rust.git
add and document a new `is_system_llvm` abstraction
This commit is contained in:
parent
1a47f5b448
commit
1490bbab92
|
@ -2032,23 +2032,24 @@ fn install_llvm_file(builder: &Builder<'_>, source: &Path, destination: &Path) {
|
|||
///
|
||||
/// Returns whether the files were actually copied.
|
||||
fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir: &Path) -> bool {
|
||||
if let Some(config) = builder.config.target_config.get(&target) {
|
||||
if config.llvm_config.is_some() && !builder.config.llvm_from_ci {
|
||||
// If the LLVM was externally provided, then we don't currently copy
|
||||
// artifacts into the sysroot. This is not necessarily the right
|
||||
// choice (in particular, it will require the LLVM dylib to be in
|
||||
// the linker's load path at runtime), but the common use case for
|
||||
// external LLVMs is distribution provided LLVMs, and in that case
|
||||
// they're usually in the standard search path (e.g., /usr/lib) and
|
||||
// copying them here is going to cause problems as we may end up
|
||||
// with the wrong files and isn't what distributions want.
|
||||
//
|
||||
// This behavior may be revisited in the future though.
|
||||
//
|
||||
// If the LLVM is coming from ourselves (just from CI) though, we
|
||||
// still want to install it, as it otherwise won't be available.
|
||||
return false;
|
||||
}
|
||||
// If the LLVM was externally provided, then we don't currently copy
|
||||
// artifacts into the sysroot. This is not necessarily the right
|
||||
// choice (in particular, it will require the LLVM dylib to be in
|
||||
// the linker's load path at runtime), but the common use case for
|
||||
// external LLVMs is distribution provided LLVMs, and in that case
|
||||
// they're usually in the standard search path (e.g., /usr/lib) and
|
||||
// copying them here is going to cause problems as we may end up
|
||||
// with the wrong files and isn't what distributions want.
|
||||
//
|
||||
// This behavior may be revisited in the future though.
|
||||
//
|
||||
// NOTE: this intentionally doesn't use `is_rust_llvm`; whether this is patched or not doesn't matter,
|
||||
// we only care if the shared object itself is managed by bootstrap.
|
||||
//
|
||||
// If the LLVM is coming from ourselves (just from CI) though, we
|
||||
// still want to install it, as it otherwise won't be available.
|
||||
if builder.is_system_llvm(target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// On macOS, rustc (and LLVM tools) link to an unversioned libLLVM.dylib
|
||||
|
|
|
@ -1845,6 +1845,8 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
|
|||
llvm_components_passed = true;
|
||||
}
|
||||
if !builder.is_rust_llvm(target) {
|
||||
// FIXME: missing Rust patches is not the same as being system llvm; we should rename the flag at some point.
|
||||
// Inspecting the tests with `// no-system-llvm` in src/test *looks* like this is doing the right thing, though.
|
||||
cmd.arg("--system-llvm");
|
||||
}
|
||||
|
||||
|
|
|
@ -1810,7 +1810,14 @@ impl Config {
|
|||
}
|
||||
target.llvm_config = Some(config.src.join(s));
|
||||
}
|
||||
target.llvm_has_rust_patches = cfg.llvm_has_rust_patches;
|
||||
if let Some(patches) = cfg.llvm_has_rust_patches {
|
||||
assert_eq!(
|
||||
config.submodules,
|
||||
Some(false),
|
||||
"cannot set `llvm-has-rust-patches` for a managed submodule (set `build.submodules = false` if you want to apply patches)"
|
||||
);
|
||||
target.llvm_has_rust_patches = Some(patches);
|
||||
}
|
||||
if let Some(ref s) = cfg.llvm_filecheck {
|
||||
target.llvm_filecheck = Some(config.src.join(s));
|
||||
}
|
||||
|
|
|
@ -823,18 +823,34 @@ impl Build {
|
|||
INTERNER.intern_path(self.out.join(&*target.triple).join("md-doc"))
|
||||
}
|
||||
|
||||
/// Returns `true` if no custom `llvm-config` is set for the specified target.
|
||||
/// 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.
|
||||
///
|
||||
/// If no custom `llvm-config` was specified then Rust's llvm will be used.
|
||||
/// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set.
|
||||
fn is_system_llvm(&self, target: TargetSelection) -> bool {
|
||||
match self.config.target_config.get(&target) {
|
||||
Some(Target { llvm_config: Some(_), .. }) => {
|
||||
let ci_llvm = self.config.llvm_from_ci && target == self.config.build;
|
||||
!ci_llvm
|
||||
}
|
||||
// We're building from the in-tree src/llvm-project sources.
|
||||
Some(Target { llvm_config: None, .. }) => false,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if this is our custom, patched, version of LLVM.
|
||||
///
|
||||
/// This does not necessarily imply that we're managing the `llvm-project` submodule.
|
||||
fn is_rust_llvm(&self, target: TargetSelection) -> bool {
|
||||
match self.config.target_config.get(&target) {
|
||||
// We're using a user-controlled version of LLVM. The user has explicitly told us whether the version has our patches.
|
||||
// (They might be wrong, but that's not a supported use-case.)
|
||||
// In particular, this tries to support `submodules = false` and `patches = false`, for using a newer version of LLVM that's not through `rust-lang/llvm-project`.
|
||||
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,
|
||||
// The user hasn't promised the patches match.
|
||||
// This only has our patches if it's downloaded from CI or built from source.
|
||||
_ => !self.is_system_llvm(target),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue