mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-22 07:21:06 +01:00
[check-libstdc++] Only inspect direct DT_NEEDED entries (#6592)
ldd prints the full transitive dependency closure, so the check fails when a dependency of a dependency links C++ (for example cairo -> fontconfig -> libxml2 -> ICU), even though HarfBuzz itself has no libstdc++/libc++ NEEDED entry. When readelf (or llvm-readelf) is available, inspect the library's own (NEEDED) entries and check every exported library, including harfbuzz-cairo and harfbuzz-icu. Without either tool, keep the ldd/otool closure check but skip those two, whose closure is known to contain libstdc++.
This commit is contained in:
1 parent
5a53654525
commit
24439d01be
2 files changed
+15
-5
No files matched your search
+12
-3
@@ -5,7 +5,7 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from check_helpers import CHECK_LIBSTDCXX_LIBS
|
||||
from check_helpers import CHECK_LIBSTDCXX_LIBS, CHECK_SYMBOL_LIBS
|
||||
|
||||
srcdir = sys.argv[1]
|
||||
base_srcdir = sys.argv[2]
|
||||
@@ -14,6 +14,7 @@ builddir = sys.argv[3]
|
||||
os.chdir(srcdir)
|
||||
|
||||
ldd = os.getenv("LDD", shutil.which("ldd"))
|
||||
readelf = os.getenv("READELF") or shutil.which("readelf") or shutil.which("llvm-readelf")
|
||||
if not ldd:
|
||||
otool = os.getenv("OTOOL", shutil.which("otool"))
|
||||
if otool:
|
||||
@@ -25,14 +26,22 @@ if not ldd:
|
||||
stat = 0
|
||||
tested = False
|
||||
|
||||
for soname in CHECK_LIBSTDCXX_LIBS:
|
||||
check_libs = CHECK_SYMBOL_LIBS
|
||||
if not readelf:
|
||||
check_libs = CHECK_LIBSTDCXX_LIBS
|
||||
|
||||
for soname in check_libs:
|
||||
for suffix in ["so", "dylib"]:
|
||||
so = os.path.join(builddir, "lib%s.%s" % (soname, suffix))
|
||||
if not os.path.exists(so):
|
||||
continue
|
||||
|
||||
print("Checking that we are not linking to libstdc++ or libc++ in %s" % so)
|
||||
ldd_result = subprocess.check_output(ldd.split() + [so])
|
||||
if readelf:
|
||||
dynamic = subprocess.check_output([readelf, "-d", so])
|
||||
ldd_result = b"\n".join(line for line in dynamic.splitlines() if b"(NEEDED)" in line)
|
||||
else:
|
||||
ldd_result = subprocess.check_output(ldd.split() + [so])
|
||||
if (b"libstdc++" in ldd_result) or (b"libc++" in ldd_result):
|
||||
print("Ouch, %s is linked to libstdc++ or libc++" % so)
|
||||
stat = 1
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
# harfbuzz-icu links to libstdc++ because icu does.
|
||||
# harfbuzz-icu links to libstdc++ because icu does, and harfbuzz-cairo links transitively
|
||||
# to libxml2 which on some platforms is also linked against icu
|
||||
CHECK_LIBSTDCXX_LIBS = [
|
||||
"harfbuzz",
|
||||
"harfbuzz-subset",
|
||||
"harfbuzz-raster",
|
||||
"harfbuzz-vector",
|
||||
"harfbuzz-gobject",
|
||||
"harfbuzz-cairo",
|
||||
]
|
||||
|
||||
CHECK_SYMBOL_LIBS = CHECK_LIBSTDCXX_LIBS + [
|
||||
"harfbuzz-cairo",
|
||||
"harfbuzz-icu",
|
||||
]
|
||||
Reference in new issue
Block a user