summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-20 08:32:49 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-24 11:52:27 +0100
commite0ea2c73781800fa2e1c7d9d2fd540eca2f9f3e3 (patch)
tree6ef6b2197a005421d36953a196376c82dc115109 /meta
parentbc6b668e6048950e8449b6ba415ae1c4f682f986 (diff)
downloadpoky-e0ea2c73781800fa2e1c7d9d2fd540eca2f9f3e3.tar.gz
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>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/package.bbclass47
1 files changed, 30 insertions, 17 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 03fe18de58..94e4639a11 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1631,25 +1631,28 @@ python package_do_shlibs() {
1631 1631
1632 shlibswork_dir = d.getVar('SHLIBSWORKDIR') 1632 shlibswork_dir = d.getVar('SHLIBSWORKDIR')
1633 1633
1634 def linux_so(file, needed, sonames, renames, pkgver): 1634 def linux_so(file, pkg, pkgver, d):
1635 needs_ldconfig = False 1635 needs_ldconfig = False
1636 needed = set()
1637 sonames = set()
1638 renames = []
1636 ldir = os.path.dirname(file).replace(pkgdest + "/" + pkg, '') 1639 ldir = os.path.dirname(file).replace(pkgdest + "/" + pkg, '')
1637 cmd = d.getVar('OBJDUMP') + " -p " + pipes.quote(file) + " 2>/dev/null" 1640 cmd = d.getVar('OBJDUMP') + " -p " + pipes.quote(file) + " 2>/dev/null"
1638 fd = os.popen(cmd) 1641 fd = os.popen(cmd)
1639 lines = fd.readlines() 1642 lines = fd.readlines()
1640 fd.close() 1643 fd.close()
1641 rpath = [] 1644 rpath = tuple()
1642 for l in lines: 1645 for l in lines:
1643 m = re.match("\s+RPATH\s+([^\s]*)", l) 1646 m = re.match("\s+RPATH\s+([^\s]*)", l)
1644 if m: 1647 if m:
1645 rpaths = m.group(1).replace("$ORIGIN", ldir).split(":") 1648 rpaths = m.group(1).replace("$ORIGIN", ldir).split(":")
1646 rpath = list(map(os.path.normpath, rpaths)) 1649 rpath = tuple(map(os.path.normpath, rpaths))
1647 for l in lines: 1650 for l in lines:
1648 m = re.match("\s+NEEDED\s+([^\s]*)", l) 1651 m = re.match("\s+NEEDED\s+([^\s]*)", l)
1649 if m: 1652 if m:
1650 dep = m.group(1) 1653 dep = m.group(1)
1651 if dep not in needed[pkg]: 1654 if dep not in needed:
1652 needed[pkg].append((dep, file, rpath)) 1655 needed.add((dep, file, rpath))
1653 m = re.match("\s+SONAME\s+([^\s]*)", l) 1656 m = re.match("\s+SONAME\s+([^\s]*)", l)
1654 if m: 1657 if m:
1655 this_soname = m.group(1) 1658 this_soname = m.group(1)
@@ -1657,12 +1660,12 @@ python package_do_shlibs() {
1657 if not prov in sonames: 1660 if not prov in sonames:
1658 # if library is private (only used by package) then do not build shlib for it 1661 # if library is private (only used by package) then do not build shlib for it
1659 if not private_libs or this_soname not in private_libs: 1662 if not private_libs or this_soname not in private_libs:
1660 sonames.append(prov) 1663 sonames.add(prov)
1661 if libdir_re.match(os.path.dirname(file)): 1664 if libdir_re.match(os.path.dirname(file)):
1662 needs_ldconfig = True 1665 needs_ldconfig = True
1663 if snap_symlinks and (os.path.basename(file) != this_soname): 1666 if snap_symlinks and (os.path.basename(file) != this_soname):
1664 renames.append((file, os.path.join(os.path.dirname(file), this_soname))) 1667 renames.append((file, os.path.join(os.path.dirname(file), this_soname)))
1665 return needs_ldconfig 1668 return (needs_ldconfig, needed, sonames, renames)
1666 1669
1667 def darwin_so(file, needed, sonames, renames, pkgver): 1670 def darwin_so(file, needed, sonames, renames, pkgver):
1668 if not os.path.exists(file): 1671 if not os.path.exists(file):
@@ -1690,7 +1693,7 @@ python package_do_shlibs() {
1690 for combo in combos: 1693 for combo in combos:
1691 if not combo in sonames: 1694 if not combo in sonames:
1692 prov = (combo, ldir, pkgver) 1695 prov = (combo, ldir, pkgver)
1693 sonames.append(prov) 1696 sonames.add(prov)
1694 if file.endswith('.dylib') or file.endswith('.so'): 1697 if file.endswith('.dylib') or file.endswith('.so'):
1695 rpath = [] 1698 rpath = []
1696 p = sub.Popen([d.expand("${HOST_PREFIX}otool"), '-l', file],stdout=sub.PIPE,stderr=sub.PIPE) 1699 p = sub.Popen([d.expand("${HOST_PREFIX}otool"), '-l', file],stdout=sub.PIPE,stderr=sub.PIPE)
@@ -1714,7 +1717,7 @@ python package_do_shlibs() {
1714 continue 1717 continue
1715 name = os.path.basename(l.split()[0]).rsplit(".", 1)[0] 1718 name = os.path.basename(l.split()[0]).rsplit(".", 1)[0]
1716 if name and name not in needed[pkg]: 1719 if name and name not in needed[pkg]:
1717 needed[pkg].append((name, file, [])) 1720 needed[pkg].add((name, file, tuple()))
1718 1721
1719 def mingw_dll(file, needed, sonames, renames, pkgver): 1722 def mingw_dll(file, needed, sonames, renames, pkgver):
1720 if not os.path.exists(file): 1723 if not os.path.exists(file):
@@ -1722,7 +1725,7 @@ python package_do_shlibs() {
1722 1725
1723 if file.endswith(".dll"): 1726 if file.endswith(".dll"):
1724 # assume all dlls are shared objects provided by the package 1727 # assume all dlls are shared objects provided by the package
1725 sonames.append((os.path.basename(file), os.path.dirname(file).replace(pkgdest + "/" + pkg, ''), pkgver)) 1728 sonames.add((os.path.basename(file), os.path.dirname(file).replace(pkgdest + "/" + pkg, ''), pkgver))
1726 1729
1727 if (file.endswith(".dll") or file.endswith(".exe")): 1730 if (file.endswith(".dll") or file.endswith(".exe")):
1728 # use objdump to search for "DLL Name: .*\.dll" 1731 # use objdump to search for "DLL Name: .*\.dll"
@@ -1733,7 +1736,7 @@ python package_do_shlibs() {
1733 for m in re.finditer("DLL Name: (.*?\.dll)$", out.decode(), re.MULTILINE | re.IGNORECASE): 1736 for m in re.finditer("DLL Name: (.*?\.dll)$", out.decode(), re.MULTILINE | re.IGNORECASE):
1734 dllname = m.group(1) 1737 dllname = m.group(1)
1735 if dllname: 1738 if dllname:
1736 needed[pkg].append((dllname, file, [])) 1739 needed[pkg].add((dllname, file, tuple()))
1737 1740
1738 if d.getVar('PACKAGE_SNAP_LIB_SYMLINKS') == "1": 1741 if d.getVar('PACKAGE_SNAP_LIB_SYMLINKS') == "1":
1739 snap_symlinks = True 1742 snap_symlinks = True
@@ -1761,9 +1764,10 @@ python package_do_shlibs() {
1761 if not pkgver: 1764 if not pkgver:
1762 pkgver = ver 1765 pkgver = ver
1763 1766
1764 needed[pkg] = [] 1767 needed[pkg] = set()
1765 sonames = list() 1768 sonames = set()
1766 renames = list() 1769 renames = []
1770 linuxlist = []
1767 for file in pkgfiles[pkg]: 1771 for file in pkgfiles[pkg]:
1768 soname = None 1772 soname = None
1769 if cpath.islink(file): 1773 if cpath.islink(file):
@@ -1773,8 +1777,17 @@ python package_do_shlibs() {
1773 elif targetos.startswith("mingw"): 1777 elif targetos.startswith("mingw"):
1774 mingw_dll(file, needed, sonames, renames, pkgver) 1778 mingw_dll(file, needed, sonames, renames, pkgver)
1775 elif os.access(file, os.X_OK) or lib_re.match(file): 1779 elif os.access(file, os.X_OK) or lib_re.match(file):
1776 ldconfig = linux_so(file, needed, sonames, renames, pkgver) 1780 linuxlist.append(file)
1777 needs_ldconfig = needs_ldconfig or ldconfig 1781
1782 if linuxlist:
1783 results = oe.utils.multiprocess_launch(linux_so, linuxlist, d, extraargs=(pkg, pkgver, d))
1784 for r in results:
1785 ldconfig = r[0]
1786 needed[pkg] |= r[1]
1787 sonames |= r[2]
1788 renames.extend(r[3])
1789 needs_ldconfig = needs_ldconfig or ldconfig
1790
1778 for (old, new) in renames: 1791 for (old, new) in renames:
1779 bb.note("Renaming %s to %s" % (old, new)) 1792 bb.note("Renaming %s to %s" % (old, new))
1780 os.rename(old, new) 1793 os.rename(old, new)
@@ -1840,7 +1853,7 @@ python package_do_shlibs() {
1840 for k in shlib_provider[n[0]].keys(): 1853 for k in shlib_provider[n[0]].keys():
1841 shlib_provider_path.append(k) 1854 shlib_provider_path.append(k)
1842 match = None 1855 match = None
1843 for p in n[2] + shlib_provider_path + libsearchpath: 1856 for p in list(n[2]) + shlib_provider_path + libsearchpath:
1844 if p in shlib_provider[n[0]]: 1857 if p in shlib_provider[n[0]]:
1845 match = p 1858 match = p
1846 break 1859 break