[llvm] [Bolt] Explicitly request PIE in tests (PR #108818)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 05:14:18 PDT 2024


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/108818

When clang is built with `-DCLANG_DEFAULT_PIE_ON_LINUX=OFF`, a number of bolt tests fail:

    BOLT :: AArch64/build_id.c
    BOLT :: AArch64/plt-call.test
    BOLT :: X86/dwarf5-dwarf4-types-backward-forward-cross-reference.test
    BOLT :: X86/dwarf5-locexpr-referrence.test
    BOLT :: X86/internal-call-instrument.s
    BOLT :: X86/linux-static-keys.s
    BOLT :: X86/plt-call.test

Avoid this by explicitly adding `-fPIE` and `-pie` to the default flags in tests, so we don't depend on the clang-side default.

>From 058c234d9cd8ba30f49c631c1d6ec2f34e723f2d Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Mon, 16 Sep 2024 14:11:51 +0200
Subject: [PATCH] [Bolt] Explicitly request PIE in tests

When clang is built with `-DCLANG_DEFAULT_PIE_ON_LINUX=OFF`, a
number of bolt tests fail:

    BOLT :: AArch64/build_id.c
    BOLT :: AArch64/plt-call.test
    BOLT :: X86/dwarf5-dwarf4-types-backward-forward-cross-reference.test
    BOLT :: X86/dwarf5-locexpr-referrence.test
    BOLT :: X86/internal-call-instrument.s
    BOLT :: X86/linux-static-keys.s
    BOLT :: X86/plt-call.test

Avoid this by explicitly adding `-fPIE` and `-pie` to the default
flags in tests, so we don't depend on the clang-side default.
---
 bolt/test/lit.local.cfg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bolt/test/lit.local.cfg b/bolt/test/lit.local.cfg
index 8aa5f15d5ccfb4..e2fa0a4a2210f6 100644
--- a/bolt/test/lit.local.cfg
+++ b/bolt/test/lit.local.cfg
@@ -1,6 +1,6 @@
 host_linux_triple = config.target_triple.split("-")[0] + "-unknown-linux-gnu"
-common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all"
-flags = f"--target={host_linux_triple} {common_linker_flags}"
+common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all -pie"
+flags = f"--target={host_linux_triple} -fPIE {common_linker_flags}"
 
 config.substitutions.insert(0, ("%cflags", f"%cflags {flags}"))
 config.substitutions.insert(0, ("%cxxflags", f"%cxxflags {flags}"))



More information about the llvm-commits mailing list