mirror of https://github.com/rust-lang/rust.git
etc: The --system-libs flag is LLVM 3.5+
Older version of LLVM did not have this flag, so we need to fall back to our previous library detection when using older versions of LLVM.
This commit is contained in:
parent
682c401045
commit
36d5635273
|
@ -31,11 +31,20 @@ f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||||
// take a look at src/etc/mklldeps.py if you're interested
|
// take a look at src/etc/mklldeps.py if you're interested
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
def run(args):
|
||||||
|
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
out, err = proc.communicate()
|
||||||
|
|
||||||
|
if err:
|
||||||
|
print("failed to run llconfig: args = `{}`".format(args))
|
||||||
|
print(err)
|
||||||
|
sys.exit(1)
|
||||||
|
return out
|
||||||
|
|
||||||
for llconfig in sys.argv[3:]:
|
for llconfig in sys.argv[3:]:
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
proc = subprocess.Popen([llconfig, '--host-target'], stdout = subprocess.PIPE)
|
out = run([llconfig, '--host-target'])
|
||||||
out, err = proc.communicate()
|
|
||||||
arch, os = out.split('-', 1)
|
arch, os = out.split('-', 1)
|
||||||
arch = 'x86' if arch == 'i686' or arch == 'i386' else arch
|
arch = 'x86' if arch == 'i686' or arch == 'i386' else arch
|
||||||
if 'darwin' in os:
|
if 'darwin' in os:
|
||||||
|
@ -55,16 +64,15 @@ for llconfig in sys.argv[3:]:
|
||||||
|
|
||||||
f.write("#[cfg(" + ', '.join(cfg) + ")]\n")
|
f.write("#[cfg(" + ', '.join(cfg) + ")]\n")
|
||||||
|
|
||||||
|
version = run([llconfig, '--version']).strip()
|
||||||
|
|
||||||
# LLVM libs
|
# LLVM libs
|
||||||
|
if version < '3.5':
|
||||||
|
args = [llconfig, '--libs']
|
||||||
|
else:
|
||||||
args = [llconfig, '--libs', '--system-libs']
|
args = [llconfig, '--libs', '--system-libs']
|
||||||
args.extend(components)
|
args.extend(components)
|
||||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
out = run(args)
|
||||||
out, err = proc.communicate()
|
|
||||||
|
|
||||||
if err:
|
|
||||||
print("failed to run llconfig: args = `{}`".format(args))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
for lib in out.strip().replace("\n", ' ').split(' '):
|
for lib in out.strip().replace("\n", ' ').split(' '):
|
||||||
lib = lib.strip()[2:] # chop of the leading '-l'
|
lib = lib.strip()[2:] # chop of the leading '-l'
|
||||||
f.write("#[link(name = \"" + lib + "\"")
|
f.write("#[link(name = \"" + lib + "\"")
|
||||||
|
@ -73,28 +81,19 @@ for llconfig in sys.argv[3:]:
|
||||||
f.write(", kind = \"static\"")
|
f.write(", kind = \"static\"")
|
||||||
f.write(")]\n")
|
f.write(")]\n")
|
||||||
|
|
||||||
|
# llvm-config before 3.5 didn't have a system-libs flag
|
||||||
|
if version < '3.5':
|
||||||
|
if os == 'win32':
|
||||||
|
f.write("#[link(name = \"imagehlp\")]")
|
||||||
|
|
||||||
# LLVM ldflags
|
# LLVM ldflags
|
||||||
args = [llconfig, '--ldflags']
|
out = run([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(' '):
|
for lib in out.strip().split(' '):
|
||||||
if lib[:2] == "-l":
|
if lib[:2] == "-l":
|
||||||
f.write("#[link(name = \"" + lib[2:] + "\")]\n")
|
f.write("#[link(name = \"" + lib[2:] + "\")]\n")
|
||||||
|
|
||||||
# C++ runtime library
|
# C++ runtime library
|
||||||
args = [llconfig, '--cxxflags']
|
out = run([llconfig, '--cxxflags'])
|
||||||
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)
|
|
||||||
|
|
||||||
if 'stdlib=libc++' in out:
|
if 'stdlib=libc++' in out:
|
||||||
f.write("#[link(name = \"c++\")]\n")
|
f.write("#[link(name = \"c++\")]\n")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue