llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.82k forks source link

cmake build with shared libs fails with undef symbols on ffi #49162

Open sylvestre opened 3 years ago

sylvestre commented 3 years ago
Bugzilla Link 49818
Version trunk
OS Linux
CC @stellaraccident,@Meinersbur,@LW-archlinux,@tambry,@serge-sans-paille,@sylvestre,@tstellar

Extended Description

On Debian (stable and oldstable):

cd "/build/llvm-toolchain-snapshot-13~++20210402115133+3b48d849d443/build-llvm/tools/llvm-shlib" && /tmp/cmake/bin/cmake -E cmake_link_script CMakeFiles/LLVM.dir/link.txt --verbose=1 /usr/lib/ccache/g++-6 -fPIC -g -O2 -fdebug-prefix-map=/build/llvm-toolchain-snapshot-13~++20210402115133+3b48d849d443=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -DNDEBUG -g1 -Wl,-rpath-link,/build/llvm-toolchain-snapshot-13~++20210402115133+3b48d849d443/build-llvm/./lib -Wl,-O3 -Wl,--gc-sections -latomic -Wl,-z,defs -Wl,-z,nodelete -shared -Wl,-soname,libLLVM-13.so.1 -o ../../lib/libLLVM-13.so.1 @​CMakeFiles/LLVM.dir/objects1.rsp @​CMakeFiles/LLVM.dir/objects2.rsp -Wl,-rpath,"\$ORIGIN/../lib" -Wl,--version-script,/build/llvm-toolchain-snapshot-13~++20210402115133+3b48d849d443/build-llvm/./lib/tools/llvm-shlib/simple_version_script.map -Wl,--whole-archive -Wl,--no-whole-archive -lrt -ldl -lm /usr/lib/i386-linux-gnu/libz.so /usr/lib/i386-linux-gnu/libtinfo.so -lpthread -ledit ../../lib/LTO/CMakeFiles/obj.LLVMLTO.dir/LTOBackend.cpp.o: In function RegisterPassPlugins': ./build-llvm/include/llvm/Support/Extension.def:2: undefined reference togetPollyPluginInfo()' ../../lib/Extensions/CMakeFiles/obj.LLVMExtensions.dir/Extensions.cpp.o: In function llvm::details::extensions_anchor()': ./build-llvm/include/llvm/Support/Extension.def:2: undefined reference togetPollyPluginInfo()' ../../lib/ExecutionEngine/Interpreter/CMakeFiles/obj.LLVMInterpreter.dir/ExternalFunctions.cpp.o: In function ffiTypeFor': ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:131: undefined reference toffi_type_sint64' ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:133: undefined reference to ffi_type_float' ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:134: undefined reference toffi_type_double' ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:135: undefined reference to ffi_type_pointer' ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:125: undefined reference toffi_type_void' ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:128: undefined reference to ffi_type_sint8' ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:129: undefined reference toffi_type_sint16' ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:130: undefined reference to ffi_type_sint32' ../../lib/ExecutionEngine/Interpreter/CMakeFiles/obj.LLVMInterpreter.dir/ExternalFunctions.cpp.o: In functionffiInvoke': ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:230: undefined reference to ffi_prep_cif' ./llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:235: undefined reference toffi_call' collect2: error: ld returned 1 exit status tools/llvm-shlib/CMakeFiles/LLVM.dir/build.make:4373: recipe for target 'lib/libLLVM-13.so.1' failed

