I’m currently having issues trying to rebuild one of my projects with an updated version of LLVM. This project generates a statically linked binary.
My previous build used llvm-10.0.0 and I could build the binary without any issues. When I checked out HEAD a few weeks ago (commit 82fbc5d) and tried a build, it failed with the following linking error:
I haven’t changed my CMakeLists.txt file, and I’m lost as to how to fix this issue. Any help would be appreciated. For reference, my CMakeLists.txt file as as follows:
— BEGIN CMakeLists.txt —
set(LLVM_LINK_COMPONENTS support)
add_clang_executable(mybinary
)
set (GCC_COMPILE_FLAGS “-O3”)
set (GCC_LINK_FLAGS “-static”)
set (CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} ${GCC_COMPILER_FLAGS}”)
set (CMAKE_EXE_LINKER_FLAGS “${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS}”)
This can be an issue of the CMake module called by find_package(ZLIB)
As a workaround, -DLLVM_ENABLE_ZLIB=off, but some zlib features will be
disabled (clang -gz, ld.lld's ability to read/write compressed debug sections).
Here my notes are:
-Others were getting somewhere else such errors too and were equally puzzled
-I wonder if llvm.lld could be even nicer in saying something like:
“When trying to statically link with options , dynamic object was found on a chain due to options <either explicit so mention or offending -llibname etc>, please consider switching to dynamic link with or using static version of ”
-If above is too much, entry in documentation and url to article could be good enough as second line of error message.
Pawel
sob., 8.05.2021, 04:50 użytkownik Danie Grobbelaar via llvm-dev <llvm-dev@lists.llvm.org> napisał:
On the one after patched cmake script i would wonder if You could try to bisect-find command line option(s) causing libz.so and libtinfo.so getting included anyway. It could be maybe -lpthreads or some other -l having libz.so in its dependencies. If you try this youll likely get unresolved symbols but dont worry from -lpthread or some other -l but libz.so and libtinfo.so references includer(s) would get found in this way. Then i would try to replace these ones referencing libz.so and libtinfo.so with ones that reference static versions of those. Hope this helps a little.
Pawel
wt., 11.05.2021, 07:05 użytkownik Danie Grobbelaar via llvm-dev <llvm-dev@lists.llvm.org> napisał: