[Lldb-commits] [PATCH] D71319: [lldb][dotest] Improve libc++ detection

Jordan Rupprecht via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 11 13:51:44 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG34ef51b5f979: [lldb][dotest] Improve libc++ detection (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71319/new/

https://reviews.llvm.org/D71319

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


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -32,6 +32,7 @@
 import signal
 import subprocess
 import sys
+import tempfile
 
 # Third-party modules
 import six
@@ -850,9 +851,15 @@
         return True, "libc++ always present"
 
     if platform == "linux":
-        if not os.path.isdir("/usr/include/c++/v1"):
-            return False, "Unable to find libc++ installation"
-        return True, "Headers found, let's hope they work"
+        if os.path.isdir("/usr/include/c++/v1"):
+            return True, "Headers found, let's hope they work"
+        with tempfile.NamedTemporaryFile() as f:
+            cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"]
+            p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+            _, stderr = p.communicate("int main() {}")
+            if not p.returncode:
+                return True, "Compiling with -stdlib=libc++ works"
+            return False, "Compiling with -stdlib=libc++ fails with the error: %s" % stderr
 
     return False, "Don't know how to build with libc++ on %s" % platform
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71319.233444.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191211/2cd8fda8/attachment.bin>


More information about the lldb-commits mailing list