Skip to content

Conversation

sebastiankreutzer
Copy link
Contributor

@sebastiankreutzer sebastiankreutzer commented Oct 28, 2024

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

@llvmbot llvmbot added clang Clang issues not falling into any other category compiler-rt clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' xray labels Oct 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 28, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Sebastian Kreutzer (sebastiankreutzer)

Changes

Compiling with -fxray-shared requires position-independent code.
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

Full diff: https://github.com/llvm/llvm-project/pull/113892.diff

2 Files Affected:

  • (modified) clang/test/Driver/XRay/xray-shared.cpp (-1)
  • (modified) compiler-rt/test/xray/TestCases/Posix/clang-xray-shared.cpp (+1-1)
diff --git a/clang/test/Driver/XRay/xray-shared.cpp b/clang/test/Driver/XRay/xray-shared.cpp
index 215854e1fc7cef..e331fefed1e0c9 100644
--- a/clang/test/Driver/XRay/xray-shared.cpp
+++ b/clang/test/Driver/XRay/xray-shared.cpp
@@ -1,6 +1,5 @@
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fpic -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s
-// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s
 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fno-PIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-PIC
 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fno-pic -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-PIC
 
diff --git a/compiler-rt/test/xray/TestCases/Posix/clang-xray-shared.cpp b/compiler-rt/test/xray/TestCases/Posix/clang-xray-shared.cpp
index 92f3c29e970d42..0dd721571de9b8 100644
--- a/compiler-rt/test/xray/TestCases/Posix/clang-xray-shared.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/clang-xray-shared.cpp
@@ -1,6 +1,6 @@
 // Test that the DSO-local runtime library has been linked if -fxray-shared is passed.
 //
-// RUN: %clangxx -fxray-instrument -fxray-shared %s -shared -o %t.so
+// 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

@sebastiankreutzer
Copy link
Contributor Author

@MatzeB

@sebastiankreutzer
Copy link
Contributor Author

@rupprecht If this looks good to you, could you commit it? I don't have write access.

@rupprecht rupprecht merged commit a388df7 into llvm:main Oct 29, 2024
13 checks passed
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
)

Compiling with `-fxray-shared` requires position-independent code
(introduced in llvm#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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category compiler-rt xray

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants