-
Notifications
You must be signed in to change notification settings - Fork 102
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
Creating a binary that links against Julia #511
Comments
You'd probably need to use Julia as dependency. There is a builder in Yggdrasil, but it probably works for a handful of platforms and it's for Julia 1.0.3. In general, if you're looking for a builder you should checkout Yggdrasil, and contribute there a new one |
That Julia builder looks like it builds another copy of Julia, though? That's not sufficient; it is vital to link against the same Julia that is loading "my" binary. Yggdrasil looks like it doesn't play with the current release of BinaryBuilder (0.1.4) though, or does it? |
Yeah, sorry, forgot to reply on this. Yggdrasil is using |
Why is that, exactly? We're using those binaries to build the C++ part of CxxWrap, and since it is using dynamic linking it works fine with libjulia 1.0 - 1.3, even if at compile time only the 1.0 version was available. |
Sorry, with "link" I was referring to "dynamic link at runtime", not "creating the binary during the build stage". I didn't realize that I could use that "Julia builder" and then later on link against the actual "main" Julia. If that's possible, then this does again sound like a potentially viable venue -- thank you for the hint! I'll take a look at how CxxWrap does it. However, we do use APIs that only were added in Julia 1.1 (via a PR by us), so we need that at the latest. We also access relatively low-level parts of the GC directly, so the question is whether that part of the ABI stayed compatible from Julia 1.1 to 1.2 resp. 1.3. |
All in all, I am still very much confused what version of |
The latest stable version is very old and almost no one is using it. The code on
Most of the new development happened in PR #441, but after that PR has been merged the code has been quite stable. Many of the changes that we had since then are about tweaking CI in Yggdrasil and don't affect users.
Yes, as long as you're willing to use Julia 1.3.0-rc4 or later. |
Yes, updating the builder to get all the new point releases in should fix that. I'm kind of surprised we didn't hit problems yet with CxxWrap, so I'd probably also use the updated versions when available just to be safe. |
Is there a way to specify multiple versions in a builder? Or does this require duplicating the builder (possible with an include to reduce code duplication)? I noticed that the Julia builder has lots of commented out dependencies. Wonder what the story is there... |
I think the best way would be to sequentially generate new versions of the builder, the JLL packages that are generated are versioned and can be referred to by version in the A nice overview of the new system is here: https://julialang.org/blog/2019/11/artifacts |
Ok, that sounds interesting - but is it limited to Julia 1.3, or available in 1.1 & 1.2? |
As far as I understand, you can build the 1.1 and 1.2 binaries on Yggdrasil, but you will need to manually add a build.jl to download them on those versions, since it seems the new BinaryBuilder doesn't generate the build.jl anymore. The generated files end up in a repository in https://github.com/JuliaBinaryWrappers |
Note that I actually need this for specific Julia versions; experimentally, binaries using some of the lower level Julia "APIs" (they are not really official APIs, I am afraid, just internal parts of the Julia kernel) seem to differ enough at times to make a binary built against, say, Julia 1.2 crash with 1.3 and vice versa. |
So it seems @barche solved this for CxxWrap for now by using That's an interesting approach, and I will try it out. Though it won't solve my use case completely (at least not with extra effort, as there the Julia version also affects my binaries... Perhaps I can solve this by downloading and installing multiple Julia versions when building, and then building my package N times, once for each supported Julia version, and bundling this together into one binary blob... (I won't really need N versions of the code, luckily: all but one C/C++ source file are independent of the Julia version; I could link them all in a single shared library, and then have N shared libs which have the Julia version as part of their SONAME, and which contain the code from that one remaining C file, plus a link to the shared lib with everything else). Of course that also means I have to make sure to quickly update it when new (major) Julia releases are made... sigh A simpler variant would be to make a binary build which only consists of this shared library that links in all but one file; and then compile that one file on the user's machine. Alas, if I do that, I really could just as well compile everything on the user's machine, and don't both with a binary builder, as the time savings would be minuscule (the whole project compilers in 20-30 seconds on a semi-current laptop), and all the hassle with building on the user's machine would still be there, and it's not really more or less work with 1 vs. 100 C files... |
Just BTW, we have a Julia_jll now. |
Thanks for the heads up (though I was aware already). Unfortunately it does not yet solve the issue for me, as there are binary incompatibilities in the low-level Julia kernel "interface" between e.g. Julia 1.2 and 1.3 (I have not yet tested with 1.3 vs. 1.4). To be clear: I put "interface" in quotation part because what we use is not really part of any official Julia kernel API/ABI, I think, so I want to stress that this is not a complaint, merely an observation -- but the thing is, we are using the Julia GC instead of our own GC for this project (to facilitate better integration of Julia and GAP objects) and thus e.g. need to interact with TLS. So it's not surprising somewhere something in the Julia kernel changes from time to time that means we have to recompile. On the upside, the code which depends on Julia is restricted to a single C source file with just ~1000 lines of text (including comments), so it's not too bad. I've even thought about just recompiling that file -- but then the user still needs a working C compiler and Julia header files, so not that much is gained... sigh Anyway, that means that using Julia_jll is not quite enough for us -- we'd still need a way to make the JLL choose the dylib it loads not just on the arch, but also on the version of Julia (and of course then we also need to build the relevant binaries against each supported Julia version). That should be doable with a customized version of the code generating JLLs (I don't think it'd be useful for the general public, so I don't think trying to get this into BinaryProvider/BinaryBuilder/Yggdrasil would make sense). Alternatively (and preferably), perhaps we can figure out a way to avoid or workaround this binary incompatibility; but for that, we first need to figure out what exactly causes it, something I simply didn't get around yet (it wasn't very important given that even knowing it would not have solved anything; but now that Julia_jll is there, it is of interest again). Perhaps @rbehrends can help me with that. |
@fingolfin is your issue not solved by creating a build recipe that links against a particular version of Julia, then building that recipe for all versions of Julia_jll? (Right now that only includes 1.4, but it will soon contain 1.5) E.g. you can have a |
Yes that ought to work. I wasn't aware this was possible |
@staticfloat I have two questions on this (well, probably more once I actually try doing it):
|
Note that the
|
Any particular reason why I'll look into make a PR for BinaryBuilder.jl then. BTW, we figured out what causes the dependency on the specific Julia version in our C code (which was written to integrate with the Julia GC): Unfortunately we need to access part of Julia's TLS, and the members of |
Nope, do whatever makes the most sense to you.
Yep, that seems like the proper fix. |
I've submitted JuliaLang/julia#36064 with the accessor functions. Any feedback welcome. I'll now look into adding Julia versioning to BinaryBuilder |
We have |
For various reasons, I need to create a binary build for a binary that links against Julia resp.
libjulia
(to interact with the Julia GC, but that should be irrelevant). This requires Julia >= 1.2My problem is that in the build environment, there is no Julia installed, and in particular no Julia headers, so I can't do that. Is there any way around this? I realize this is probably a relatively rare thing to do, so perhaps BinaryBuilder does not cover it yet? If it does not, is there are at least principle interest in supporting this? (If so, I'd be inclined to try and help implement it).
Not sure if it is relevant, but note that I am currently using BinaryBuilder 0.1.4, because that's the version being shipped. But I see that there are tons of changes in this repository compared to that, which makes me wonder what I should be using.
The text was updated successfully, but these errors were encountered: