-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add imaging_mode support (static compilation) #125
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #125 +/- ##
==========================================
- Coverage 79.79% 71.63% -8.16%
==========================================
Files 22 22
Lines 1628 1590 -38
==========================================
- Hits 1299 1139 -160
- Misses 329 451 +122
Continue to review full report at Codecov.
|
Base PR has been merged; needs an update here? |
Yes indeed! How do you feel about me having the extra field in |
I'm not sure. It's not really a property of the source function, is it? Maybe an |
I combined these under the assumption that if you're emitting symbols, you probably want to be able to emit relocatable code for shared libraries (since we can actually do that now!). If you want them to be split concepts, how should |
9ab6adc
to
4d52463
Compare
I setup a few tests, although they won't get run unless you have a recent enough build of Julia. Some of them are skipped because they don't yet work with imaging mode (probably either bugs or missing functionality in Julia), but they should work eventually. |
Better make those a
Yeah I'm not sure, feel free to keep both aspects linked for now, it's not like GPUCompiler.jl has a stable API or anything 🙂 |
Unfortunately, the thing that's broken is that the IR gets generated just slightly wrong, so we just get a segfault 🙂
I definitely can separate them in the future, when users end up requesting the ability to differentiate. |
4d52463
to
b2524b5
Compare
Added an |
test/native.jl
Outdated
@test_skip ccall(generate_shlib_fptr(f5, ()), Symbol, ()) == :asymbol | ||
f6(x) = x == :asymbol ? true : false | ||
@test_skip ccall(generate_shlib_fptr(f6, (Symbol,)), Bool, (Symbol,), :asymbol) | ||
@test_skip !ccall(generate_shlib_fptr(f6, (Symbol,)), Bool, (Symbol,), :bsymbol) |
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.
At least one of these test should run in an external process.
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.
In reality, anything that relies on runtime calls/state should probably go through another process. I'll spool one up with Distributed and see how far I can get.
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.
This approach was very enlightening, if also unfortunate. I found that we still emit things like Symbols and some other objects as inttoptr
'd pointers. I'm going to have one of the simpler tests run on another process, but clearly there's still some extra work to be done.
b2524b5
to
4b3cf11
Compare
Should I gate Julia global externalization/internalization behind an interface function, or are we okay with keeping it as always-on? |
if LLVM.linkage(gbl) == LLVM.API.LLVMInternalLinkage && | ||
typeof(LLVM.initializer(gbl)) <: LLVM.PointerNull && | ||
(startswith(LLVM.name(gbl), "jl_global") || | ||
startswith(LLVM.name(gbl), "jl_sym")) |
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.
Why also jl_sym
, not just jl_global
(in a function that externalizes globals)?
Do we emit such globals in other scenarios? We're starting to have a lot of interface functions... |
@jpsamaroo what was the state of this, I'm thinking of rebasing it since it's the most common error we are hitting right now. |
Aside from this not actually switching on imaging mode (as I pointed out on Slack), I think this mostly was working. |
I think the issue that this is has is that it doesn't do the processing of the global variables. So you end up with uninitialized GVs and no way to know what's supposed to go in there? |
Even without global variables, seems like this could be useful for StaticCompiler if it lets us use more of libjulia! |
Requires JuliaLang/julia#38642
We can tell Julia that we want it to emit symbols instead of session-specific pointers, making our code (potentially) relocatable. I'm not locked in on this API, but it was pretty easy to implement. Known issues include
Symbol
s embedded in the IR; they show up as{}* null
in the LLVM IR for some reason. I've tested that I can roundtrip very simple functions (including closures) throughcodegen(:obj, ...)
+dlopen/dlsym
.