Skip to content

Commit f3d4d11

Browse files
[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 #127020
1 parent 86fc248 commit f3d4d11

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

clang/utils/perf-training/perf-helper.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,14 @@ def bolt_optimize(args):
628628
sys.stdout.write(line)
629629
process.check_returncode()
630630

631-
output = subprocess.check_output(
632-
[opts.readelf, "--file-header", input], universal_newlines=True
633-
)
634-
if re.search(r"Type:\s*((Shared)|(DYN))", output):
635-
# force using the instrumented version
631+
# Shared library must be preloaded to be covered.
632+
if ".so" in input:
636633
preloads.append(instrumented_output)
637634

638635
if preloads:
639-
print("Patching execution environment for dynamic library")
636+
print(
637+
f"Patching execution environment for dynamic libraries: {' '.join(preloads)}"
638+
)
640639
environ["LD_PRELOAD"] = os.pathsep.join(preloads)
641640

642641
args = [

0 commit comments

Comments
 (0)