Avoid the hexagon backend on old versions of LLVM
This commit is contained in:
parent
c558a2ae37
commit
32aeb22f54
1 changed files with 38 additions and 28 deletions
|
@ -17,30 +17,24 @@ use std::path::{PathBuf, Path};
|
|||
|
||||
use build_helper::output;
|
||||
|
||||
fn detect_llvm_link(llvm_config: &Path) -> (&'static str, Option<&'static str>) {
|
||||
let mut version_cmd = Command::new(llvm_config);
|
||||
version_cmd.arg("--version");
|
||||
let version_output = output(&mut version_cmd);
|
||||
let mut parts = version_output.split('.').take(2)
|
||||
.filter_map(|s| s.parse::<u32>().ok());
|
||||
if let (Some(major), Some(minor)) = (parts.next(), parts.next()) {
|
||||
if major > 3 || (major == 3 && minor >= 9) {
|
||||
// Force the link mode we want, preferring static by default, but
|
||||
// possibly overridden by `configure --enable-llvm-link-shared`.
|
||||
if env::var_os("LLVM_LINK_SHARED").is_some() {
|
||||
return ("dylib", Some("--link-shared"));
|
||||
} else {
|
||||
return ("static", Some("--link-static"));
|
||||
}
|
||||
} else if major == 3 && minor == 8 {
|
||||
// Find out LLVM's default linking mode.
|
||||
let mut mode_cmd = Command::new(llvm_config);
|
||||
mode_cmd.arg("--shared-mode");
|
||||
if output(&mut mode_cmd).trim() == "shared" {
|
||||
return ("dylib", None);
|
||||
} else {
|
||||
return ("static", None);
|
||||
}
|
||||
fn detect_llvm_link(major: u32, minor: u32, llvm_config: &Path)
|
||||
-> (&'static str, Option<&'static str>) {
|
||||
if major > 3 || (major == 3 && minor >= 9) {
|
||||
// Force the link mode we want, preferring static by default, but
|
||||
// possibly overridden by `configure --enable-llvm-link-shared`.
|
||||
if env::var_os("LLVM_LINK_SHARED").is_some() {
|
||||
return ("dylib", Some("--link-shared"));
|
||||
} else {
|
||||
return ("static", Some("--link-static"));
|
||||
}
|
||||
} else if major == 3 && minor == 8 {
|
||||
// Find out LLVM's default linking mode.
|
||||
let mut mode_cmd = Command::new(llvm_config);
|
||||
mode_cmd.arg("--shared-mode");
|
||||
if output(&mut mode_cmd).trim() == "shared" {
|
||||
return ("dylib", None);
|
||||
} else {
|
||||
return ("static", None);
|
||||
}
|
||||
}
|
||||
("static", None)
|
||||
|
@ -92,9 +86,25 @@ fn main() {
|
|||
let host = env::var("HOST").expect("HOST was not set");
|
||||
let is_crossed = target != host;
|
||||
|
||||
let optional_components =
|
||||
["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz", "jsbackend", "msp430",
|
||||
"sparc", "nvptx", "hexagon"];
|
||||
let mut optional_components =
|
||||
vec!["x86", "arm", "aarch64", "mips", "powerpc", "pnacl",
|
||||
"systemz", "jsbackend", "msp430", "sparc", "nvptx"];
|
||||
|
||||
let mut version_cmd = Command::new(&llvm_config);
|
||||
version_cmd.arg("--version");
|
||||
let version_output = output(&mut version_cmd);
|
||||
let mut parts = version_output.split('.').take(2)
|
||||
.filter_map(|s| s.parse::<u32>().ok());
|
||||
let (major, minor) =
|
||||
if let (Some(major), Some(minor)) = (parts.next(), parts.next()) {
|
||||
(major, minor)
|
||||
} else {
|
||||
(3, 7)
|
||||
};
|
||||
|
||||
if major > 3 {
|
||||
optional_components.push("hexagon");
|
||||
}
|
||||
|
||||
// FIXME: surely we don't need all these components, right? Stuff like mcjit
|
||||
// or interpreter the compiler itself never uses.
|
||||
|
@ -158,7 +168,7 @@ fn main() {
|
|||
.cpp_link_stdlib(None) // we handle this below
|
||||
.compile("librustllvm.a");
|
||||
|
||||
let (llvm_kind, llvm_link_arg) = detect_llvm_link(&llvm_config);
|
||||
let (llvm_kind, llvm_link_arg) = detect_llvm_link(major, minor, &llvm_config);
|
||||
|
||||
// Link in all LLVM libraries, if we're uwring the "wrong" llvm-config then
|
||||
// we don't pick up system libs because unfortunately they're for the host
|
||||
|
|
Loading…
Add table
Reference in a new issue