X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_llvm%2Fbuild.rs;h=62ef5804dce6d7491f1a8c79620d4986114ed745;hb=03d488b48af9f66b91e9400387f781b82411fa82;hp=7729ec6bef4a7409eff955dc96b90e90524fcf4a;hpb=d7388d1857fa32c6659997b901631f087d68dbf0;p=rust.git diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 7729ec6bef4..62ef5804dce 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -4,6 +4,29 @@ use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; +const OPTIONAL_COMPONENTS: &[&str] = &[ + "x86", + "arm", + "aarch64", + "amdgpu", + "avr", + "m68k", + "mips", + "powerpc", + "systemz", + "jsbackend", + "webassembly", + "msp430", + "sparc", + "nvptx", + "hexagon", + "riscv", + "bpf", +]; + +const REQUIRED_COMPONENTS: &[&str] = + &["ipo", "bitreader", "bitwriter", "linker", "asmparser", "lto", "coverage", "instrumentation"]; + fn detect_llvm_link() -> (&'static str, &'static str) { // Force the link mode we want, preferring static by default, but // possibly overridden by `configure --enable-llvm-link-shared`. @@ -76,6 +99,10 @@ fn output(cmd: &mut Command) -> String { } fn main() { + for component in REQUIRED_COMPONENTS.iter().chain(OPTIONAL_COMPONENTS.iter()) { + println!("cargo:rustc-check-cfg=values(llvm_component,\"{}\")", component); + } + if tracked_env_var_os("RUST_CHECK").is_some() { // If we're just running `check`, there's no need for LLVM to be built. return; @@ -131,42 +158,11 @@ fn main() { let host = env::var("HOST").expect("HOST was not set"); let is_crossed = target != host; - let optional_components = &[ - "x86", - "arm", - "aarch64", - "amdgpu", - "avr", - "m68k", - "mips", - "powerpc", - "systemz", - "jsbackend", - "webassembly", - "msp430", - "sparc", - "nvptx", - "hexagon", - "riscv", - "bpf", - ]; - - let required_components = &[ - "ipo", - "bitreader", - "bitwriter", - "linker", - "asmparser", - "lto", - "coverage", - "instrumentation", - ]; - let components = output(Command::new(&llvm_config).arg("--components")); let mut components = components.split_whitespace().collect::>(); - components.retain(|c| optional_components.contains(c) || required_components.contains(c)); + components.retain(|c| OPTIONAL_COMPONENTS.contains(c) || REQUIRED_COMPONENTS.contains(c)); - for component in required_components { + for component in REQUIRED_COMPONENTS { if !components.contains(component) { panic!("require llvm component {} but wasn't found", component); }