mirror of
https://git.yoctoproject.org/poky
synced 2026-06-03 13:49:49 +00:00
package: Allow parallel processing of shlib analysis
This function is a bit more invasive to add parallelism to but allows the shlibs analysis to happen in multiple threads. In order to return values correctly/safely the data types needed tweaking to avoid lists and use immutable objects. (From OE-Core rev: b5788fb1f795f2f35d1788d8311e12984ffb2122) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -1631,25 +1631,28 @@ python package_do_shlibs() {
|
|||||||
|
|
||||||
shlibswork_dir = d.getVar('SHLIBSWORKDIR')
|
shlibswork_dir = d.getVar('SHLIBSWORKDIR')
|
||||||
|
|
||||||
def linux_so(file, needed, sonames, renames, pkgver):
|
def linux_so(file, pkg, pkgver, d):
|
||||||
needs_ldconfig = False
|
needs_ldconfig = False
|
||||||
|
needed = set()
|
||||||
|
sonames = set()
|
||||||
|
renames = []
|
||||||
ldir = os.path.dirname(file).replace(pkgdest + "/" + pkg, '')
|
ldir = os.path.dirname(file).replace(pkgdest + "/" + pkg, '')
|
||||||
cmd = d.getVar('OBJDUMP') + " -p " + pipes.quote(file) + " 2>/dev/null"
|
cmd = d.getVar('OBJDUMP') + " -p " + pipes.quote(file) + " 2>/dev/null"
|
||||||
fd = os.popen(cmd)
|
fd = os.popen(cmd)
|
||||||
lines = fd.readlines()
|
lines = fd.readlines()
|
||||||
fd.close()
|
fd.close()
|
||||||
rpath = []
|
rpath = tuple()
|
||||||
for l in lines:
|
for l in lines:
|
||||||
m = re.match("\s+RPATH\s+([^\s]*)", l)
|
m = re.match("\s+RPATH\s+([^\s]*)", l)
|
||||||
if m:
|
if m:
|
||||||
rpaths = m.group(1).replace("$ORIGIN", ldir).split(":")
|
rpaths = m.group(1).replace("$ORIGIN", ldir).split(":")
|
||||||
rpath = list(map(os.path.normpath, rpaths))
|
rpath = tuple(map(os.path.normpath, rpaths))
|
||||||
for l in lines:
|
for l in lines:
|
||||||
m = re.match("\s+NEEDED\s+([^\s]*)", l)
|
m = re.match("\s+NEEDED\s+([^\s]*)", l)
|
||||||
if m:
|
if m:
|
||||||
dep = m.group(1)
|
dep = m.group(1)
|
||||||
if dep not in needed[pkg]:
|
if dep not in needed:
|
||||||
needed[pkg].append((dep, file, rpath))
|
needed.add((dep, file, rpath))
|
||||||
m = re.match("\s+SONAME\s+([^\s]*)", l)
|
m = re.match("\s+SONAME\s+([^\s]*)", l)
|
||||||
if m:
|
if m:
|
||||||
this_soname = m.group(1)
|
this_soname = m.group(1)
|
||||||
@@ -1657,12 +1660,12 @@ python package_do_shlibs() {
|
|||||||
if not prov in sonames:
|
if not prov in sonames:
|
||||||
# if library is private (only used by package) then do not build shlib for it
|
# if library is private (only used by package) then do not build shlib for it
|
||||||
if not private_libs or this_soname not in private_libs:
|
if not private_libs or this_soname not in private_libs:
|
||||||
sonames.append(prov)
|
sonames.add(prov)
|
||||||
if libdir_re.match(os.path.dirname(file)):
|
if libdir_re.match(os.path.dirname(file)):
|
||||||
needs_ldconfig = True
|
needs_ldconfig = True
|
||||||
if snap_symlinks and (os.path.basename(file) != this_soname):
|
if snap_symlinks and (os.path.basename(file) != this_soname):
|
||||||
renames.append((file, os.path.join(os.path.dirname(file), this_soname)))
|
renames.append((file, os.path.join(os.path.dirname(file), this_soname)))
|
||||||
return needs_ldconfig
|
return (needs_ldconfig, needed, sonames, renames)
|
||||||
|
|
||||||
def darwin_so(file, needed, sonames, renames, pkgver):
|
def darwin_so(file, needed, sonames, renames, pkgver):
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
@@ -1690,7 +1693,7 @@ python package_do_shlibs() {
|
|||||||
for combo in combos:
|
for combo in combos:
|
||||||
if not combo in sonames:
|
if not combo in sonames:
|
||||||
prov = (combo, ldir, pkgver)
|
prov = (combo, ldir, pkgver)
|
||||||
sonames.append(prov)
|
sonames.add(prov)
|
||||||
if file.endswith('.dylib') or file.endswith('.so'):
|
if file.endswith('.dylib') or file.endswith('.so'):
|
||||||
rpath = []
|
rpath = []
|
||||||
p = sub.Popen([d.expand("${HOST_PREFIX}otool"), '-l', file],stdout=sub.PIPE,stderr=sub.PIPE)
|
p = sub.Popen([d.expand("${HOST_PREFIX}otool"), '-l', file],stdout=sub.PIPE,stderr=sub.PIPE)
|
||||||
@@ -1714,7 +1717,7 @@ python package_do_shlibs() {
|
|||||||
continue
|
continue
|
||||||
name = os.path.basename(l.split()[0]).rsplit(".", 1)[0]
|
name = os.path.basename(l.split()[0]).rsplit(".", 1)[0]
|
||||||
if name and name not in needed[pkg]:
|
if name and name not in needed[pkg]:
|
||||||
needed[pkg].append((name, file, []))
|
needed[pkg].add((name, file, tuple()))
|
||||||
|
|
||||||
def mingw_dll(file, needed, sonames, renames, pkgver):
|
def mingw_dll(file, needed, sonames, renames, pkgver):
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
@@ -1722,7 +1725,7 @@ python package_do_shlibs() {
|
|||||||
|
|
||||||
if file.endswith(".dll"):
|
if file.endswith(".dll"):
|
||||||
# assume all dlls are shared objects provided by the package
|
# assume all dlls are shared objects provided by the package
|
||||||
sonames.append((os.path.basename(file), os.path.dirname(file).replace(pkgdest + "/" + pkg, ''), pkgver))
|
sonames.add((os.path.basename(file), os.path.dirname(file).replace(pkgdest + "/" + pkg, ''), pkgver))
|
||||||
|
|
||||||
if (file.endswith(".dll") or file.endswith(".exe")):
|
if (file.endswith(".dll") or file.endswith(".exe")):
|
||||||
# use objdump to search for "DLL Name: .*\.dll"
|
# use objdump to search for "DLL Name: .*\.dll"
|
||||||
@@ -1733,7 +1736,7 @@ python package_do_shlibs() {
|
|||||||
for m in re.finditer("DLL Name: (.*?\.dll)$", out.decode(), re.MULTILINE | re.IGNORECASE):
|
for m in re.finditer("DLL Name: (.*?\.dll)$", out.decode(), re.MULTILINE | re.IGNORECASE):
|
||||||
dllname = m.group(1)
|
dllname = m.group(1)
|
||||||
if dllname:
|
if dllname:
|
||||||
needed[pkg].append((dllname, file, []))
|
needed[pkg].add((dllname, file, tuple()))
|
||||||
|
|
||||||
if d.getVar('PACKAGE_SNAP_LIB_SYMLINKS') == "1":
|
if d.getVar('PACKAGE_SNAP_LIB_SYMLINKS') == "1":
|
||||||
snap_symlinks = True
|
snap_symlinks = True
|
||||||
@@ -1761,9 +1764,10 @@ python package_do_shlibs() {
|
|||||||
if not pkgver:
|
if not pkgver:
|
||||||
pkgver = ver
|
pkgver = ver
|
||||||
|
|
||||||
needed[pkg] = []
|
needed[pkg] = set()
|
||||||
sonames = list()
|
sonames = set()
|
||||||
renames = list()
|
renames = []
|
||||||
|
linuxlist = []
|
||||||
for file in pkgfiles[pkg]:
|
for file in pkgfiles[pkg]:
|
||||||
soname = None
|
soname = None
|
||||||
if cpath.islink(file):
|
if cpath.islink(file):
|
||||||
@@ -1773,8 +1777,17 @@ python package_do_shlibs() {
|
|||||||
elif targetos.startswith("mingw"):
|
elif targetos.startswith("mingw"):
|
||||||
mingw_dll(file, needed, sonames, renames, pkgver)
|
mingw_dll(file, needed, sonames, renames, pkgver)
|
||||||
elif os.access(file, os.X_OK) or lib_re.match(file):
|
elif os.access(file, os.X_OK) or lib_re.match(file):
|
||||||
ldconfig = linux_so(file, needed, sonames, renames, pkgver)
|
linuxlist.append(file)
|
||||||
needs_ldconfig = needs_ldconfig or ldconfig
|
|
||||||
|
if linuxlist:
|
||||||
|
results = oe.utils.multiprocess_launch(linux_so, linuxlist, d, extraargs=(pkg, pkgver, d))
|
||||||
|
for r in results:
|
||||||
|
ldconfig = r[0]
|
||||||
|
needed[pkg] |= r[1]
|
||||||
|
sonames |= r[2]
|
||||||
|
renames.extend(r[3])
|
||||||
|
needs_ldconfig = needs_ldconfig or ldconfig
|
||||||
|
|
||||||
for (old, new) in renames:
|
for (old, new) in renames:
|
||||||
bb.note("Renaming %s to %s" % (old, new))
|
bb.note("Renaming %s to %s" % (old, new))
|
||||||
os.rename(old, new)
|
os.rename(old, new)
|
||||||
@@ -1840,7 +1853,7 @@ python package_do_shlibs() {
|
|||||||
for k in shlib_provider[n[0]].keys():
|
for k in shlib_provider[n[0]].keys():
|
||||||
shlib_provider_path.append(k)
|
shlib_provider_path.append(k)
|
||||||
match = None
|
match = None
|
||||||
for p in n[2] + shlib_provider_path + libsearchpath:
|
for p in list(n[2]) + shlib_provider_path + libsearchpath:
|
||||||
if p in shlib_provider[n[0]]:
|
if p in shlib_provider[n[0]]:
|
||||||
match = p
|
match = p
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user