Skip to content

Commit 32a81d1

Browse files
committed
configure: Enable libc++ with LLVM with clang
When clang is enabled, also pass through --enable-libcpp to LLVM's configure command line to help it pick up the most recent c++ runtime library. This also changes the mklldeps.py script to pick up on whether LLVM was linked against stdc++ or c++ based on the --cxxflags that llvm-config prints. In an ongoing attempt to update LLVM, the bots need to update their C compilers to something that supports c++11 (LLVM recently switched). The OSX bots are running Lion (10.7), which only supports up to gcc 4.2 and clang 3.2. Apparently the libstdc++ is too old (even on the most updated command line tools) for LLVM, but using libc++ instead appears to work just fine.
1 parent 30ff17f commit 32a81d1

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

configure

+2
Original file line numberDiff line numberDiff line change
@@ -938,13 +938,15 @@ do
938938

939939
LLVM_CXX_64="ccache clang++ -Qunused-arguments"
940940
LLVM_CC_64="ccache clang -Qunused-arguments"
941+
LLVM_OPTS="$LLVM_OPTS --enable-libcpp"
941942
;;
942943
("clang")
943944
LLVM_CXX_32="clang++ -m32 -Qunused-arguments"
944945
LLVM_CC_32="clang -m32 -Qunused-arguments"
945946

946947
LLVM_CXX_64="clang++ -Qunused-arguments"
947948
LLVM_CC_64="clang -Qunused-arguments"
949+
LLVM_OPTS="$LLVM_OPTS --enable-libcpp"
948950
;;
949951
("ccache gcc")
950952
LLVM_CXX_32="ccache g++ -m32"

src/etc/mklldeps.py

+23-8
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
f.write("#[cfg(" + ', '.join(cfg) + ")]\n")
5757

5858
# LLVM libs
59-
args = [llconfig, '--libs']
59+
args = [llconfig, '--libs', '--system-libs']
6060
args.extend(components)
6161
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
6262
out, err = proc.communicate()
@@ -65,9 +65,13 @@
6565
print("failed to run llconfig: args = `{}`".format(args))
6666
sys.exit(1)
6767

68-
for lib in out.strip().split(' '):
69-
lib = lib[2:] # chop of the leading '-l'
70-
f.write("#[link(name = \"" + lib + "\", kind = \"static\")]\n")
68+
for lib in out.strip().replace("\n", ' ').split(' '):
69+
lib = lib.strip()[2:] # chop of the leading '-l'
70+
f.write("#[link(name = \"" + lib + "\"")
71+
# LLVM libraries are all static libraries
72+
if 'LLVM' in lib:
73+
f.write(", kind = \"static\"")
74+
f.write(")]\n")
7175

7276
# LLVM ldflags
7377
args = [llconfig, '--ldflags']
@@ -82,8 +86,19 @@
8286
if lib[:2] == "-l":
8387
f.write("#[link(name = \"" + lib[2:] + "\")]\n")
8488

85-
#extra
86-
f.write("#[link(name = \"stdc++\")]\n")
87-
if os == 'win32':
88-
f.write("#[link(name = \"imagehlp\")]\n")
89+
# C++ runtime library
90+
args = [llconfig, '--cxxflags']
91+
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
92+
out, err = proc.communicate()
93+
94+
if err:
95+
print("failed to run llconfig: args = `{}`".format(args))
96+
sys.exit(1)
97+
98+
if 'stdlib=libc++' in out:
99+
f.write("#[link(name = \"c++\")]\n")
100+
else:
101+
f.write("#[link(name = \"stdc++\")]\n")
102+
103+
# Attach everything to an extern block
89104
f.write("extern {}\n")

0 commit comments

Comments
 (0)