This is an archive of the discontinued LLVM Phabricator instance.

Fix build of llvm-cfi-verify on mingw32
AbandonedPublic

Authored by vchuravy on Mar 19 2018, 4:16 PM.

Details

Reviewers
dschuff
skatkov
Summary

While cross-compiling LLVM for MINGW32 I am running into the following
issue:

../../lib/libLLVMSymbolize.a(Symbolize.cpp.obj):Symbolize.cpp:(.text+0x840):
multiple definition of `llvm::symbolize::LLVMSymbolizer::flush()'
../../lib/libLLVM.dll.a(d023843.o):(.text+0x0): first defined here
../../lib/libLLVMMC.a(MCContext.cpp.obj):MCContext.cpp:(.text+0x6300):
multiple definition of `llvm::MCContext::~MCContext()'
../../lib/libLLVM.dll.a(d023604.o):(.text+0x0): first defined here
../../lib/libLLVMSupport.a(CommandLine.cpp.obj):CommandLine.cpp:(.text+0x0):
multiple definition of `llvm::cl::GenericOptionValue::anchor()'
../../lib/libLLVM.dll.a(d015473.o):(.text+0x0): first defined here

Which appears because llvm-cfi-verify is build both against the
libLLVM.a.dll and transient dependencies:

cat tools/llvm-cfi-verify/CMakeFiles/llvm-cfi-verify.dir/link.txt
/usr/local/bin/cmake -E remove -f
CMakeFiles/llvm-cfi-verify.dir/objects.a
/opt/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-ar cr
CMakeFiles/llvm-cfi-verify.dir/objects.a
@CMakeFiles/llvm-cfi-verify.dir/objects1.rsp
/opt/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-g++ -m64
-D__USING_SJLJ_EXCEPTIONS__ -D__CRT__NO_INLINE__ -Wa,-mbig-obj
-Werror=date-time -std=gnu++11 -Wall -W -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic
-Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
-Wno-comment  -O2 -DNDEBUG   -Wl,--stack,16777216 -Wl,--whole-archive
CMakeFiles/llvm-cfi-verify.dir/objects.a -Wl,--no-whole-archive  -o
../../bin/llvm-cfi-verify.exe
-Wl,--out-implib,../../lib/libllvm-cfi-verify.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
@CMakeFiles/llvm-cfi-verify.dir/linklibs.rsp

cat tools/llvm-cfi-verify/CMakeFiles/llvm-cfi-verify.dir/linklibs.rsp
../../lib/libLLVM.dll.a ../../lib/libLLVMCFIVerify.a
../../lib/libLLVMSymbolize.a ../../lib/libLLVMDebugInfoDWARF.a
../../lib/libLLVMDebugInfoPDB.a ../../lib/libLLVMObject.a
../../lib/libLLVMMCParser.a ../../lib/libLLVMMC.a
../../lib/libLLVMBitReader.a ../../lib/libLLVMCore.a
../../lib/libLLVMBinaryFormat.a ../../lib/libLLVMDebugInfoCodeView.a
../../lib/libLLVMDebugInfoMSF.a ../../lib/libLLVMSupport.a -lpsapi
-lshell32 -lole32 -luuid -ladvapi32 ../../lib/libLLVMDemangle.a
-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32
-luuid -lcomdlg32 -ladvapi32

We can avoid this mess by passing in DISABLE_LLVM_LINK_LLVM_DYLIB to
add_llvm_tool

Diff Detail

Event Timeline

vchuravy created this revision.Mar 19 2018, 4:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2019, 10:58 AM

Is this OK to land?

Shouldn't instead LLVMCFIVerify be declared using add_llvm_library with the proper dependency on the add_llvm_tool line. It seems like the problem might just be mixing the llvm and the cmake variant of these commands.

vchuravy added a project: Restricted Project.Jan 14 2020, 1:31 AM