1
Fork 0

librustc: add LLVM LDFLAGS to deps

This commit let librustc automatically pickup LDFLAGS dependencies
inherited from LLVM, which may otherwise result in undefined
references to external symbols under certain linking environment.

A symptom of this issue is eg. a failure when trying to link against
librustc (due to unresolved ffi_*i symbols), while using a system-wide
LLVM.

Signed-off-by: Luca Bruno <lucab@debian.org>
This commit is contained in:
Luca Bruno 2014-03-02 17:29:54 +01:00
parent baf79083ae
commit 1e2f572fb6

View file

@ -55,6 +55,7 @@ for llconfig in sys.argv[3:]:
f.write("#[cfg(" + ', '.join(cfg) + ")]\n")
# LLVM libs
args = [llconfig, '--libs']
args.extend(components)
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@ -67,6 +68,21 @@ for llconfig in sys.argv[3:]:
for lib in out.strip().split(' '):
lib = lib[2:] # chop of the leading '-l'
f.write("#[link(name = \"" + lib + "\", kind = \"static\")]\n")
# LLVM ldflags
args = [llconfig, '--ldflags']
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = proc.communicate()
if err:
print("failed to run llconfig: args = `{}`".format(args))
sys.exit(1)
for lib in out.strip().split(' '):
if lib[:2] == "-l":
f.write("#[link(name = \"" + lib[2:] + "\")]\n")
#extra
f.write("#[link(name = \"stdc++\")]\n")
if os == 'win32':
f.write("#[link(name = \"imagehlp\")]\n")