Bug 1516228 - Use llvm-objdump for ELF in dependentlibs.py, too. r=firefox-build-system-reviewers,mshal
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 24 Jan 2019 15:55:59 +0000
changeset 455342 53d93ee3ad847b03120d3159e2b8b2caace7a370
parent 455341 4f53ede3351741395c132fbbcfb03a06926b7113
child 455343 24ebb52d21fa602df6aa29c88921c0b8b487bf5c
push id35432
push usernbeleuzu@mozilla.com
push dateFri, 25 Jan 2019 04:27:48 +0000
treeherdermozilla-central@93a452407d5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, mshal
bugs1516228
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1516228 - Use llvm-objdump for ELF in dependentlibs.py, too. r=firefox-build-system-reviewers,mshal Depends on D17465 Differential Revision: https://phabricator.services.mozilla.com/D17466
toolkit/library/dependentlibs.py
--- a/toolkit/library/dependentlibs.py
+++ b/toolkit/library/dependentlibs.py
@@ -24,35 +24,26 @@ def dependentlibs_win32_objdump(lib):
     deps = []
     for line in proc.stdout:
         match = re.match('\s+DLL Name: (\S+)', line)
         if match:
             deps.append(match.group(1))
     proc.wait()
     return deps
 
-def dependentlibs_readelf(lib):
+def dependentlibs_elf_objdump(lib):
     '''Returns the list of dependencies declared in the given ELF .so'''
-    proc = subprocess.Popen([substs.get('TOOLCHAIN_PREFIX', '') + 'readelf', '-d', lib], stdout = subprocess.PIPE)
+    proc = subprocess.Popen([substs['LLVM_OBJDUMP'], '--private-headers', lib], stdout = subprocess.PIPE)
     deps = []
     for line in proc.stdout:
-        # Each line has the following format:
-        #  tag (TYPE)          value
-        # or with BSD readelf:
-        #  tag TYPE            value
-        # Looking for NEEDED type entries
-        tmp = line.split(' ', 3)
-        if len(tmp) > 3 and 'NEEDED' in tmp[2]:
-            # NEEDED lines look like:
-            # 0x00000001 (NEEDED)             Shared library: [libname]
-            # or with BSD readelf:
-            # 0x00000001 NEEDED               Shared library: [libname]
-            match = re.search('\[(.*)\]', tmp[3])
-            if match:
-                deps.append(match.group(1))
+        # We are looking for lines with the format:
+        #   NEEDED             libname
+        tmp = line.split()
+        if len(tmp) == 2 and tmp[0] == 'NEEDED':
+            deps.append(tmp[1])
     proc.wait()
     return deps
 
 def dependentlibs_mac_objdump(lib):
     '''Returns the list of dependencies declared in the given MACH-O dylib'''
     proc = subprocess.Popen([substs['LLVM_OBJDUMP'], '--private-headers', lib], stdout = subprocess.PIPE)
     deps = []
     cmd = None
@@ -94,17 +85,17 @@ def dependentlibs(lib, libpaths, func):
                 break
 
     return deps
 
 def gen_list(output, lib):
     libpaths = [os.path.join(substs['DIST'], 'bin')]
     binary_type = get_type(lib)
     if binary_type == ELF:
-        func = dependentlibs_readelf
+        func = dependentlibs_elf_objdump
     elif binary_type == MACHO:
         func = dependentlibs_mac_objdump
     else:
         ext = os.path.splitext(lib)[1]
         assert(ext == '.dll')
         func = dependentlibs_win32_objdump
 
     deps = dependentlibs(lib, libpaths, func)