llvm / llvm-project

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

[TableGen] Fix llvm-tblgen library structure #80647

Closed Pierre-vh closed 7 months ago

Pierre-vh commented 9 months ago

llvm/utils/TableGen has a weird library structure, and it's not the first time a seemingly innocent change triggers linker errors in some build bots. I'm often unable to reproduce such errors locally, so I wonder if they only happen in some configurations, or when using gcc?

In any case, that library is due for a clean-up I believe. Helpers are mixed with backends, some files are ad-hoc placed into other targets because they have unit tests, etc. It may be a good idea to simply have two folders: one for the backends, and one for all helpers associated with the backends.

I had to revert https://github.com/llvm/llvm-project/commit/cfa0833ccc7450a322e709583e894e4c96ce682e because of these issues. This should re-land when fixed.

MaskRay commented 9 months ago

Did you still have the linker error (before the revert bb2008767d02edd4ccd017c92e9cc11d409a98e9), which can be shared for this issue ?

Pierre-vh commented 8 months ago
FAILED: lib/libLLVMTableGenGlobalISel.so.19git 
: && /usr/bin/clang++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=mold -Wl,--color-diagnostics   -Wl,--gc-sections -shared -Wl,-soname,libLLVMTableGenGlobalISel.so.19git -o lib/libLLVMTableGenGlobalISel.so.19git utils/TableGen/GlobalISel/CMakeFiles/obj.LLVMTableGenGlobalISel.dir/CodeExpander.cpp.o utils/TableGen/GlobalISel/CMakeFiles/obj.LLVMTableGenGlobalISel.dir/CombinerUtils.cpp.o utils/TableGen/GlobalISel/CMakeFiles/obj.LLVMTableGenGlobalISel.dir/CXXPredicates.cpp.o utils/TableGen/GlobalISel/CMakeFiles/obj.LLVMTableGenGlobalISel.dir/MatchDataInfo.cpp.o utils/TableGen/GlobalISel/CMakeFiles/obj.LLVMTableGenGlobalISel.dir/PatternParser.cpp.o utils/TableGen/GlobalISel/CMakeFiles/obj.LLVMTableGenGlobalISel.dir/Patterns.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/worker/buildbot-aarch64/bolt-aarch64-ubuntu-clang-shared/build/lib:"  lib/libLLVMTableGen.so.19git  lib/libLLVMSupport.so.19git  -Wl,-rpath-link,/home/worker/buildbot-aarch64/bolt-aarch64-ubuntu-clang-shared/build/lib && :
mold: error: undefined symbol: llvm::CodeGenIntrinsic::CodeGenIntrinsic(llvm::Record*, std::vector<llvm::Record*, std::allocator<llvm::Record*> >)
>>> referenced by PatternParser.cpp
>>>               utils/TableGen/GlobalISel/CMakeFiles/obj.LLVMTableGenGlobalISel.dir/PatternParser.cpp.o:(llvm::gi::PatternParser::parseInstructionPattern(llvm::Init const&, llvm::StringRef))
mold: error: undefined symbol: llvm::CodeGenTarget::ReadInstructions() const
>>> referenced by PatternParser.cpp
>>>               utils/TableGen/GlobalISel/CMakeFiles/obj.LLVMTableGenGlobalISel.dir/PatternParser.cpp.o:(llvm::CodeGenTarget::getInstruction(llvm::Record const*) const)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
12.199 [298/1/12] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/GlobalISelCombinerEmitter.cpp.o

https://lab.llvm.org/buildbot/#/builders/221/builds/21556

Note that there is a patch (#80847) that I started to fix this class of issue for good within TableGen source.