-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add option for the behavior of __register_frame/__deregister_frame in ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp #43419
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
Comments
*** Bug llvm/llvm-bugzilla-archive#47799 has been marked as a duplicate of this bug. *** |
I extended the patch to modify llvm/lib/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.cpp following a suggestion from Lang Hames. |
I don't see anywhere to upload the patch as an attachment. diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake +/* Define if LLVM libunwind is used for ExecutionEngine. / diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.cpp -#ifdef APPLE template Error registerEHFrameSection(const void *EHFrameSectionAddr, Error deregisterEHFrameSection(const void *EHFrameSectionAddr, -#ifdef APPLE+#if defined(APPLE) || (EXECUTION_ENGINE_USE_LLVM_UNWINDER == 1) |
Can we make this patch depends on '-DCLANG_DEFAULT_UNWINDLIB="libunwind"', |
CLANG_DEFAULT_UNWINDLIB is for the clang being built, not the clang used for the build. The compiler used for the build does not even need to be clang. What we can do is detect whether libunwind is used by looking to see whether __unw_add_dynamic_fde/__unw_remove_dynamic_fde is defined. I'm testing a patch that does that. |
Patch up for review at https://reviews.llvm.org/D106129. |
I've approved Harald's patch. Longer term I think we should revisit the dynamic registration APIs in libunwind to see if we can come up with something universal, but this seems like a good interim solution. If anyone wants this urgently there may still be time to request that it be cherry-picked to the LLVM 13 release branch. Otherwise it will be in LLVM 14. |
Peter S. Housel's patch https://reviews.llvm.org/D108081 touches on this issue as well. Maybe the best option, since we control libunwind, would be to add a symbol to that that could be used to identify it at runtime (if there isn't one already). Then we could dynamically choose the correct behavior based on the presence/absence of that symbol? |
If we make sure to add that symbol at the same time that we add support to libunwind for calling __register_frame with the same arguments as libgcc's, we could do this statically, even. I think changing libunwind is covered by bug 47750, so we can close this one. |
Hi Harald, I think this may have broken exceptions on one of the Darwin bots: It's hard to be certain though -- the bot was failing with other errors when you first committed the change. Would you mind if I temporarily reverted it to see if the bot goes green again? |
Alternatively we could change the check to #if defined(HAVE_UNW_ADD_DYNAMIC_FDE) || defined(APPLE) until we can narrow this down further. |
#if defined(HAVE_UNW_ADD_DYNAMIC_FDE) || defined(APPLE) looks good to me, that effectively reverts the patch for Apple platforms while leaving it in place for non-Apple platforms, that gives time to get a better idea of what's going on and how to come up with a better fix. |
Put up for review as https://reviews.llvm.org/D108511. I am testing locally to double check that this still works on my system, but whether it fixes it on the bot is something we will only see after pushing. |
It does, so if that is okay with you, please approve and I'll push. |
mentioned in issue llvm/llvm-bugzilla-archive#47799 |
What's the longer term should be, I am still facing this issue |
can __unw_add_dynamic_fde be detected in runtime instead of compile time? |
Extended Description
I use the full set of libraries from LLVM working under Linux with no dependency of gcc. While making use of LLVM MCJIT, I observed that there would be an error message from
LLVMRunFunction
,libunwind: __unw_add_dynamic_fde: bad fde: FDE is really a CIE
By searching LLVM source code, I got two facts as follows.
__unw_add_dynamic_fde()
inlibunwind/src/libunwind.cpp
.llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
, it is assumed that the behavior of__register_frame
/__deregister_frame
from libunwind depends on OS. It is checked by#ifdef __APPLE__
.libunwind, however, is actually a runtime shared library chosen at compile time. For example, it can be specified to use libgcc or libunwind according to the build option
CLANG_DEFAULT_UNWINDLIB
. It's true that the native libunwind on macOS is from LLVM, and on Linux it is from gcc. But this does not prevent programs for macOS from using the set of runtime libraries from gcc, and vice versa.I have made a fix by adding a new cmake option
EXECUTION_ENGINE_USE_LLVM_UNWINDER
. My suggested patch is as attached.The text was updated successfully, but these errors were encountered: