-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[libunwind] Don't override LINKER_LANGUAGE #143533
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
base: main
Are you sure you want to change the base?
Conversation
libunwind's GCC build fails because it tested `-nostdlib++` flag against C++ linker but then use C linker to perform final linking, while gcc doesn't support this flag but g++ does. The rationale for setting LINKER_LANGUAGE to C is to avoid pulling in C++ standard libraries. However this is already guaranteed by the combination of `-nostdlib++` and `empty CMAKE_CXX_IMPLICIT_LINK_LIBRARIES`, thus we can safely remove this override. However, in case `-nostdlib++` is unsupported, we need to use `-nodefaultlibs` and link against rtlib & libc manually.
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-libunwind Author: Jiaxun Yang (FlyGoat) Changeslibunwind's GCC build fails because it tested The rationale for setting LINKER_LANGUAGE to C is to avoid pulling in C++ standard libraries. However this is already guaranteed by the combination of However, in case Full diff: https://github.com/llvm/llvm-project/pull/143533.diff 1 Files Affected:
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 70bd3a017cda7..e83d11363f7e4 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -74,6 +74,9 @@ set(LIBUNWIND_SOURCES
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
add_link_flags_if_supported(-nostdlib++)
else()
+ if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
+ add_link_flags_if_supported(-nodefaultlibs)
+ endif()
if (LIBUNWIND_USE_COMPILER_RT)
add_library_flags("${LIBUNWIND_BUILTINS_LIBRARY}")
else()
@@ -164,7 +167,6 @@ set_target_properties(unwind_shared
PROPERTIES
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBUNWIND_ENABLE_SHARED}>,FALSE,TRUE>"
LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
- LINKER_LANGUAGE C
OUTPUT_NAME "${LIBUNWIND_SHARED_OUTPUT_NAME}"
VERSION "${LIBUNWIND_LIBRARY_VERSION}"
SOVERSION "1"
@@ -211,7 +213,6 @@ set_target_properties(unwind_static
PROPERTIES
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBUNWIND_ENABLE_STATIC}>,FALSE,TRUE>"
LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
- LINKER_LANGUAGE C
OUTPUT_NAME "${LIBUNWIND_STATIC_OUTPUT_NAME}"
)
|
@MaskRay Do you mind to help me merge once I get necessary approval? I’m not a commiter yet. |
Please rebase :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is required, or even works after #143162.
@philnik777 Sorry I wasn’t aware of that. However #143162 breaks my use case of bootstrapping libunwind with compiler-rt builtins from same runtime build. I’ll try to come up with a more comprehensive solution. |
libunwind's GCC build fails because it tested
-nostdlib++
flag against C++ linker but then use C linker to perform final linking, while gcc doesn't support this flag but g++ does.The rationale for setting LINKER_LANGUAGE to C is to avoid pulling in C++ standard libraries. However this is already guaranteed by the combination of
-nostdlib++
andempty CMAKE_CXX_IMPLICIT_LINK_LIBRARIES
, thus we can safely remove this override.However, in case
-nostdlib++
is unsupported, we need to use-nodefaultlibs
and link against rtlib & libc manually.Closes #98440