with cmake ../llvm/ \ -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;compiler-rt;lld;debuginfo-tests;polly;openmp;lldb" \ -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-13 \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG -g1" \ -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_INSTALL_UTILS=ON \ -DLLVM_VERSION_SUFFIX= \ -DLLVM_ENABLE_SPHINX=ON \ -DSPHINX_WARNINGS_AS_ERRORS=OFF \ -DLLVM_ENABLE_RTTI=ON \ -DLLVM_ENABLE_FFI=ON \ -DLLVM_ENABLE_DUMP=ON \ -DPYTHON_EXECUTABLE=/usr/bin/python3 -DLIBOMP_LIBFLAGS="-latomic" -DCMAKE_SHARED_LINKER_FLAGS="-latomic" -DCLANG_SYSTEMZ_DEFAULT_ARCH=z196 -DLLVM_BINUTILS_INCDIR=/usr/include/ -DLLVM_USE_PERF=yes -DLLVM_ENABLE_LIBPFM=ON \ -DLIBCLANG_LIBRARY_VERSION=1 \ -DCLANG_LINK_CLANG_DYLIB=ON \ -DENABLE_LINKER_BUILD_ID=ON \ -DPOLLY_BUNDLED_JSONCPP=OFF \ -DCOMPILER_RT_USE_LIBCXX=NO \ -DLLVM_ENABLE_Z3_SOLVER=OFF \ -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="AVR" \ -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ -DCLANG_VENDOR=Debian \ -DCLANG_ENABLE_BOOTSTRAP=ON \ -DCLANG_BUILD_EXAMPLES=OFF \ -DLLVM_POLLY_LINK_INTO_TOOLS=ON \ -DBOOTSTRAP_CMAKE_CXX_FLAGS=' -fuse-ld=gold -fPIC -Wno-unused-command-line-argument -Wno-unknown-warning-option ' \ -DBOOTSTRAP_CMAKE_C_FLAGS=' -fuse-ld=gold -fPIC -Wno-unused-command-line-argument -Wno-unknown-warning-option ' \ -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_VERBOSE_MAKEFILE;CMAKE_BUILD_TYPE;CMAKE_CXX_FLAGS_RELWITHDEBINFO;LLVM_LINK_LLVM_DYLIB;LLVM_INSTALL_UTILS;LLVM_VERSION_SUFFIX;LLVM_ENABLE_SPHINX;SPHINX_WARNINGS_AS_ERRORS;LLVM_BUILD_LLVM_DYLIB;LLVM_ENABLE_RTTI;LLVM_ENABLE_FFI;LIBCLANG_LIBRARY_VERSION;ENABLE_LINKER_BUILD_ID;POLLY_BUNDLED_JSONCPP;LLVM_EXPERIMENTAL_TARGETS_TO_BUILD;LLVM_USE_PERF;LLVM_ENABLE_ASSERTIONS;LLVM_BINUTILS_INCDIR;LLVM_HOST_TRIPLE;LLVM_COMPILER_CHECKED;COMPILER_RT_BUILD_BUILTINS;LIBOMP_LIBFLAGS;CMAKE_SHARED_LINKER_FLAGS;PYTHON_EXECUTABLE;LLVM_ENABLE_Z3_SOLVER;LLVM_POLLY_LINK_INTO_TOOLS;CLANG_VENDOR"

Full log: https://llvm-jenkins.debian.net/job/llvm-toolchain-stretch-binaries/architecture=i386,distribution=stretch/2182/consoleFull

tambry commented 2 years ago

mentioned in issue llvm/llvm-bugzilla-archive#49843

tambry commented 3 years ago

Bug llvm/llvm-bugzilla-archive#49843 has been marked as a duplicate of this bug.

tstellar commented 3 years ago

Reverting https://reviews.llvm.org/D95727 fixed the problem

I have reverted this commit in main.

sylvestre commented 3 years ago

Reverting https://reviews.llvm.org/D95727 fixed the problem

Meinersbur commented 3 years ago

getPollyPluginInfo is from the statically linked plugin extensions that Polly uses to not require -load LLVMPolly.so every time. It should have been included into libLLVM.so as well. Adding @​serge-sans-paille to CC for this.

No idea about ffi.

POLLY_BUNDLED_JSONCPP is not used anymore. Instead, Polly uses LLVM's own JSON parser.