llvm / llvm-project

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

`tblgen-to-irdl` fails to build on windows with LLVM_LINK_LLVM_DYLIB=ON #90881

Open Zentrik opened 6 months ago

Zentrik commented 6 months ago

Looks similar to #58015. I'm pretty sure this is due to LLVM_LINK_LLVM_DYLIB=ON and/or LLVM_BUILD_LLVM_DYLIB=ON but I've hade some trouble getting stuff working locally to test if removing those fixes it. This is using mignw.

Here's the error, full log is at https://buildkite.com/julialang/yggdrasil/builds/9311#018e9ae4-d493-4cd6-b026-ea88ed882b02.

ninja: job failed: : && /opt/bin/x86_64-w64-mingw32-libgfortran5-cxx11/x86_64-w64-mingw32-clang++ --target=x86_64-w64-mingw32 --sysroot=/opt/x86_64-w64-mingw32/x86_64-w64-mingw32/sys-root/ -remap -D__USING_SJLJ_EXCEPTIONS__ -D__CRT__NO_INLINE -pthread -DMLIR_CAPI_ENABLE_WINDOWS_DLL_DECLSPEC -fvisibility-inlines-hidden -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Werror=mismatched-tags -O3 -DNDEBUG -Wl,--stack,16777216    -Wl,--gc-sections tools/mlir/tools/tblgen-to-irdl/CMakeFiles/tblgen-to-irdl.dir/tblgen-to-irdl.cpp.obj tools/mlir/tools/tblgen-to-irdl/CMakeFiles/tblgen-to-irdl.dir/OpDefinitionsGen.cpp.obj -o bin/tblgen-to-irdl.exe -Wl,--out-implib,lib/libtblgen-to-irdl.dll.a -Wl,--major-image-version,0,--minor-image-version,0  lib/libLLVMTableGen.a  lib/libLLVMTableGen.a  lib/libMLIRIR.a  lib/libMLIRIRDL.a  lib/libMLIRTblgenLib.a  lib/libMLIRSupport.a  lib/libMLIRDialect.a  lib/libMLIRInferTypeOpInterface.a  lib/libMLIRSideEffectInterfaces.a  lib/libMLIRIR.a  lib/libMLIRSupport.a  lib/libLLVM.dll.a  lib/libLLVMTableGen.a  lib/libLLVMSupport.a  -lpsapi  -lshell32  -lole32  -luuid  -ladvapi32  -lws2_32  /workspace/destdir/lib/libz.dll.a  lib/libLLVMDemangle.a  lib/libMLIRTableGen.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && :
ld.lld: error: duplicate symbol: llvm::cl::parser<long long>::parse(llvm::cl::Option&, llvm::StringRef, llvm::StringRef, long long&)
>>> defined at libLLVMSupport.a(CommandLine.cpp.obj)
>>> defined at libLLVM.dll

ld.lld: error: duplicate symbol: llvm::cl::basic_parser_impl::getOptionWidth(llvm::cl::Option const&) const
>>> defined at libLLVMSupport.a(CommandLine.cpp.obj)
>>> defined at libLLVM.dll
ld.lld: error: duplicate symbol: llvm::cl::basic_parser_impl::printOptionInfo(llvm::cl::Option const&, unsigned long long) const
>>> defined at libLLVMSupport.a(CommandLine.cpp.obj)
>>> defined at libLLVM.dll
makslevental commented 6 months ago

Try setting

  "-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON",
  "-DCMAKE_C_VISIBILITY_PRESET=hidden",
  "-DCMAKE_CXX_VISIBILITY_PRESET=hidden",
Zentrik commented 6 months ago

Hmm, that seems to have caused llvm to stop building on all platforms. On windows it fails before getting to tblgen-to-irdl with various errors, the first few are

ninja: job failed: : && /opt/bin/x86_64-w64-mingw32-libgfortran5-cxx11/x86_64-w64-mingw32-clang++ --target=x86_64-w64-mingw32 --sysroot=/opt/x86_64-w64-mingw32/x86_64-w64-mingw32/sys-root/ -remap -D__USING_SJLJ_EXCEPTIONS__ -D__CRT__NO_INLINE -pthread -DMLIR_CAPI_ENABLE_WINDOWS_DLL_DECLSPEC -fvisibility-inlines-hidden -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -O3 -DNDEBUG -Wl,--stack,16777216    -Wl,--gc-sections tools/sanstats/CMakeFiles/sanstats.dir/sanstats.cpp.obj -o bin/sanstats.exe -Wl,--out-implib,lib/libsanstats.dll.a -Wl,--major-image-version,0,--minor-image-version,0  lib/libLLVM-18jl.dll.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && :
clang-16: warning: argument unused during compilation: '-remap' [-Wunused-command-line-argument]
ld.lld: error: undefined symbol: llvm::cl::getGeneralCategory()
>>> referenced by tools/sanstats/CMakeFiles/sanstats.dir/sanstats.cpp.obj:(llvm::cl::opt<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, false, llvm::cl::parser<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>::opt<llvm::cl::FormattingFlags, llvm::cl::NumOccurrencesFlag, llvm::cl::desc>(llvm::cl::FormattingFlags const&, llvm::cl::NumOccurrencesFlag const&, llvm::cl::desc const&))
>>> referenced by tools/sanstats/CMakeFiles/sanstats.dir/sanstats.cpp.obj:(llvm::cl::opt<bool, false, llvm::cl::parser<bool>>::opt<char [9], llvm::cl::initializer<bool>, llvm::cl::desc, llvm::cl::cat>(char const (&) [9], llvm::cl::initializer<bool> const&, llvm::cl::desc const&, llvm::cl::cat const&))

ld.lld: error: undefined symbol: llvm::cl::Option::addArgument()
>>> referenced by tools/sanstats/CMakeFiles/sanstats.dir/sanstats.cpp.obj:(llvm::cl::opt<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, false, llvm::cl::parser<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>::opt<llvm::cl::FormattingFlags, llvm::cl::NumOccurrencesFlag, llvm::cl::desc>(llvm::cl::FormattingFlags const&, llvm::cl::NumOccurrencesFlag const&, llvm::cl::desc const&))
>>> referenced by tools/sanstats/CMakeFiles/sanstats.dir/sanstats.cpp.obj:(llvm::cl::opt<bool, false, llvm::cl::parser<bool>>::opt<char [9], llvm::cl::initializer<bool>, llvm::cl::desc, llvm::cl::cat>(char const (&) [9], llvm::cl::initializer<bool> const&, llvm::cl::desc const&, llvm::cl::cat const&))

ld.lld: error: undefined symbol: llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long long, unsigned long long)
>> referenced by tools/sanstats/CMakeFiles/sanstats.dir/sanstats.cpp.obj:(llvm::cl::opt<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, false, llvm::cl::parser<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>::opt<llvm::cl::FormattingFlags, llvm::cl::NumOccurrencesFlag, llvm::cl::desc>(llvm::cl::FormattingFlags const&, llvm::cl::NumOccurrencesFlag const&, llvm::cl::desc const&))
>>> referenced by tools/sanstats/CMakeFiles/sanstats.dir/sanstats.cpp.obj:(llvm::cl::opt<bool, false, llvm::cl::parser<bool>>::opt<char [9], llvm::cl::initializer<bool>, llvm::cl::desc, llvm::cl::cat>(char const (&) [9], llvm::cl::initializer<bool> const&, llvm::cl::desc const&, llvm::cl::cat const&))

All logs at https://buildkite.com/julialang/yggdrasil/builds/10220#_.