This is an archive of the discontinued LLVM Phabricator instance.

`Debug` (but not `Release`): error: undefined reference to `ThreadPlanCallFunctionUsingABI` ctor && `ThreadPlanCallUserExpression` ctor
ClosedPublic

Authored by jankratochvil on Feb 2 2020, 6:32 AM.

Details

Summary

On Fedora 30 x86_64 with

time cmake ../llvm-monorepo/llvm/ -DCMAKE_BUILD_TYPE=Debug  -DLLVM_USE_LINKER=gold -DLLVM_ENABLE_PROJECTS="lldb;clang;lld"  -DLLVM_USE_SPLIT_DWARF=ON -DCMAKE_C_COMPILER=clang  -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_ASSERTIONS=ON

getting:

lldb/source/Expression/IRInterpreter.cpp:1471: error: undefined reference to 'lldb_private::ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI(lldb_private::Thread&, lldb_private::Address const&, llvm::Type&, llvm::Type&, llvm::ArrayRef<lldb_private::ABI::CallArgument>, lldb_private::EvaluateExpressionOptions const&)'
lldb/source/Expression/LLVMUserExpression.cpp:148: error: undefined reference to 'lldb_private::ThreadPlanCallUserExpression::ThreadPlanCallUserExpression(lldb_private::Thread&, lldb_private::Address&, llvm::ArrayRef<unsigned long>, lldb_private::EvaluateExpressionOptions const&, std::shared_ptr<lldb_private::UserExpression>&)'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

When I do a Release build I do not get this error. This linking commands fails:

(cd /home/jkratoch/redhat/llvm-monorepo-clangassertdebug/tools/lldb/unittests/DataFormatter;/usr/lib64/ccache/clang++   -fPIC -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 -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -g   -fuse-ld=gold -Wl,-allow-shlib-undefined CMakeFiles/LLDBFormatterTests.dir/FormatManagerTests.cpp.o  -o LLDBFormatterTests ../../../../lib/libLLVMSupport.a ../../../../lib/libLLVMSupport.a -lpthread ../../../../lib/libgtest_main.a ../../../../lib/libgtest.a -lpthread ../../../../lib/liblldbCore.a ../../../../lib/liblldbInterpreter.a ../../../../lib/liblldbSymbol.a ../../../../lib/liblldbTarget.a ../../../../lib/liblldbUtility.a -lpthread ../../../../lib/liblldbBreakpoint.a ../../../../lib/liblldbDataFormatters.a ../../../../lib/liblldbExpression.a ../../../../lib/liblldbPluginCPlusPlusLanguage.a ../../../../lib/liblldbPluginObjCLanguage.a ../../../../lib/liblldbCommands.a ../../../../lib/liblldbPluginExpressionParserClang.a ../../../../lib/liblldbPluginProcessUtility.a ../../../../lib/liblldbPluginObjectFileJIT.a ../../../../lib/liblldbPluginClangCommon.a ../../../../lib/liblldbPluginCPPRuntime.a ../../../../lib/liblldbPluginTypeSystemClang.a ../../../../lib/liblldbPluginAppleObjCRuntime.a ../../../../lib/liblldbPluginObjCRuntime.a ../../../../lib/liblldbPluginRenderScriptRuntime.a ../../../../lib/liblldbPluginSymbolFileDWARF.a ../../../../lib/liblldbPluginSymbolFilePDB.a ../../../../lib/liblldbPluginSymbolFileNativePDB.a ../../../../lib/liblldbCore.a ../../../../lib/liblldbInterpreter.a ../../../../lib/liblldbSymbol.a ../../../../lib/liblldbTarget.a ../../../../lib/liblldbBreakpoint.a ../../../../lib/liblldbDataFormatters.a ../../../../lib/liblldbExpression.a ../../../../lib/liblldbPluginCPlusPlusLanguage.a ../../../../lib/liblldbPluginObjCLanguage.a ../../../../lib/liblldbCommands.a ../../../../lib/liblldbPluginExpressionParserClang.a ../../../../lib/liblldbPluginProcessUtility.a ../../../../lib/liblldbPluginObjectFileJIT.a ../../../../lib/liblldbPluginClangCommon.a ../../../../lib/liblldbPluginCPPRuntime.a ../../../../lib/liblldbPluginTypeSystemClang.a ../../../../lib/liblldbPluginAppleObjCRuntime.a ../../../../lib/liblldbPluginObjCRuntime.a ../../../../lib/liblldbPluginRenderScriptRuntime.a ../../../../lib/liblldbPluginSymbolFileDWARF.a ../../../../lib/liblldbPluginSymbolFilePDB.a ../../../../lib/liblldbPluginSymbolFileNativePDB.a ../../../../lib/liblldbCore.a ../../../../lib/liblldbInterpreter.a ../../../../lib/liblldbSymbol.a ../../../../lib/liblldbTarget.a ../../../../lib/liblldbBreakpoint.a ../../../../lib/liblldbDataFormatters.a ../../../../lib/liblldbExpression.a ../../../../lib/liblldbPluginCPlusPlusLanguage.a ../../../../lib/liblldbPluginObjCLanguage.a ../../../../lib/liblldbCommands.a ../../../../lib/liblldbPluginExpressionParserClang.a ../../../../lib/liblldbPluginProcessUtility.a ../../../../lib/liblldbPluginObjectFileJIT.a ../../../../lib/liblldbPluginClangCommon.a ../../../../lib/liblldbPluginCPPRuntime.a ../../../../lib/liblldbPluginTypeSystemClang.a ../../../../lib/liblldbPluginAppleObjCRuntime.a ../../../../lib/liblldbPluginObjCRuntime.a ../../../../lib/liblldbPluginRenderScriptRuntime.a ../../../../lib/liblldbPluginSymbolFileDWARF.a ../../../../lib/liblldbPluginSymbolFilePDB.a ../../../../lib/liblldbPluginSymbolFileNativePDB.a ../../../../lib/liblldbCore.a ../../../../lib/liblldbInterpreter.a ../../../../lib/liblldbSymbol.a ../../../../lib/liblldbTarget.a ../../../../lib/liblldbBreakpoint.a ../../../../lib/liblldbDataFormatters.a ../../../../lib/liblldbExpression.a ../../../../lib/liblldbPluginCPlusPlusLanguage.a ../../../../lib/liblldbPluginObjCLanguage.a ../../../../lib/liblldbCommands.a ../../../../lib/liblldbPluginExpressionParserClang.a ../../../../lib/liblldbPluginProcessUtility.a ../../../../lib/liblldbPluginObjectFileJIT.a ../../../../lib/liblldbPluginClangCommon.a ../../../../lib/liblldbPluginCPPRuntime.a ../../../../lib/liblldbPluginTypeSystemClang.a ../../../../lib/liblldbPluginAppleObjCRuntime.a ../../../../lib/liblldbPluginObjCRuntime.a ../../../../lib/liblldbPluginRenderScriptRuntime.a ../../../../lib/liblldbPluginSymbolFileDWARF.a ../../../../lib/liblldbPluginSymbolFilePDB.a ../../../../lib/liblldbPluginSymbolFileNativePDB.a -lcurses /usr/lib64/libform.so /usr/lib64/libpanel.so ../../../../lib/liblldbBase.a ../../../../lib/libLLVMMCJIT.a ../../../../lib/libLLVMExecutionEngine.a ../../../../lib/libLLVMRuntimeDyld.a ../../../../lib/libclangCodeGen.a ../../../../lib/libLLVMCoroutines.a ../../../../lib/libLLVMCoverage.a ../../../../lib/libLLVMLTO.a ../../../../lib/libLLVMObjCARCOpts.a ../../../../lib/libLLVMPasses.a ../../../../lib/libLLVMipo.a ../../../../lib/libLLVMLinker.a ../../../../lib/libLLVMInstrumentation.a ../../../../lib/libLLVMVectorize.a ../../../../lib/libLLVMCodeGen.a ../../../../lib/libLLVMBitWriter.a ../../../../lib/libLLVMScalarOpts.a ../../../../lib/libLLVMAggressiveInstCombine.a ../../../../lib/libLLVMInstCombine.a ../../../../lib/libclangRewriteFrontend.a ../../../../lib/libclangRewrite.a ../../../../lib/libclangFrontend.a ../../../../lib/libclangDriver.a ../../../../lib/libLLVMOption.a ../../../../lib/libclangParse.a ../../../../lib/libclangSerialization.a ../../../../lib/libclangSema.a ../../../../lib/libclangEdit.a ../../../../lib/libclangAnalysis.a ../../../../lib/libclangASTMatchers.a ../../../../lib/libLLVMTarget.a ../../../../lib/libLLVMIRReader.a ../../../../lib/libLLVMAsmParser.a ../../../../lib/liblldbHost.a /usr/lib64/libedit.so /usr/lib64/liblzma.so /usr/lib64/libedit.so /usr/lib64/liblzma.so ../../../../lib/libLLVMDebugInfoDWARF.a ../../../../lib/liblldbUtility.a /usr/lib64/libxml2.so ../../../../lib/libclangAST.a ../../../../lib/libLLVMFrontendOpenMP.a ../../../../lib/libLLVMTransformUtils.a ../../../../lib/libLLVMAnalysis.a ../../../../lib/libLLVMProfileData.a ../../../../lib/libclangLex.a ../../../../lib/libclangBasic.a ../../../../lib/libLLVMDebugInfoPDB.a ../../../../lib/libLLVMObject.a ../../../../lib/libLLVMBitReader.a ../../../../lib/libLLVMCore.a ../../../../lib/libLLVMRemarks.a ../../../../lib/libLLVMBitstreamReader.a ../../../../lib/libLLVMMCParser.a ../../../../lib/libLLVMMC.a ../../../../lib/libLLVMTextAPI.a ../../../../lib/libLLVMBinaryFormat.a ../../../../lib/libLLVMDebugInfoCodeView.a ../../../../lib/libLLVMDebugInfoMSF.a ../../../../lib/libLLVMSupport.a /usr/lib64/libz.so -lrt -lpthread -ldl -ltinfo -lm /usr/lib64/libz3.so ../../../../lib/libLLVMDemangle.a )

One can workaround it by appending to the end:

../../../../lib/liblldbTarget.a

Or by wrapping the libs into:

-Wl,--start-group ... --Wl,--end-group

It is a recent regression although I am not sure when it happened. git bisect says D73517 but it has bad reproducibility. I understand it may be affected by optimizations/inlining etc.

Diff Detail

Event Timeline

jankratochvil created this revision.Feb 2 2020, 6:32 AM

Functions are defined in: ./lib/liblldbTarget.a = lldb/source/Target/CMakeLists.txt
Functions are needed in: ./lib/liblldbExpression.a = lldb/source/Expression/CMakeLists.txt

labath added a comment.Feb 3 2020, 4:16 AM

Lldb has a lot of circular dependencies, so it is not totally surprising that code move can cause this error to perk up. It the past we've worked around this by increasing the LINK_INTERFACE_MULTIPLICITY property in lldb/Core/CMakeLists.txt, and it seems like we should do that now as well -- the Data Formatter tests are not really to blame here (they don't use the expression library directly), so it's quite possible this problem will perk up soon in another place.

That said, if you have an idea on how to reduce the number of dependency cycles, I'd very much like to hear that too...

OK, LINK_INTERFACE_MULTIPLICITY also works.

labath accepted this revision.Feb 3 2020, 5:16 PM
This revision is now accepted and ready to land.Feb 3 2020, 5:16 PM
This revision was automatically updated to reflect the committed changes.