Skip to content

Commit

Permalink
librustc: add LLVM LDFLAGS to deps
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lucab committed Mar 2, 2014
1 parent baf7908 commit 1e2f572
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/etc/mklldeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

f.write("#[cfg(" + ', '.join(cfg) + ")]\n")

# LLVM libs
args = [llconfig, '--libs']
args.extend(components)
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand All @@ -67,6 +68,21 @@
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")
Expand Down

0 comments on commit 1e2f572

Please sign in to comment.