-
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
[CMake] [compiler-rt] fix architecture checks in runtime builds #66374
base: main
Are you sure you want to change the base?
[CMake] [compiler-rt] fix architecture checks in runtime builds #66374
Conversation
When Clang is built with libunwind as the default unwinder, the architecture support checks in compiler-rt fail during the runtime build because Clang can't link before libunwind is built. This commit fixes the checks by making them respect CMAKE_REQUIRED_FLAGS, a variable that contains linker arguments to disable the unwinder if necessary.
This is effectively the same problem that the Can you share more about your configuration that’s leading you to this failure? CMake has changed and evolved a lot since I wrote a lot of the hacky mess that drives this all, so some of these decisions should probably be revisited. |
set(SAVED_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${argstring}") | ||
try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE} | ||
COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS} ${FLAG_NO_EXCEPTIONS}" |
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.
This logic is already quite fragile so I'd prefer minimizing the changes. Could we just pass ${CMAKE_REQUIRED_FLAGS}
here instead?
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 think I tried, mirroring the code in CMake's implementation of check_cxx_source_compiles
, which passes the flags as compile definitions. There was some sort of problem, but I can't remember now what it was 🤔
Have you tried using |
There is actually code in
Sure. We build Clang and compiler-rt+libunwind via
I'm just a regular CMake user, not an expert 😢 What are the recent changes that would be useful in this context?
I think I shied away from it because we wanted to build the 32-bit runtimes as well. Is there a good way to achieve this with I should also say that we're hitting the limits of |
When Clang is built with libunwind as the default unwinder, the architecture support checks in compiler-rt fail during the runtime build because Clang can't link before libunwind is built. This commit fixes the checks by making them respect CMAKE_REQUIRED_FLAGS, a variable that contains linker arguments to disable the unwinder if necessary.