-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix compilation with LLVM 6.0.1 #6380
Conversation
But crystal builds on LLVM6 right now, and has done for months on archlinux. What changed? |
I'm not sure – have you tested with 6.0.1 on archlinux? I'll see if I still have 6.0.0 on my mac to compare. |
And none of the arch patches to LLVM 6.0.1 are to anything but the build system: https://git.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/llvm |
Did you remember to run |
I started with a clean slate, |
Btw. the patch also works against 0.25.1 and HEAD when compiling crystal with the homebrew formula and |
works for me. What's different between the homebrew and archlinux sources here? Is this platform-specific weirdness? I hope not. |
Maybe the symbols just don't clash on Linux. Linking on Darwin differs a fair bit from Linux. |
@RX14 If you like I can update the |
Hmm, this is kind of a chicken-egg problem. The ci script installs crystal from homebrew and then links the matching llvm version that the crystal formula depends on. In oder to fix that I should update the homebrew formula to build against llvm 6 and they will ask if the patch was upstreamed :-) What I could do is create a new PR in homebre-core that only updates the dependency but does not yet include the patch and wait for it to fail. Then I could point you at the homebrew-core jenkins build results and then push the patch in the homebrew formula in another commit to show if it fixes the build. |
Oh well, since @ilovezfs mentioned interest in bumping crystal's llvm dependency to 6.0 in comment Homebrew/homebrew-core#28930 (comment) of the 0.25.0 release discussion I might get it through. |
See also Homebrew/homebrew-core#29774 (comment) Same failure. |
Thanks for the link, that saves me some time. |
Same error happens on my macOS 10.12.6, building with the updated LLVM 6.0.1 from homebrew. With this PR, it builds, and then |
@matiasgarciaisaia do you get the same |
You don't need the CI to run on LLVM 6 to patch crystal to support LLVM 6 on osx |
No, only if you want to reproduce the compile error in the CI on macOS. |
Okay, I've looked into this a bit further and i'm okay with this patch. These calls can be replaced with their official counterparts but i'd rather merge a quickfix patch then one that uses the new llvm-c versions. My only feedback is to |
I did that at first, but then looked at I'm fine with either convention, but I think using two different naming schemes in the same file is confusing. |
Oh, and I think we should add I'll push an update for that shortly. |
This fixes symbol clashes with the LLVM C-API DebugInfo that was added in LLVM 6.0.
595fc48
to
070c766
Compare
@felixbuenemann it doesn't need to include |
and yes, if we already use the |
Too late :-( (regarding DebugInfo.h inclusion) Including the header allows us to spot conflicts like this easier, since they blow up at compile time instead of at link time. It would also have allowed to spot the error on Linux earlier where the symbols somehow didn't clash. If you still think it should be removed let me now and I'll revert to the previous version. |
if that's the case, we should include it in every LLVM version. |
The header was added in LLVM 6.0 so that will be very difficult to achieve ;-) In the future the bindings should probably be rewritten to use the new LLVM C DebugInfo API instead of the C++ bindings, but that would break backwards compatibility (or there would be two different implementations). |
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.
Sorry for my stupid suggestions, this is good as-is.
This is probably an acceptable quick fix, but since LLVM is adding C bindings for Debug Information, we should evolve our custom set of C++ to match the new API for older LLVM releases, so we don't break anything, and can move on. Hopefully dropping the custom C++ someday. |
@@ -56,14 +60,16 @@ LLVMDIBuilderRef LLVMNewDIBuilder(LLVMModuleRef mref) { | |||
return wrap(new DIBuilder(*m)); | |||
} | |||
|
|||
#if LLVM_VERSION_LE(5, 9) |
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.
Note: there won't be any 5.x other than 5.0. LE(5, 0)
is enough, no need to indroduce unknown version numbers :)
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.
Good catch, I just fixed this locally, but @RX14 merged in parallel before I pushed it.
I'll send a tiny new PR to fix it and reference it here.
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.
@RX14 @ysbaddaden I fixed this in #6383.
Indeed, this is a good quick fix but I'd love a patch which got the LLVM bindings in-sync. |
This fixes the following compile error on LLVM 6.0.1 (and 6.0.0):
Since the functions
LLVMDIBuilderCreateCompileUnit
andLLVMDIBuilderCreateFile
exist in LLVM 6.0, but have a much different signature, I chose to instead rename the conflicting methods by adding a "2" suffix, like already done forLLVMSetCurrentDebugLocation
.This is related to #5556.
I'm currently running into issue #6372 during
make spec
, but it also happens with LLVM 5.0.2.The specs pass fine if I apply the fix described in #6372 (comment).