Skip to content

Commit 34ef51b

Browse files
committed
[lldb][dotest] Improve libc++ detection
Summary: The test logic for running libc++ tests only looks to see if `/usr/include/c++/v1` exists. This adds a fallback for including libc++ tests as long as `$(CC) -stdlib=libc++` works. Reviewers: labath, EricWF Subscribers: ldionne, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71319
1 parent 5c9816b commit 34ef51b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import signal
3333
import subprocess
3434
import sys
35+
import tempfile
3536

3637
# Third-party modules
3738
import six
@@ -850,9 +851,15 @@ def canRunLibcxxTests():
850851
return True, "libc++ always present"
851852

852853
if platform == "linux":
853-
if not os.path.isdir("/usr/include/c++/v1"):
854-
return False, "Unable to find libc++ installation"
855-
return True, "Headers found, let's hope they work"
854+
if os.path.isdir("/usr/include/c++/v1"):
855+
return True, "Headers found, let's hope they work"
856+
with tempfile.NamedTemporaryFile() as f:
857+
cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"]
858+
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
859+
_, stderr = p.communicate("int main() {}")
860+
if not p.returncode:
861+
return True, "Compiling with -stdlib=libc++ works"
862+
return False, "Compiling with -stdlib=libc++ fails with the error: %s" % stderr
856863

857864
return False, "Don't know how to build with libc++ on %s" % platform
858865

0 commit comments

Comments
 (0)