[libcxx-commits] [libcxx] d8afac7 - [libc++] Use Python subprocess instead of libc++'s own utilities
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 25 06:33:29 PDT 2022
Author: Louis Dionne
Date: 2022-05-25T09:33:22-04:00
New Revision: d8afac7a2b736b367cc817242b0c4a13a3ff0051
URL: https://github.com/llvm/llvm-project/commit/d8afac7a2b736b367cc817242b0c4a13a3ff0051
DIFF: https://github.com/llvm/llvm-project/commit/d8afac7a2b736b367cc817242b0c4a13a3ff0051.diff
LOG: [libc++] Use Python subprocess instead of libc++'s own utilities
Once we move off entirely from the legacy testing framework, this will
allow removing a bunch of code.
Differential Revision: https://reviews.llvm.org/D126303
Added:
Modified:
libcxx/utils/libcxx/sym_check/extract.py
libcxx/utils/libcxx/sym_check/util.py
Removed:
################################################################################
diff --git a/libcxx/utils/libcxx/sym_check/extract.py b/libcxx/utils/libcxx/sym_check/extract.py
index 07299891792e..13769ec55274 100644
--- a/libcxx/utils/libcxx/sym_check/extract.py
+++ b/libcxx/utils/libcxx/sym_check/extract.py
@@ -11,10 +11,10 @@
"""
import distutils.spawn
import os.path
-import sys
import re
+import subprocess
+import sys
-import libcxx.util
from libcxx.sym_check import util
extract_ignore_names = ['_init', '_fini']
@@ -51,9 +51,7 @@ def extract(self, lib):
parsed symbols.
"""
cmd = [self.nm_exe] + self.flags + [lib]
- out, _, exit_code = libcxx.util.executeCommandVerbose(cmd)
- if exit_code != 0:
- raise RuntimeError('Failed to run %s on %s' % (self.nm_exe, lib))
+ out = subprocess.check_output(cmd).decode()
fmt_syms = (self._extract_sym(l)
for l in out.splitlines() if l.strip())
# Cast symbol to string.
@@ -139,9 +137,7 @@ def extract(self, lib):
parsed symbols.
"""
cmd = [self.tool] + self.flags + [lib]
- out, _, exit_code = libcxx.util.executeCommandVerbose(cmd)
- if exit_code != 0:
- raise RuntimeError('Failed to run %s on %s' % (self.nm_exe, lib))
+ out = subprocess.check_output(cmd).decode()
dyn_syms = self.get_dynsym_table(out)
return self.process_syms(dyn_syms)
diff --git a/libcxx/utils/libcxx/sym_check/util.py b/libcxx/utils/libcxx/sym_check/util.py
index 13f09d4b214f..41c6439eca77 100644
--- a/libcxx/utils/libcxx/sym_check/util.py
+++ b/libcxx/utils/libcxx/sym_check/util.py
@@ -6,12 +6,12 @@
#
#===----------------------------------------------------------------------===##
+from pprint import pformat
import ast
import distutils.spawn
-import sys
import re
-import libcxx.util
-from pprint import pformat
+import subprocess
+import sys
def read_syms_from_list(slist):
@@ -66,11 +66,10 @@ def write_syms(sym_list, out=None, names_only=False, filter=None):
def demangle_symbol(symbol):
if _cppfilt_exe is None:
return symbol
- out, _, exit_code = libcxx.util.executeCommandVerbose(
- [_cppfilt_exe], input=symbol)
- if exit_code != 0:
+ result = subprocess.run([_cppfilt_exe], input=symbol.encode(), capture_output=True)
+ if result.returncode != 0:
return symbol
- return out
+ return result.stdout.decode()
def is_elf(filename):
More information about the libcxx-commits
mailing list