diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-07-25 15:37:12 -0700 |
|---|---|---|
| committer | Jan-Erik Rediger <janerik@fnordig.de> | 2016-07-29 10:29:59 +0200 |
| commit | 0509be1f6bc48da753d7383275d3c39591f3650c (patch) | |
| tree | e842e8368d4b2f3763560bdac94b7746940d508f /src | |
| parent | 75bcda4cf1c2d16bda20d1efb0c87b227d973180 (diff) | |
Update parsing llvm-config output
Now it prints full paths on MSVC, but we're only interested in path names
Diffstat (limited to 'src')
| -rw-r--r-- | src/etc/mklldeps.py | 7 | ||||
| -rw-r--r-- | src/librustc_llvm/build.rs | 19 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py index 8381e4f7040..24b007576aa 100644 --- a/src/etc/mklldeps.py +++ b/src/etc/mklldeps.py @@ -77,6 +77,13 @@ for lib in out.strip().replace("\n", ' ').split(' '): lib = lib.strip()[2:] elif lib[0] == '-': lib = lib.strip()[1:] + # If this actually points at a literal file then we're on MSVC which now + # prints full paths, so get just the name of the library and strip off the + # trailing ".lib" + elif os.path.exists(lib): + lib = os.path.basename(lib)[:-4] + elif lib[-4:] == '.lib': + lib = lib[:-4] f.write("#[link(name = \"" + lib + "\"") if not llvm_shared and 'LLVM' in lib: f.write(", kind = \"static\"") diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index a2c808cbcb6..085ea240a50 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -13,7 +13,7 @@ extern crate build_helper; use std::process::Command; use std::env; -use std::path::PathBuf; +use std::path::{PathBuf, Path}; use build_helper::output; @@ -135,8 +135,17 @@ fn main() { &lib[2..] } else if lib.starts_with("-") { &lib[1..] + } else if Path::new(lib).exists() { + // On MSVC llvm-config will print the full name to libraries, but + // we're only interested in the name part + let name = Path::new(lib).file_name().unwrap().to_str().unwrap(); + name.trim_right_matches(".lib") + } else if lib.ends_with(".lib") { + // Some MSVC libraries just come up with `.lib` tacked on, so chop + // that off + lib.trim_right_matches(".lib") } else { - continue; + continue }; // Don't need or want this library, but LLVM's CMake build system @@ -145,7 +154,7 @@ fn main() { // library and it otherwise may just pull in extra dependencies on // libedit which we don't want if name == "LLVMLineEditor" { - continue; + continue } let kind = if name.starts_with("LLVM") { @@ -165,7 +174,9 @@ fn main() { let mut cmd = Command::new(&llvm_config); cmd.arg("--ldflags"); for lib in output(&mut cmd).split_whitespace() { - if is_crossed { + if lib.starts_with("-LIBPATH:") { + println!("cargo:rustc-link-search=native={}", &lib[9..]); + } else if is_crossed { if lib.starts_with("-L") { println!("cargo:rustc-link-search=native={}", lib[2..].replace(&host, &target)); |
