[cfe-users] Shared Debug Build MSYS2 MinGW-w64 constant Link Error

Oliver Niebuhr via cfe-users cfe-users at lists.llvm.org
Tue May 11 04:44:55 PDT 2021


Hello.

As Static Debug Builds only work with MSVC, I am forced to use 
Shared-Libs with GCC on MSYS2.

The Problem is, it always Fails at this exact stage:

FAILED: bin/BugpointPasses.dll
cmd.exe /C "cd . && C:\Dev\msys64\mingw64\bin\g++.exe -Wa,-mbig-obj 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess 
-Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -fasynchronous-unwind-tables 
-finput-charset=utf-8 -fno-lto -fno-omit-frame-pointer 
-grecord-gcc-switches -pthread -Og -g1 -ggdb -pipe -Wall -Wl,-Og 
-Wl,--allow-multiple-definition -Wl,--build-id=sha1 -Wl,--dynamicbase 
-Wl,--enable-auto-image-base -Wl,-fno-lto -Wl,--high-entropy-va 
-Wl,--nxcompat -Wa,-mbig-obj -Wl,-Bdynamic 
C:/Dev/Builds/LLVMx64DebugSrc/tools/bugpoint-passes/BugpointPasses.def 
-shared -o bin\BugpointPasses.dll 
-Wl,--major-image-version,0,--minor-image-version,0 
tools/bugpoint-passes/CMakeFiles/BugpointPasses.dir/TestPasses.cpp.obj 
lib/libLLVMCore.dll.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 
-lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/Dev/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: 
tools/bugpoint-passes/CMakeFiles/BugpointPasses.dir/TestPasses.cpp.obj: 
in function `llvm::CallBase::getNumSubclassExtraOperands() const':
C:/Dev/GitRepos/llvm-project/llvm/include/llvm/IR/InstrTypes.h:1198: 
undefined reference to `llvm::llvm_unreachable_internal(char const*, 
char const*, unsigned int)'
collect2.exe: error: ld returned 1 exit status

Sys Config:
* Windows 10 21H1, x86_64
* MSYS2, MinGW-w64, 10.3.0, x86_64
* CMake 3.20.2 MinGW-w64 prebuilt, x86_64
* Ninja 1.10.2 MinGW-w64 prebuilt, x86_64
* LLVM 12.x Git Source
* Building from MSYS2 MinGW64 Shell
* Static Release Builds of LLVM/Clang for x86 and x86_64 are working 
just fine

Latest CMake Config Flags tested:
cmake ${SYSTEMDRIVE}/Dev/GitRepos/llvm-project/llvm/ 
${SYSTEMDRIVE}/Dev/Builds/LLVMx64DebugSrc/ -G'Ninja' 
-DCMAKE_VERBOSE_MAKEFILE=ON 
-DCMAKE_C_FLAGS_DEBUG='-fasynchronous-unwind-tables 
-finput-charset=utf-8 -fno-lto -fno-omit-frame-pointer 
-grecord-gcc-switches -pthread -Og -g1 -ggdb -pipe -Wall -Wl,-Og 
-Wl,--allow-multiple-definition -Wl,--build-id=sha1-Wl,--dynamicbase 
-Wl,--enable-auto-image-base -Wl,-fno-lto -Wl,--high-entropy-va 
-Wl,--nxcompat -Wa,-mbig-obj -Wl,-Bdynamic' 
-DCMAKE_CXX_FLAGS_DEBUG='-fasynchronous-unwind-tables 
-finput-charset=utf-8 -fno-lto -fno-omit-frame-pointer 
-grecord-gcc-switches -pthread -Og -g1 -ggdb -pipe -Wall -Wl,-Og 
-Wl,--allow-multiple-definition -Wl,--build-id=sha1 
-Wl,--default-image-base-high -Wl,--dynamicbase 
-Wl,--enable-auto-image-base -Wl,-fno-lto -Wl,--high-entropy-va 
-Wl,--nxcompat -Wa,-mbig-obj -Wl,-Bdynamic' 
-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;compiler-rt;lld;lldb;llvm' 
-DCMAKE_CXX_STANDARD=17 
-DCMAKE_INSTALL_PREFIX=${SYSTEMDRIVE}/Dev/Binaries/LLVMx64Debug/ 
-DCMAKE_BUILD_TYPE='Debug' -DLLVM_TARGETS_TO_BUILD='X86' 
-DBUILD_SHARED_LIBS='ON' -DLLVM_INCLUDE_EXAMPLES='OFF' 
-DLLVM_INCLUDE_TESTS='OFF' -DLLVM_INCLUDE_DOCS='OFF' 
-DLLVM_PARALLEL_COMPILE_JOBS=$(nproc) -DLLVM_PARALLEL_LINK_JOBS=$(nproc) 
-DLLVM_ENABLE_EH='OFF' -DLLVM_ENABLE_RTTI='OFF' -DLLVM_ENABLE_DIA_SDK='OFF'

But that does only partially matter(?), because even with the DEFAULT 
FLAGS IT FAILS at this stage. So it seems I am missing something else. 
Another Compiler Flag? Another Linker Flag? General incompatibility?

Thanks in advance!
Olli


More information about the cfe-users mailing list