[llvm] bf86968 - Use portable flag with nm in extract_symbols.py

David Tenty via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 23 13:48:49 PDT 2019


Author: David Tenty
Date: 2019-10-23T16:48:22-04:00
New Revision: bf869683c3f26827853e3c34d3c4a337069928fe

URL: https://github.com/llvm/llvm-project/commit/bf869683c3f26827853e3c34d3c4a337069928fe
DIFF: https://github.com/llvm/llvm-project/commit/bf869683c3f26827853e3c34d3c4a337069928fe.diff

LOG: Use portable flag with nm in extract_symbols.py

Summary:
nm is one of the tools that extract_symbols.py can use to extract
symbols from llvm libraries as part of the build process. This patch
updates the invocation of nm to use the -P POSIX option for "portable
output" so we get a consistently parsable output format on all
platforms.

A link to the relevant nm format: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/nm.html

Reviewers: hubert.reinterpretcast, stevewan, sfertile

Reviewed By: stevewan

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69004

Added: 
    

Modified: 
    llvm/utils/extract_symbols.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/extract_symbols.py b/llvm/utils/extract_symbols.py
index 93ad2e9c3758..7cdcce126ce2 100755
--- a/llvm/utils/extract_symbols.py
+++ b/llvm/utils/extract_symbols.py
@@ -42,13 +42,13 @@ def dumpbin_get_symbols(lib):
     process.wait()
 
 def nm_get_symbols(lib):
-    process = subprocess.Popen(['nm',lib], bufsize=1,
+    process = subprocess.Popen(['nm','-P',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
-        match = re.match("^\S+\s+[BDGRSTVW]\s+(\S+)$", line)
+        match = re.match("^(\S+)\s+[BDGRSTVW]\s+\S+\s+\S+$", line)
         if match:
             yield match.group(1)
     process.wait()


        


More information about the llvm-commits mailing list