-
Notifications
You must be signed in to change notification settings - Fork 205
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
[WIP] Support LLVM12 #503
[WIP] Support LLVM12 #503
Conversation
Ah, I'll put in some #ifs so that this only affects builds with LLVM12 |
Think I got the conditionals right to let it build correctly on appveyor with the older LLVM versions, and it still builds for me with LLVM12. |
For what it's worth, macOS with LLVM 12 built from source is giving me:
So I think we need a more sophisticated way to figure out when we need this. It may make sense to split out that aspect of the PR from the LLVM 12 parts. |
When I remove that, it builds, and
So that looks pretty good. I haven't taken a look at the specific tests to figure out what's going wrong there yet. |
Please note: I pushed a rebase to pick up some CI upgrades that should hopefully fix the compiler issues we were seeing. |
I was digging a bit more into why this patch works, given that it seemingly removes the As best I can tell, ORCv1 really is gone, along with Therefore, it seems that the removal of the call to Anyway, I guess it's fair game to use MCJIT since it's still around and LLVM has seen fit to maintain it for longer than its supposed replacement. But I think this does mean that at some point we need to go back to the ORC transition documents and take a harder look at what needs to be done. I don't think it'll be as easy as just adding or removing a function call. I'm fine with this PR as-is, because I still think it's progress, but note that because we're technically reverting to an older JIT, I'm not sure what issues might pop up that we (and the LLVM team at large) have likely been ignoring since version 5. Someone will actually need to look at the failing tests and figure out what's going on there. [1]: There are a couple of vestiges hanging around like the |
Just FYI, I reverted the CMake change since it's breaking in CI too (see here):
I think we're going to have to look into a separate flag, possibly |
Well, I've been playing around with my LLVM12 version and I was running into some weird, sporadic segfaults. Summary: Seems to have a problem passing structs by value IF the struct size is >128 bits
Causes the output:
I couldn't find any simple example of a runtime segfault when calling the function rather than compiling it, but I suspect the issue is related. I tried the binary release and it passes the test just fine, so I guess this is probably an incompatibility with LLVM12 |
To add on to my previous comment,
So, definitely something wrong going on with passing large structs by value. |
Are you saying the code generated by Terra is nondeterministic? That would definitely be bad, regardless of what exactly that generated code is. You might find it easier to verify with a |
Fixes "Attribute 'byval' type does not match parameter!" errors
Well! That was an adventure. I think I got it all figured out & fixed.
Heres a small test that I ran to check that the fix worked:
Terra Binary Release:
This branch now:
(Note the extra [1] golang/go#43870 |
Looks like this might have fixed the last few tests that were failing randomly too. Ran them all 5 times and no failures! |
I think something's missing an LLVM version bound. |
Just pushed it a bit hastily, wrong name for the attribute in the old LLVM. I might try to set up a docker container so I can test the older versions myself. |
Looks like LLVM 12 is unhappy again. If you want to try out Docker, this Dockerfile may help you get started. Though you will have to bump it up to Ubuntu 21.04 in order to get LLVM 12. https://github.com/terralang/terra/blob/master/docker/Dockerfile.ubuntu (I certainly agree it's faster to iterate this way than to push everything through CI, though I will keep approving runs on my end.) |
In case it was not noted, the CMake build was fine, it was just the regular Makefile that was causing problems... |
I don't object to the Makefile changes in principle, but it does seem to have messed something up in the Ubuntu 16.04/LLVM 3.8 case (and possible others, but the CI got killed before it checked the rest). So if there's a way to harmonize that better, I'd appreciate it. But we use |
Well, first off looks like no pushd/popd apparently on
More importantly, the linker output is indeed different, so I will have to add something to normalize it.
(which is what unpacklibraries.lua was relying on.) |
In case it helps, I think there was an attempt to fix this in #459 at some point, but I don't remember if anyone made an effort to make this fully backwards compatible with the old versions. |
Changes the way LLVM & Clang object files are detected & extracted in the default Makefile to handle a wider variety of linker `-t` output formats.
Hm... Not sure extracting all the static libs is necessarily a good idea. Looks like its failing because its never pulling in LLVMObjCARCOpts.a, which is on the linker command line, but the trace does not output it, so it does not get extracted into llvm_objects/ If you have any ideas let me know, otherwise I think I'm going to try reverting it back to the old method but with a special case for the new linker output. |
I think that's fine. My general attitude about the Makefile is that we need to not break it, but it doesn't need to be pretty. It's formally deprecated, and while it won't be going away any time soon, all new feature work/polish/cleanup beyond the bare minimum is going into CMake. So if there's a reasonable but slightly ugly solution for Make that gets us past this, I'd just go for it. |
I decided to go the other route of just including all the LLVM libs, which let me clean up some of the craziness that was going on. I'm guessing this will probably increase the binary size, since its no longer filtering out the libs it does not need, and it makes it required to link to libffi and libedit, but it seems like this is closer to what the CMake build is doing, and is a lot simpler of a solution. Removed the REEXPORT_LLVM_COMPONENTS option as well, since it shouldn't be necessary either as LLVM is included in its entirety always now. Let me know if you think thats too drastic, though to me it seems like a good way of supporting the Makefile builds easier going forward. |
Hm, looks like it needs libPolly. Oddly I didn't need that to build it with LLVM12. Polly is listed in the LLVMExports cmake file, not sure if theres a way to determine that with llvm-config. I'll be looking into it |
If it can be made to work I'm fine with this approach. |
Thanks so much for working on this and pushing it all the way through! I've gone ahead and merged the PR. |
My attempt at getting Terra to build with LLVM12 on ArchLinux.
On my machine at least, this works and it seems all the tests run successfully most of the time. A few tests seem to be segfaulting once every few runs:
Not sure what the implications are of removing the
setUseOrcMCJITReplacement
line (and theOrcMCJITReplacement.h
include), but it at least builds and runs!Have not tested any other OS, I'm not very experienced with CMake so I would appreciate any help if someone wants to try and make my CMakeLists.txt changes work across multiple OSes and/or make it still be compatible with older LLVM versions (Not sure the best way to test this myself)