Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang][test] Add fPIC when building shared library #80065

Merged
merged 1 commit into from
Jan 31, 2024
Merged

Conversation

jsji
Copy link
Member

@jsji jsji commented Jan 30, 2024

Fix linking error: "ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output"

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jan 30, 2024
@jsji jsji requested a review from ChuanqiXu9 January 30, 2024 21:43
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 30, 2024

@llvm/pr-subscribers-clang

Author: Jinsong Ji (jsji)

Changes

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

1 Files Affected:

  • (modified) clang/test/Interpreter/cxx20-modules.cppm (+2-2)
diff --git a/clang/test/Interpreter/cxx20-modules.cppm b/clang/test/Interpreter/cxx20-modules.cppm
index 2c6eba5255191..dfee828631e32 100644
--- a/clang/test/Interpreter/cxx20-modules.cppm
+++ b/clang/test/Interpreter/cxx20-modules.cppm
@@ -7,8 +7,8 @@
 //
 // RUN: %clang -std=c++20 %t/mod.cppm --precompile \
 // RUN:     -o %t/mod.pcm
-// RUN: %clang %t/mod.pcm -c -o %t/mod.o
-// RUN: %clang -shared %t/mod.o -o %t/libmod.so
+// RUN: %clang -fPIC %t/mod.pcm -c -o %t/mod.o
+// RUN: %clang -fPIC -shared %t/mod.o -o %t/libmod.so
 //
 // RUN: cat %t/import.cpp | env LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH \
 // RUN:     clang-repl -Xcc=-std=c++20 -Xcc=-fmodule-file=M=%t/mod.pcm \

@jsji jsji requested a review from jyu2-git January 30, 2024 21:43
@jsji jsji self-assigned this Jan 30, 2024
Copy link
Contributor

@jyu2-git jyu2-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing.

@jsji jsji merged commit b929be2 into llvm:main Jan 31, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants