d-dynamic-link-llvm
authorRust Maintainers <pkg-rust-maintainers@lists.alioth.debian.org>
Wed, 4 Jan 2017 20:34:56 +0000 (20:34 +0000)
committerXimin Luo <infinity0@debian.org>
Wed, 4 Jan 2017 20:34:56 +0000 (20:34 +0000)
Gbp-Pq: Name d-dynamic-link-llvm.patch

src/etc/mklldeps.py
src/librustc_llvm/build.rs

index 24b007576aa24ad673a6687d246400f0dd16b459..9d1ce8c2b713fd7c07bcb6c045d7d545fd1e0e59 100644 (file)
@@ -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'])
index 4d3a4d09dcea04bf3ad882861f07d232cabcd4a9..4cb3366a6bb4076b3fb73a082e4204690b58f2a5 100644 (file)
@@ -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::<u32>().ok()),
-                                         parts.next().and_then(|s| s.parse::<u32>().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
     //