JLang
JLang copied to clipboard
LLVM-6.0 support
Hi,
Is there any way to build the JLang project using LLVM-6.0?
I'm using JLang to generate LLVM IR out of java files. And I use the Java LLVM IR files for downstream tasks.
The problem is that I'm using some other tools that are compatible with LLVM-6.0. As a result, almost all of the .ll files generated by JLang are rejected by the other tools. This is because the other tools do not support LLVM-5.0 but JLang only uses LLVM-5.0. JLang raises an error if any other version of LLVM is used:
LLVM version is out of date (or too new)
Any help is greatly appreciated.
Hi,
Thanks for your interest! At the moment we only support LLVM 5.0, but there is no fundamental reason for that.
We use Java shims for the LLVM C API that JLang uses to generate the LLVM code. Currently those shims are generated from the LLVM-5.0 API and thus produce code compatible w/ that version of LLVM.
No one is, at the moment, working on updating these shims or their use in the JLang compiler. Likely we would have to change some of the compiler code to match new signatures, etc. but I don't think we're using any functionality that is specific to 5.0.
As far as I know (without having looked too hard) there's also no nice way to do this generically across LLVM versions and so any efforts on our end to do this would likely target newer versions of LLVM rather than 6.0.
If you're interested in working on 6.0 compatibility then I could certainly give pointers as to what steps would need to be taken.
Another option is installing LLVM-5.0 on your system ONLY as a dependency for JLang. If you plan to use the generated *.ll files with other LLVM tools - those files are possibly compatible for LLVM 6.0 use. I can't promise that will work, but it might!
Drew, Thanks for your reply. I've already installed llvm-5.0 and produced llvm ir via JLang. but those *.ll files were not compatible with other llvm-based tools. I've tried this. That's why I asked for the support of newer version of LLVM.
I mentioned LLVM-6.0 because this is the closest version to version 5.0. Obviously. targeting newer versions of llvm, like 10.0 is really great and helpful. I mentioned 6.0 because I thought perhaps the update steps would be more straightforward and doesn't require heavy modifications and edits.
Ah I see - yeah I haven't looked too closely at the API changes so I'm not sure how big a difference 6 vs 10 really is.
There isn't anyone actively working on JLang updates here (beyond bug fixes) at the moment so I can't promise a timeline or anything, but I'll create a ticket that outlines the work needed and if someone gets around to it we'll certainly let you know.
Thanks. Drew, since you are an expert in this area, do you have any recommendations on generating LLVM IR for java programs? I searched a lot in this area to try different tools, but so far I found JLang is the only viable option.
The main tools I've heard of are JITs rather than ahead-of-time and also proprietary -- see Azul's Falcon compiler.
Most other efforts I know of go the other way -> allowing LLVM-based native code to run on a language VM (e.g, GraalVM).
I believe that's part of the reason that JLang was started originally - a surprising dearth of artifacts in this area!
Sorry I couldn't be more helpful.
@tehranixyz You can use llvm-as of LLVM 5.0 to transform the generated .ll file to llvm-5.0 bitcode which is supported in any version of LLVM after 5.0, the reason is LLVM keeps backward compatibility of bitcode format.