CMakeLists.txt: fix linking with ld#12153
Conversation
|
Wait, zig also fails. |
Fix for the error below: ld: liblldELF.a(OutputSections.cpp.o): undefined reference to symbol 'deflate' ld: libz.so.1: error adding symbols: DSO missing from command line ld recently changed to only link with explicitly defined targets
|
OK, works for me :-) |
|
This change overlaps with #12136 , but I'm inclined to think this fix is better because it doesn't rely on llvm-config. The flaw with the other change is that when llvm-config corresponds to a shared-library (only) installation of LLVM, it will not report libz as a build-time dependency. It links to libz at run-time not build time. However, on some systems LLD is provided only as a static library which does need libz at build-time. As far as I know, there's no equivalent to |
|
Hi, Sorry, I was not aware of that PR. Are there any systems out there with On the other hand I hardly think of a system without |
|
Sorry, let me clarify: If your LLVM installation only includes shared libraries, "llvm-config --link-static --system-libs" fails. On the other hand, "llvm-config --link-shared --system-libs" always (correctly) reports no build-time link dependencies because for a shared library, The issue is that if LLD is being linked as a static library, it will have build-time dependencies (-lz) and llvm-config won't be able to report them. |
andrewrk
left a comment
There was a problem hiding this comment.
However, on some systems LLD is provided only as a static library which does need libz at build-time. As far as I know, there's no equivalent to llvm-config for LLD and it doesn't come with pkg-config files on my system either, so I think the best we can do is just hardcode this dependency.
Hmm I'm not satisfied with this. I'd like to work with upstream to solve this in a more satisfying way. Let's let this problem fester until we can get upstream to cooperate with us on helping downstream applications link properly.
In the meantime, building zig with everything static works fine. Let's coordinate with package maintainers and LLVM on getting system-integration working properly.
The root problem here is LLD not being provided as a dynamically linked library along with LLVM and Clang, would you agree?
|
I believe this has been addressed by #12136. |
|
No, #12136 does not fix this, at least not for me, but I understand that my solution is not the right one. Shall I open a bug report for this? |
|
Can you share what happens when you try to build master branch now? |
|
Here is my guix.scm, I run Next step: Build log: |
|
Hmm, for me the "Found llvm" part says: I'm not sure why yours does not have the system libs appended. Can you share the output of I would expect this to output can you share the output of this as well? |
|
I think I should not see those errors :-( |
|
I'm not sure we can solve this problem downstream; we are trying our best to learn what the system wants us to do, and the system is crapping its pants |
|
OK, thanks. |
Fix for the error below:
ld: liblldELF.a(OutputSections.cpp.o): undefined reference to symbol 'deflate'
ld: libz.so.1: error adding symbols: DSO missing from command line
ld recently changed to only link with explicitly defined targets