[llvm] 1edb04b - [extract_symbols.py] Adjust usage of nm again
John Brawn via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 13 08:31:58 PST 2023
Author: John Brawn
Date: 2023-02-13T16:29:08Z
New Revision: 1edb04bc70f3db2d34295270474cad15c6c775f0
URL: https://github.com/llvm/llvm-project/commit/1edb04bc70f3db2d34295270474cad15c6c775f0
DIFF: https://github.com/llvm/llvm-project/commit/1edb04bc70f3db2d34295270474cad15c6c775f0.diff
LOG: [extract_symbols.py] Adjust usage of nm again
The previous change to extract_symbols.py means that building on macOS
with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS fails as we try to export some
local symbols, as the regex used to match external symbols wasn't good
enough. Solve this by using the -g option to nm, so we only get
external symbols and don't have to check for local symbols at all.
Added:
Modified:
llvm/utils/extract_symbols.py
Removed:
################################################################################
diff --git a/llvm/utils/extract_symbols.py b/llvm/utils/extract_symbols.py
index 7270f59ec0d54..1d057cd3a51a5 100755
--- a/llvm/utils/extract_symbols.py
+++ b/llvm/utils/extract_symbols.py
@@ -42,14 +42,14 @@ def dumpbin_get_symbols(lib):
process.wait()
def nm_get_symbols(lib):
+ # -P means the output is in portable format, and -g means we only get global
+ # symbols.
+ cmd = ['nm','-P','-g']
if sys.platform.startswith('aix'):
- process = subprocess.Popen(['nm','-P','-Xany','-C','-p',lib], bufsize=1,
- stdout=subprocess.PIPE, stdin=subprocess.PIPE,
- universal_newlines=True)
- else:
- process = subprocess.Popen(['nm','-P',lib], bufsize=1,
- stdout=subprocess.PIPE, stdin=subprocess.PIPE,
- universal_newlines=True)
+ cmd += ['-Xany','-C','-p']
+ process = subprocess.Popen(cmd+[lib], bufsize=1,
+ stdout=subprocess.PIPE, stdin=subprocess.PIPE,
+ universal_newlines=True)
process.stdin.close()
for line in process.stdout:
# Look for external symbols that are defined in some section, i.e.
@@ -59,7 +59,7 @@ def nm_get_symbols(lib):
# The -P flag displays the size field for symbols only when applicable,
# so the last field is optional. There's no space after the value field,
# but \s+ match newline also, so \s+\S* will match the optional size field.
- match = re.match("^(\S+)\s+[^AabdtU]\s+\S+\s+\S*$", line)
+ match = re.match("^(\S+)\s+[^AU]\s+\S+\s+\S*$", line)
if match:
yield (match.group(1), True)
# Look for undefined symbols, which have only name and type (which is U).
More information about the llvm-commits
mailing list