0
0
mirror of https://github.com/llvm/llvm-project.git synced 2025-04-21 09:46:49 +00:00

[clang][cmake] Fix support for dynamic libraries in CLANG_BOLT

Simpler detection of dynamic library operands as the readelf one seems
to be unreliable (works on my setup, not on buildbots).

This is a follow-up to 
This commit is contained in:
serge-sans-paille 2025-03-03 18:04:13 +01:00
parent 86fc248ff6
commit f3d4d11547
No known key found for this signature in database
GPG Key ID: 7B24DA8C9551659F

@ -628,15 +628,14 @@ def bolt_optimize(args):
sys.stdout.write(line)
process.check_returncode()
output = subprocess.check_output(
[opts.readelf, "--file-header", input], universal_newlines=True
)
if re.search(r"Type:\s*((Shared)|(DYN))", output):
# force using the instrumented version
# Shared library must be preloaded to be covered.
if ".so" in input:
preloads.append(instrumented_output)
if preloads:
print("Patching execution environment for dynamic library")
print(
f"Patching execution environment for dynamic libraries: {' '.join(preloads)}"
)
environ["LD_PRELOAD"] = os.pathsep.join(preloads)
args = [