-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[libunwind] Compile the asm as well as the C++ source #86351
Conversation
@llvm/pr-subscribers-libunwind Author: Jon Chesterfield (JonChesterfield) ChangesWhen a CMakeLists.txt is missing a 'project' statement you get the default supported languages of C and CXX. https://cmake.org/cmake/help/latest/command/project.html. The help says ASM should be listed last. CMake doesn't raise an error about the .S files it has been told about when project is missing. It silently ignores them. In this case, the symptom is an undefined symbol *jumpto in the library. Working theory for why this isn't more obviously broken everywhere is the 'runtimes' CMakeLists.txt does contain a 'project' statement which lists ASM and/or by default linking shared libraries with undefined symbols succeeds. The string immediately after project appears to be arbitrary, chosen 'Unwind' to match the capitalization of 'Runtimes'. For completeness, this also removes the following warning when building libunwind by itself: >CMake Warning (dev) in CMakeLists.txt: This gives no hint that the consequence of ignoring this warning is cmake will ignore your assembly. Full diff: https://github.com/llvm/llvm-project/pull/86351.diff 1 Files Affected:
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 806d5a783ec39c..01d3b72b73e842 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -3,6 +3,7 @@
#===============================================================================
cmake_minimum_required(VERSION 3.20.0)
+project(Unwind LANGUAGES C CXX ASM)
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
✅ With the latest revision this PR passed the Python code formatter. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
It might make sense to restore the |
I'm sorry to hear that. Reading through https://libcxx.llvm.org/BuildingLibcxx.html now to see if I can make ENABLE_RUNTIMES behave itself under cross compilation. I'm familiar with this in the context of the "bootstrapping" build from the docs, the build clang first one, which drops (most) arguments passed to cmake. Hopefully building runtimes directly doesn't involve that quirk. Building libunwind, then libc++, then libcxxabi to create three archives which are combined works on main at present as far as I can tell, provided one hacks around the missing asm files in libunwind. If we don't want to land this trivial patch, we should make the causal link between a missing symbol in a dynamic library which segv's on use and that the cmake invocation which used to work and still looks like it works much more obvious. Restoring the fatal error would be an improvement. |
Indeed, pointing cmake at I agree that it probably would be good to keep the error message explaining this, especially if it otherwise seems to almost work. |
I think I'm getting the behaviour I want out of the following incantation which does not require this patch. This doesn't attempt to build shared library versions which removes a bunch of failure modes.
|
When a CMakeLists.txt is missing a 'project' statement you get the default supported languages of C and CXX. https://cmake.org/cmake/help/latest/command/project.html. The help says ASM should be listed last.
CMake doesn't raise an error about the .S files it has been told about when project is missing. It silently ignores them. In this case, the symptom is an undefined symbol *jumpto in the library.
Working theory for why this isn't more obviously broken everywhere is the 'runtimes' CMakeLists.txt does contain a 'project' statement which lists ASM and/or by default linking shared libraries with undefined symbols succeeds.
The string immediately after project appears to be arbitrary, chosen 'Unwind' to match the capitalization of 'Runtimes'.
For completeness, this also removes the following warning when building libunwind by itself:
This gives no hint that the consequence of ignoring this warning is cmake will ignore your assembly.