-
Notifications
You must be signed in to change notification settings - Fork 13.4k
OrcV2: also set COFF flag overrides when custom linking layer is used #129533
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
✅ With the latest revision this PR passed the C/C++ code formatter. |
(fixed formatting) |
A related question to @lhames: do you see any way to work around this issue using the C-API and configure OrcV2 so that it correctly sets these flags when using a custom linking layer? Thank you 🙇 |
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.
LGTM. These flags are hacks, but RTDyldObjectLinkingLayer won't be fixed and will be deprecated in the future. This is a good way to avoid them complicating the public API in the mean time.
If your fix is sufficient for you for now i'd prefer not to expose these flags through the C API as they're workarounds for deficiencies in our current implementation. The eventual hope is to remove them, but I'm busy with other tasks at the moment and don't have time to do this work at the moment. |
Great, thank you. Let's use this version then instead of adding bindings of those methods. Regarding the workaround: this is making a number of LLVM versions unusable for my project on Windows, so I was just wondering if you see some other way to set those flags that doesn't need changes in LLVM itself. (Maybe by creating a default linking layer and then retroactively applying the customization from the custom link layer) But I'm assuming it's not possible with the C API. Also: If/when |
I adapted the commit to address a merge conflict caused by conflicting changes on |
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.
Otherwise LGTM.
I think the LLVM change is the right way to go for now.
They will also be deprecated. There is no C API replacement for these yet. We'll need to implement new APIs for this. What customizations are you using? Do you need to control layout, or just find out where particular sections / symbols are? |
I need to control the layout. I am using These are entirely self-contained computational kernels that don't use any external functionality (e.g. from libc). |
@lhames: I incorporated the feedback but left in the |
This will be interesting. The Do you actually need to control where the JIT'd memory lives, or just its layout? I'm wondering if we could get by with a "SectionMerger" plugin that merges all blocks into a single section with |
Alternatively we could expose an API that allows you to merge simple |
I don't need control over the absolute address, just having a single section will be enough. A |
The other option honestly sounds fine as well :). The main requirement is that there is a way to pack code+data into a single section (no matter its absolute address), via the C API. |
Looks like this is causing crashes in MLIR. Unfortunately I don't have access to a Windows machine to debug these. |
I've asked the #mlir channel on Discord if they're able to reproduce. If you have a debug build handy you might be able to take a look too? The logs show an unhandled |
This reverts commit eecf6af.
@lhames Is it possible that removing the |
Dear @lhames, I was wondering what I could do to get this unblocked. Current LLVM builds crash with my project when used on Windows because of this issue. Does this current commit still crash in the MLIR test suite after I reverted the latest change? |
Hi Wenzel, Sorry for the late reply — I’ve been out on vacation since early April. I’m back next Monday and should be able to look into this later in the week. Thanks for your patience! |
Thank you @lhames, please let me know if I can help with anything. This specific fix aside, I am also wondering if we discuss (perhaps in a separate issue) a way to link into a flat buffer that has better long-term stability as the currently broken API is also on the way out. (You mentioned the following two potential paths that sound like they would work)
|
LLJIT's
LLJIT::createObjectLinkingLayer()
function sets theOverrideObjectFlagsWithResponsibilityFlags
andAutoClaimResponsibilityForObjectSymbols
flags when compiling on Windows, where the COFF format is internally usedllvm-project/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
Lines 962 to 965 in 9573c62
However, the implementation fails to do these flag assignments when the user has specified a linking layer.
llvm-project/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
Lines 953 to 954 in 9573c62
For applications that specify a custom linking layer, this makes LLVM unusable when using LLJIT through the C-API bindings on Windows, since
setOverrideObjectFlagsWithResponsibilityFlags
andsetAutoClaimResponsibilityForObjectSymbols
don't have C-API bindings and can therefore not be called to set these flags manually. In particular, theLLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks
linking layer is affected by this.This PR fixes the issue by inserting an additional check in the early exit branch to see if COFF is used, and if the created linking layer is/derives from
RTDyldObjectLinkingLayer
. In that case, those flags should also be set.cc @lhames @rtabbara @njroussel