mirror of
https://git.proxmox.com/git/rustc
synced 2026-08-13 04:40:29 +00:00
Actually we don't need to run llvm-config at all, if we're just hard-coding -lLLVM
This commit is contained in:
parent
3641207ab5
commit
f0387a45d2
104
debian/patches/dynamic-link-llvm.patch
vendored
104
debian/patches/dynamic-link-llvm.patch
vendored
@ -1,33 +1,61 @@
|
||||
Description: Dynamically link with Debian's LLVM
|
||||
Hard-code -lLLVM, instead of using llvm-config to figure out which components
|
||||
to link in. The latter doesn't work properly anyway for dynamic linking - see
|
||||
LLVM bug #3201. If/when this is fixed, then Rust upstream will probably fix
|
||||
their code to allow for this, and after that happens we can rm this patch.
|
||||
.
|
||||
TODO: not sure if we need extra tweaks for cross-compiling
|
||||
Author: Ximin Luo <infinity0@debian.org>
|
||||
Forwarded: not-needed
|
||||
---
|
||||
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
|
||||
--- a/src/librustc_llvm/build.rs
|
||||
+++ b/src/librustc_llvm/build.rs
|
||||
@@ -125,6 +125,9 @@
|
||||
}
|
||||
cmd.args(&components[..]);
|
||||
|
||||
+ // Link in Debian full LLVM shared library.
|
||||
+ println!("cargo:rustc-link-lib={}={}", "dylib", "LLVM");
|
||||
+
|
||||
for lib in output(&mut cmd).split_whitespace() {
|
||||
let name = if lib.starts_with("-l") {
|
||||
&lib[2..]
|
||||
@@ -143,8 +146,12 @@
|
||||
continue
|
||||
}
|
||||
@@ -115,37 +115,10 @@
|
||||
.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");
|
||||
- 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 {
|
||||
- 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);
|
||||
+ // On Debian we ignore the LLVM component static libs, and instead
|
||||
+ // dynamically link in the full LLVM shared library, above.
|
||||
+ // See #832565 for more details
|
||||
+ if !name.starts_with("LLVM") {
|
||||
+ println!("cargo:rustc-link-lib={}={}", "dylib", 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");
|
||||
|
||||
// LLVM ldflags
|
||||
//
|
||||
--- a/src/etc/mklldeps.py
|
||||
+++ b/src/etc/mklldeps.py
|
||||
@@ -56,16 +56,14 @@
|
||||
@@ -56,31 +56,12 @@
|
||||
|
||||
f.write("\n")
|
||||
|
||||
@ -39,27 +67,27 @@
|
||||
+llvm_shared = True
|
||||
|
||||
# LLVM libs
|
||||
args = [llvm_config, '--libs', '--system-libs']
|
||||
args.extend(components)
|
||||
out = run(args)
|
||||
+# Link in Debian full LLVM shared library.
|
||||
+f.write("#[link(name = \"LLVM\")]\n")
|
||||
for lib in out.strip().replace("\n", ' ').split(' '):
|
||||
if len(lib) == 0:
|
||||
continue
|
||||
@@ -77,10 +75,11 @@
|
||||
lib = lib.strip()[2:]
|
||||
elif lib[0] == '-':
|
||||
lib = lib.strip()[1:]
|
||||
-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:]
|
||||
- f.write("#[link(name = \"" + lib + "\"")
|
||||
- if not llvm_shared and 'LLVM' in lib:
|
||||
- f.write(", kind = \"static\"")
|
||||
- f.write(")]\n")
|
||||
+ # On Debian we ignore the LLVM component static libs, and instead
|
||||
+ # dynamically link in the full LLVM shared library, above.
|
||||
+ # See #832565 for more details
|
||||
+ if not 'LLVM' in lib:
|
||||
+ f.write("#[link(name = \"" + lib + "\")]\n")
|
||||
+# Link in Debian full LLVM shared library.
|
||||
+# TODO: not sure what to do in the cross-compiling case.
|
||||
+f.write("#[link(name = \"LLVM\")]\n")
|
||||
|
||||
# LLVM ldflags
|
||||
out = run([llvm_config, '--ldflags'])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user