From 97b7b4bd5bb53d3bd47120a9bb177211b6f403a3 Mon Sep 17 00:00:00 2001 From: Rust Maintainers Date: Sun, 12 Mar 2017 03:15:33 +0000 Subject: [PATCH] d-dynamic-link-llvm Gbp-Pq: Name d-dynamic-link-llvm.patch --- src/etc/mklldeps.py | 35 ++++--------------------- src/librustc_llvm/build.rs | 53 +++----------------------------------- 2 files changed, 9 insertions(+), 79 deletions(-) diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py index 24b007576a..8c86be318d 100644 --- a/src/etc/mklldeps.py +++ b/src/etc/mklldeps.py @@ -56,38 +56,13 @@ def runErr(args): f.write("\n") -args = [llvm_config, '--shared-mode'] -args.extend(components) -llvm_shared, out = runErr(args) -if llvm_shared: - llvm_shared = 'shared' in out +llvm_shared = True # LLVM libs -args = [llvm_config, '--libs', '--system-libs'] -args.extend(components) -out = run(args) -for lib in out.strip().replace("\n", ' ').split(' '): - if len(lib) == 0: - continue - # in some cases we get extra spaces in between libs so ignore those - if len(lib) == 1 and lib == ' ': - continue - # not all libs strictly follow -lfoo, on Bitrig, there is -pthread - if lib[0:2] == '-l': - 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\"") - f.write(")]\n") +# Link in Debian full LLVM shared library. +# FIXME: not sure what to do in the cross-compiling case. +f.write("#[link(name = \"LLVM-3.9\")]\n") + # LLVM ldflags out = run([llvm_config, '--ldflags']) diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 86c40a0208..5c91402d24 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -157,55 +157,10 @@ fn main() { let (llvm_kind, llvm_link_arg) = detect_llvm_link(&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 - // of llvm-config, not the target that we're attempting to link. - let mut cmd = Command::new(&llvm_config); - cmd.arg("--libs"); - - if let Some(link_arg) = llvm_link_arg { - cmd.arg(link_arg); - } - - if !is_crossed { - cmd.arg("--system-libs"); - } - cmd.args(&components[..]); - - for lib in output(&mut cmd).split_whitespace() { - let name = if lib.starts_with("-l") { - &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; - }; - - // Don't need or want this library, but LLVM's CMake build system - // doesn't provide a way to disable it, so filter it here even though we - // may or may not have built it. We don't reference anything from this - // library and it otherwise may just pull in extra dependencies on - // libedit which we don't want - if name == "LLVMLineEditor" { - continue; - } - - let kind = if name.starts_with("LLVM") { - llvm_kind - } else { - "dylib" - }; - println!("cargo:rustc-link-lib={}={}", kind, name); - } + // Link in all LLVM libraries + // Link in Debian full LLVM shared library. + // FIXME: not sure what to do in the cross-compiling case. + println!("cargo:rustc-link-lib={}={}", "dylib", "LLVM-3.9"); // LLVM ldflags // -- 2.30.2