Sebastian Kreutzer a388df7127
[XRay] Remove reliance on default PIC behavior in DSO tests (#113892)
Compiling with `-fxray-shared` requires position-independent code
(introduced in #113548).
Some tests do not explicitly specify this, thus falling back to the
compiler default.
If, for example, Clang is compiled with
`-DCLANG_DEFAULT_PIE_ON_LINUX=OFF`, these checks fail.

This patch addresses this issue in two tests:
- Removing a check in `xray-shared.cpp` that only tests default PIC
behavior
- Adding `-fPIC` explicitly in `clang-xray-shared.cpp`
2024-10-29 09:40:53 -05:00

15 lines
530 B
C++

// Test that the DSO-local runtime library has been linked if -fxray-shared is passed.
//
// RUN: %clangxx -fxray-instrument -fxray-shared -fPIC %s -shared -o %t.so
// RUN: llvm-nm %t.so | FileCheck %s --check-prefix ENABLED
// RUN: %clangxx -fxray-instrument %s -shared -o %t.so
// RUN: llvm-nm %t.so | FileCheck %s --check-prefix DISABLED
//
// REQUIRES: target=x86_64{{.*}}
[[clang::xray_always_instrument]] int always_instrumented() { return 42; }
// ENABLED: __start_xray_instr_map
// DISABLED-NOT: __start_xray_instr_map