llvm / llvm/llvm-project

Shared library build is failing with unresolved reference errors when trying to link libclangIncludeCleaner

Open
#184,559 7 comments 0 reactions 0 assignees View on GitHub
clang clang:PCH
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I'm trying to build recent LLVM trunk with `-DBUILD_SHARED_LIBS=ON` and it's failing with the following linker errors:

```
[2380/3118] Linking CXX shared library lib/libclangIncludeCleaner.so.23.0git
FAILED: [code=1] lib/libclangIncludeCleaner.so.23.0git
: && /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 -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Xclang -fno-pch-timestamp -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O0 -g3 -shared -Wl,-z,defs -Wl,-z,nodelete -Wl,-rpath-link,/home/nr/dev/projects/llvm/build/./lib -Xlinker --dependency-file=tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/clangIncludeCleaner.dir/link.d -Wl,-soname,libclangIncludeCleaner.so.23.0git -o lib/libclangIncludeCleaner.so.23.0git tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/Analysis.cpp.o tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/IncludeSpeller.cpp.o tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/FindHeaders.cpp.o tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/HTMLReport.cpp.o tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/LocateSymbol.cpp.o tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/Record.cpp.o tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/Types.cpp.o tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/WalkAST.cpp.o -Wl,-rpath,"\$ORIGIN/../lib:/home/nr/dev/projects/llvm/build/lib:" lib/libclangFormat.so.23.0git lib/libclangToolingInclusions.so.23.0git lib/libclangToolingInclusionsStdlib.so.23.0git lib/libclangToolingCore.so.23.0git lib/libclangAST.so.23.0git lib/libclangLex.so.23.0git lib/libclangBasic.so.23.0git lib/libLLVMSupport.so.23.0git -Wl,-rpath-link,/home/nr/dev/projects/llvm/build/lib && :
/usr/bin/ld: tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/Record.cpp.o:(.data.rel.ro._ZTVN4llvm9ErrorInfoINS_9ErrorListENS_13ErrorInfoBaseEEE[_ZTVN4llvm9ErrorInfoINS_9ErrorListENS_13ErrorInfoBaseEEE]+0x38): undefined reference to `llvm::ErrorInfo::dynamicClassID() const'
/usr/bin/ld: tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/Record.cpp.o:(.data.rel.ro._ZTVN4llvm9ErrorInfoINS_9ErrorListENS_13ErrorInfoBaseEEE[_ZTVN4llvm9ErrorInfoINS_9ErrorListENS_13ErrorInfoBaseEEE]+0x40): undefined reference to `llvm::ErrorInfo::isA(void const*) const'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with LLVM trunk and -DBUILD_SHARED_LIBS=ON, focusing on the tools/clang/tools/extra/include-cleaner/lib target and its generated link command. Inspect that target's CMake dependencies and the definition of llvm::ErrorInfo; done means the shared libclangIncludeCleaner library links successfully without the reported unresolved symbols.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.