From: Rust Maintainers Date: Wed, 4 Jan 2017 20:34:56 +0000 (+0000) Subject: d-dynamic-link-llvm X-Git-Tag: archive/raspbian/1.17.0+dfsg2-8+rpi1~2^2^2^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c17f459252f178031d1961dac4b19dda53bb0e1d;p=rustc.git d-dynamic-link-llvm Gbp-Pq: Name d-dynamic-link-llvm.patch --- diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py index 24b007576a..9d1ce8c2b7 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. +# TODO: 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 4d3a4d09dc..4cb3366a6b 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -123,63 +123,10 @@ fn main() { .cpp_link_stdlib(None) // we handle this below .compile("librustllvm.a"); - // 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"); - - // Force static linking with "--link-static" if available. - 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('.'); - if let (Some(major), Some(minor)) = (parts.next().and_then(|s| s.parse::().ok()), - parts.next().and_then(|s| s.parse::().ok())) { - if major > 3 || (major == 3 && minor >= 8) { - cmd.arg("--link-static"); - } - } - - 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") { - "static" - } else { - "dylib" - }; - println!("cargo:rustc-link-lib={}={}", kind, name); - } + // Link in all LLVM libraries + // Link in Debian full LLVM shared library. + // TODO: not sure what to do in the cross-compiling case. + println!("cargo:rustc-link-lib={}={}", "dylib", "LLVM-3.9"); // LLVM ldflags //