Hash :
77c24e8a
Author :
Date :
2025-05-06T13:17:13
[check-*.py] Remove autotoolism Instead of passing source dir and build dir to as envvars, pass them directly as script arguments. The scripts also were supposed to be able to run outsize of the build scripts, but this was broken since the fallback when the envvars were not set was wrong. The HBSOURCES and HBHEADERS are still passed as envvars since they are long lists and might hit command line length limitation on some systems.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
#!/usr/bin/env python3
import glob
import os
import re
import shutil
import subprocess
import sys
srcdir = sys.argv[1]
base_srcdir = sys.argv[2]
builddir = sys.argv[3]
objdump = os.getenv("OBJDUMP", shutil.which("objdump"))
if not objdump:
print("check-static-inits.py: 'ldd' not found; skipping test")
sys.exit(77)
if sys.version_info < (3, 5):
print("check-static-inits.py: needs python 3.5 for recursive support in glob")
sys.exit(77)
OBJS = glob.glob(os.path.join(builddir, "**", "*hb*.o"), recursive=True)
if not OBJS:
print("check-static-inits.py: object files not found; skipping test")
sys.exit(77)
stat = 0
tested = False
print("Checking that the following object files has no static initializers/finalizers")
print("\n".join(OBJS))
result = subprocess.run(
objdump.split() + ["-t"] + OBJS, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
if result.returncode:
if result.stderr.find(b"not recognized") != -1:
# https://github.com/harfbuzz/harfbuzz/issues/3019
print('objdump returned "not recognized", skipping')
else:
print("objdump returned error:\n%s" % (result.stderr.decode("utf-8")))
stat = 2
else:
tested = True
result = result.stdout.decode("utf-8")
# Checking that no object file has static initializers
for lib in re.findall(r"^.*\.[cd]tors.*$", result, re.MULTILINE):
if not re.match(r".*\b0+\b", lib):
print("Ouch, library has static initializers/finalizers")
stat = 1
# Checking that no object file has lazy static C++ constructors/destructors or other such stuff
if ("__cxa_" in result) and ("__ubsan_handle" not in result):
print(
"Ouch, library has lazy static C++ constructors/destructors or other such stuff"
)
stat = 1
sys.exit(stat if tested else 77)