-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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][cmake] Compile _Unwind* routines with -fexceptions #121819
[libunwind][cmake] Compile _Unwind* routines with -fexceptions #121819
Conversation
Created using spr 1.3.6-beta.1
@llvm/pr-subscribers-libunwind Author: Paul Kirth (ilovepi) ChangesWhen building libunwind with LTO, we found that routines, like In #56825, it was pointed out that these C routines should be compiled Fixes #56825 #120657 Full diff: https://github.com/llvm/llvm-project/pull/121819.diff 1 Files Affected:
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index e7ea57734cca97..72dd3f5bca9960 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -20,7 +20,7 @@ set(LIBUNWIND_C_SOURCES
)
set_source_files_properties(${LIBUNWIND_C_SOURCES}
PROPERTIES
- COMPILE_FLAGS "-std=c99")
+ COMPILE_FLAGS "-std=c99 -fexceptions")
set(LIBUNWIND_ASM_SOURCES
UnwindRegistersRestore.S
|
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.
The second paragraph can mention _Unwind_Resume
explicitly.
@@ -20,7 +20,7 @@ set(LIBUNWIND_C_SOURCES | |||
) | |||
set_source_files_properties(${LIBUNWIND_C_SOURCES} | |||
PROPERTIES | |||
COMPILE_FLAGS "-std=c99") | |||
COMPILE_FLAGS "-std=c99 -fexceptions") |
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.
Can you also leave a comment here explaining why we need -fexceptions
?
Is there any known issue w/ the NDK 13 bot? The log cuts out midway through tests, so I assume this is some kind of timeout or another issue w/ the emulator. the complete log only shows some warnings when launching the emulator, but IDK if those are relevant. They seem benign to me, but I'm no expert. https://buildkite.com/llvm-project/libcxx-ci/builds/39796#01943d0f-1d31-4e60-a670-d2bc43adcd4e |
Created using spr 1.3.6-beta.1
llvm-project/libunwind/CMakeLists.txt Lines 249 to 252 in 59bdea2
I wonder if it would be less bug-prone in the long term to just build the whole library with |
This will break MinGW LTO libunwind. |
Can you clarify how? |
Maybe this is a hidden bug, but I haven't investigated it too deeply, @mstorsjo may know better. |
Sorry, no clue offhand here.
Perhaps this is a symbol which we need to implicitly mark as needed in the linker? Because before the LTO, I think it only sees a definition of this symbol, but nothing referencing it, so the LTO logic thinks it doesn't need to retain/expose this symbol - while after the LTO, the generated code does add new references to it. I don't find any precedence for doing this for LTO so far, but we have a couple cases of doing something similar for the regular GC in LLD.
It does add
|
I'm sorry, but this was caused by my own mistake: my modified clang++ wrapper has a -lc++abi, which I forgot what it was previously introduced to solve.
Should I open a new issue for this? Since it won't actually happen in reality unless libunwind does switch to use |
I think its fine to file an issue like this to track that we know this is a limitation. I'd just make it explicit that this is a potential issue for the future, and that would need to be addressed before we would make such a change. In my opinion discussions like this in a code review are a bit harder to find than a proper issue, and having an issue handy that points to this discussion is a good way to make sure we don't lose context. |
Created using spr 1.3.6-beta.1 [skip ci]
Created using spr 1.3.6-beta.1 [skip ci]
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1 [skip ci]
Are there lingering concerns here or are we OK landing this? |
Created using spr 1.3.6-beta.1
Hmm, the failing bot seems to be some kind of configuration error on the bot (or issue w/ the docker daemon?) https://github.com/llvm/llvm-project/actions/runs/12775719644/job/35614829092 |
Fix typo Co-authored-by: Petr Hosek <[email protected]>
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/149/builds/34 Here is the relevant piece of the build log for the reference
|
…121819) When building libunwind with LTO, we found that routines, like _Unwind_RaiseException were marked `nounwind`. This causes problems when libunwind is then used with exception throwing code, since many of the routines are marked `nounwind` and the compiler infers that something like a try/catch block cannot throw resulting in a miscompile (see llvm#120657). Similarly, in llvm#56825, it was pointed out that marking _Unwind_Resume as `nounwind` causes bad exception table generation. This patch adds the `-fexceptions` flag to the build of the C files that define these routines, as proposed in llvm#56825. Fixes llvm#56825 llvm#120657 --------- Co-authored-by: Petr Hosek <[email protected]>
See: llvm/llvm-project#121819 This fixes LTO for libunwind, so also re-enable support for that.
See: llvm/llvm-project#121819 This fixes LTO for libunwind, so also re-enable support for that. Closes ziglang#12828.
See: llvm/llvm-project#121819 This fixes LTO for libunwind, so also re-enable support for that. Closes ziglang#12828.
When building libunwind with LTO, we found that routines, like
_Unwind_RaiseException were marked
nounwind
. This causes problems whenlibunwind is then used with exception throwing code, since many of the
routines are marked
nounwind
and the compiler infers that somethinglike a try/catch block cannot throw resulting in a miscompile
(see #120657). Similarly, in #56825, it was pointed out that marking
_Unwind_Resume as
nounwind
causes bad exception table generation.This patch adds the
-fexceptions
flag to the build of the C files thatdefine these routines, as proposed in #56825.
Fixes #56825 #120657