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
ORC cannot run initializers with non-void signatures #54797
Comments
@llvm/issue-subscribers-orcjit |
Thanks @hahnjo! I've committed a fix in a76209c. The aim is to move to to the ORC Runtime for running initializers in the future, and the ORC runtime should be able to match the behavior of the dynamic loaders (cast initializer address to |
@lhames as far as I can tell, you only committed the diff that I put above, that I could have done myself. However, as also noted above, this doesn't work if the constructor takes arguments so now it will crash in a different place. Regarding the question if that is valid, it's currently accepted by both Clang and GCC so there may be code using it. In fact, Clang's CUDA support generates constructors taking an argument - I'll have to see today if that can be removed. |
Yes, if registered via #include <stdio.h>
__attribute__((constructor))
static void constructor(int argc, char *argv[], char *envp[]) {
printf("arguments:\n");
for (int i = 0; i < argc; i++) {
printf(" %s\n", argv[i]);
}
printf("\nenvironment:\n");
while (*envp != NULL) {
printf(" %s\n", *envp);
envp++;
}
}
int main() {
return 0;
} We don't need that for CUDA, so I'm proposing to remove the argument in https://reviews.llvm.org/D123370. |
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
Interesting. I haven't come across this before. Updating the LLJIT "Generic Platform" support to do this is probably awkward but doable. If you don't need it (and nobody else has asked for it) I'm not sure it's worth the effort for now, but if you'd like to tackle it the right place to look would be in Doing this in the ORC runtime should be more natural, and it's the right long term place to implement this. I think we could leave this bug open to track implementing this in the ORC runtime. |
I've just committed e4903d8 to avoid this situation with CUDA. We'll go with this solution for Cling, so we don't have a requirement for it. I agree that this should be kept open until this is implemented somewhere when / if need arises. |
@llvm/issue-subscribers-clang-codegen |
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm/llvm-project#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
This works around a bug + missing support in ORC for constructors with non-void signatures (llvm#54797). Also submitted upstream, see https://reviews.llvm.org/D123370
Consider the following program in C:
or the (stripped down) version in LLVM IR:
When trying to run with
lli --jit-kind=orc constructor.min.ll
, there is a segmentation fault because thellvm::Function *
and its type are null pointers. This is because theCtorDtorIterator
inExecutionUtils.cpp
expects anotherConstantExpr
in the first operand of a cast, that could be fixed as follows:However, then an assertion trips because the code expects to call a function without parameters:
This at least matches MCJIT:
@lhames
The text was updated successfully, but these errors were encountered: