buildtools: fix archive extraction for LLVM 8

Message ID 20210128190515.7786-1-dmitry.kozliuk@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series buildtools: fix archive extraction for LLVM 8 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/Intel-compilation fail apply issues
ci/iol-testing warning Testing issues

Commit Message

Dmitry Kozlyuk Jan. 28, 2021, 7:05 p.m. UTC
  "llvm-ar xv lib.a" from LLVM 8 doesn't print extracted object file
names. The effect of "v" is not formally specified either.
Use "llvm-ar t" to get archive member names.

Reported-by: XuemingX Zhang <xuemingx.zhang@intel.com>

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 buildtools/gen-pmdinfo-cfile.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
  

Comments

Thomas Monjalon Jan. 28, 2021, 10:02 p.m. UTC | #1
28/01/2021 20:05, Dmitry Kozlyuk:
> "llvm-ar xv lib.a" from LLVM 8 doesn't print extracted object file
> names. The effect of "v" is not formally specified either.
> Use "llvm-ar t" to get archive member names.
> 
> Reported-by: XuemingX Zhang <xuemingx.zhang@intel.com>
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

Applied, thanks
  

Patch

diff --git a/buildtools/gen-pmdinfo-cfile.py b/buildtools/gen-pmdinfo-cfile.py
index a4e080199..58fe3ad15 100644
--- a/buildtools/gen-pmdinfo-cfile.py
+++ b/buildtools/gen-pmdinfo-cfile.py
@@ -9,11 +9,12 @@ 
 
 _, tmp_root, ar, archive, output, *pmdinfogen = sys.argv
 with tempfile.TemporaryDirectory(dir=tmp_root) as temp:
-    proc = subprocess.run(
-        # Don't use "ar p", because its output is corrupted on Windows.
-        [ar, "xv", os.path.abspath(archive)], stdout=subprocess.PIPE, check=True, cwd=temp
+    run_ar = lambda command: subprocess.run(
+        [ar, command, os.path.abspath(archive)],
+        stdout=subprocess.PIPE, check=True, cwd=temp
     )
-    lines = proc.stdout.decode().splitlines()
-    names = [line[len("x - ") :] for line in lines]
+    # Don't use "ar p", because its output is corrupted on Windows.
+    run_ar("x")
+    names = run_ar("t").stdout.decode().splitlines()
     paths = [os.path.join(temp, name) for name in names]
     subprocess.run(pmdinfogen + paths + [output], check=True)