-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
separate codegen/LLVM from julia runtime #41936
Conversation
391ac75
to
b6d788f
Compare
a548597
to
d1ab429
Compare
@JeffBezanson are you intending to expose something more flexible, like a CLI flag, to disable loading codegen? |
That would be fine, it's just a bit tricky since when the loader runs we haven't looked at the command line arguments yet. We'd have to figure out how to reorganize things a bit. |
5a6a960
to
f560696
Compare
Will dynamic dispatch still work when we just have the runtime available? |
Yes, that is implemented in the runtime. The only parts of the language that actually need the compiler are ccall, cfunction and llvmcall. |
What's the size of the runtime? If Signatures are known, can those features be precompiled? |
9de0059
to
bda2232
Compare
On my system:
but if you
Yes, those features can be precompiled in a system image. |
What does this mean for the functionality that will be available if someone uses the runtime-only part? Will it mean you can't use packages that wrap C libraries? Or would those libraries work if they are pre-compiled still? |
Anything precompiled will work. |
For call and maybe cfunction libffi might provide an LLVM less solution |
7590b7e
to
6975337
Compare
We are; I guess command line options are handled in libLLVMSupport? |
CI is also now failing on macOS due to a conflict between this PR and the update to LLVM: https://build.julialang.org/#/builders/63/builds/4301 |
As Valentin said, we are loading (initializing?) LLVM twice somehow (and only ASAN complains this somehow?). I think I can dig into it this weekend (though I'm not the most efficient person for debugging this). |
one possible solution is to detect if it is loaded twice: diff --git a/cli/loader_lib.c b/cli/loader_lib.c
index abc144c41c..81bb25062d 100644
--- a/cli/loader_lib.c
+++ b/cli/loader_lib.c
@@ -197,6 +197,11 @@ __attribute__((constructor)) void jl_load_libjulia_internal(void) {
// Unpack our special library names. This is why ordering of library names matters.
libjulia_internal = load_library(special_library_names[0], lib_dir, 1);
+
+ void (*pZN4llvm2cl22ResetCommandLineParserEv)(void) = (void (*)(void))lookup_symbol(libjulia_internal, "_ZN4llvm2cl22ResetCommandLineParserEv");
+ if (pZN4llvm2cl22ResetCommandLineParserEv)
+ pZN4llvm2cl22ResetCommandLineParserEv();
+
void *libjulia_codegen = load_library(special_library_names[1], lib_dir, 0);
const char * const * codegen_func_names;
if (libjulia_codegen == NULL) {
@@ -219,7 +224,7 @@ __attribute__((constructor)) void jl_load_libjulia_internal(void) {
}
// jl_options must be initialized very early, in case an embedder sets some
// values there before calling jl_init
- ((void (*)())jl_init_options_addr)();
+ ((void (*)(void))jl_init_options_addr)();
for (unsigned int symbol_idx=0; codegen_func_names[symbol_idx] != NULL; ++symbol_idx) {
void *addr = lookup_symbol(libjulia_codegen, codegen_func_names[symbol_idx]); |
I've opened an issue to track progress on fixing the |
Git bisect blames this commit:
for this ICE while building
Maybe this is a bug in my gcc, or a function of compiler flags somehow? |
@chriselrod Can you open a new issue? |
Done: #42588. |
re-implement ccall via libffi maybe a nice move. I tried Julia 1.8.0 (2021-12-06) Commit 30fe8cc*, and found there exists such a dependency chain: LinearAlgebra --> Linearlibblastrampoline_jll --> OpenBLAS_jll --> ccall --> compiler which makes LLVM a must-have library at runtime. |
There is no plausible reason for this. And indeed, this patch fixes compilation for the libjulia_jll builder on Yggdrasil which currently fails due to the absence of libssp. The removed line was introduced in PR JuliaLang#41936 but without any justification that I could discern, so it might have just slipped in there accidentally.
There is no plausible reason for this. And indeed, this patch fixes compilation for the libjulia_jll builder on Yggdrasil which currently fails due to the absence of libssp. The removed line was introduced in PR #41936 but without any justification that I could discern, so it might have just slipped in there accidentally.
separate libjulia-internal and libjulia-codegen makes codegen optional via a plugin interface Add special `@` character to `LOADER_BUILD_DEP_LIBS` and friends This allows us to mark a library as `"special"` so that the loader doesn't attempt to open it blindly, but rather interprets it as a list of positional arguments, that it knows how to interpret. We strictly require exactly the number of special libraries, to help avoid errors in the future as we add to this list. Strip windows runtime symbols from the windows import library Without stripping these symbols out of the import library, we end up with duplicate symbol definition errors. Co-authored-by: Julian Samaroo <[email protected]> Co-authored-by: Elliot Saba <[email protected]>
There is no plausible reason for this. And indeed, this patch fixes compilation for the libjulia_jll builder on Yggdrasil which currently fails due to the absence of libssp. The removed line was introduced in PR JuliaLang#41936 but without any justification that I could discern, so it might have just slipped in there accidentally.
separate libjulia-internal and libjulia-codegen makes codegen optional via a plugin interface Add special `@` character to `LOADER_BUILD_DEP_LIBS` and friends This allows us to mark a library as `"special"` so that the loader doesn't attempt to open it blindly, but rather interprets it as a list of positional arguments, that it knows how to interpret. We strictly require exactly the number of special libraries, to help avoid errors in the future as we add to this list. Strip windows runtime symbols from the windows import library Without stripping these symbols out of the import library, we end up with duplicate symbol definition errors. Co-authored-by: Julian Samaroo <[email protected]> Co-authored-by: Elliot Saba <[email protected]>
There is no plausible reason for this. And indeed, this patch fixes compilation for the libjulia_jll builder on Yggdrasil which currently fails due to the absence of libssp. The removed line was introduced in PR JuliaLang#41936 but without any justification that I could discern, so it might have just slipped in there accidentally.
This is a follow-up to #39129. The current state of the PR is that by default, everything works as normal, except during the build we generate both libjulia-internal (which does not link against LLVM) and libjulia-codegen (which does). The loader attempts to load libjulia-codegen after libjulia-internal. If that fails, it populates the codegen entry points with fallbacks in libjulia-internal that do nothing. That means you can simply delete libjulia-codegen, start with --compile=no, and enjoy a compiler-free julia runtime (assuming you don't actually need the compiler of course 😄 ).
This probably still needs a bunch of cleanup, and it also tends to segfault with --compile=no, which I assume can be fixed.
All in all, the loader framework we have is quite a nice way to separate the system into multiple optional components, and I foresee doing more of that. The parser and front-end would be another logical component to separate (and then ultimately replace with a new implementation written in julia and separately compiled!). It would be nice if we could streamline adding plugins a bit --- naturally, we thought the loader would only ever load one thing, so a few too many places need to be modified to add another.