You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tools from clang-tutor fail to build when using Clang/LLVM that was build with BUILD_SHARED_LIBS set. This is the error that I see on Ubuntu 16.04:
[7/9] Linking CXX executable bin/ct-la-commenter
FAILED: : && /usr/bin/clang++-11 -Wall -fdiagnostics-color=always -fno-rtti -fvisibility-inlines-hidden -g tools/CMakeFiles/ct-la-commenter.dir/LACommenterMain.cpp.o tools/CMakeFiles/ct-la-commenter.dir/__/lib/LACommenter.cpp.o -o bin/ct-la-commenter -Wl,-rpath,/home/andwar02/work/release-11/build/release/lib /home/bs/release-11/build/release/lib/libclangTooling.so.11 -Wl,-rpath-link,/home/bs/release-11/build/release/lib && :
/usr/bin/ld: tools/CMakeFiles/ct-la-commenter.dir/LACommenterMain.cpp.o: undefined reference to symbol '_ZN5clang14FrontendAction22shouldEraseOutputFilesEv'
/home/bs/work/release-11/build/release/lib/libclangFrontend.so.11: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)
SOLUTION 1
A solution was submitted by @xguptahere. It went through a few iterations. The original approach looked like this:
However, we discovered that that didn't work well with pre-build binary packages from Ubuntu 16.04. This is the error that I was getting at run-time:
bin/ct-la-commenter <clang-tutor-dir>/test/LACBool.cpp 2>&1
: CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
Aborted
So this was regression. It's hard to fix as it's not clear how the packages from Ubuntu are built and how to reproduce this with manually built packages.
SOLUTION 2 @xgupta kindly submitted an updated solution that is based on Clang's reference example. However, for this to work clang-tutor needs access to:
add_clang_executable
clang_target_link_libraries
This would normally be achieved with include(AddClang) in one of the CMake scripts. However, currently AddClang is not copied/installed in the build directory. A fix has been proposed here. One can also work around this by pointing clang-tutor to Clang's source directory (i.e. the location of AddClang). But that would mean that Ubuntu's pre-build packages alone are no longer sufficient to build the project.
SUMMARY
Both approaches break clang-tutor when using Ubuntu's pre-build LLVM/Clang packages. I think that SOLUTION 2 would be more canonical, but we may need for D94533 to be merged.
The text was updated successfully, but these errors were encountered:
Looking at the definition of add_clang_executable, it feels that add_llvm_executable should be sufficient for us.
Similarly, clang_target_link_libraries could be replaced with target_link_libraries. So, include(AddLLVM) could be replaced with include(AddClang), which means that this is doable :)
The tools from clang-tutor fail to build when using Clang/LLVM that was build with
BUILD_SHARED_LIBS
set. This is the error that I see on Ubuntu 16.04:SOLUTION 1
A solution was submitted by @xgupta here. It went through a few iterations. The original approach looked like this:
However, we discovered that that didn't work well with pre-build binary packages from Ubuntu 16.04. This is the error that I was getting at run-time:
So this was regression. It's hard to fix as it's not clear how the packages from Ubuntu are built and how to reproduce this with manually built packages.
SOLUTION 2
@xgupta kindly submitted an updated solution that is based on Clang's reference example. However, for this to work clang-tutor needs access to:
add_clang_executable
clang_target_link_libraries
This would normally be achieved with
include(AddClang)
in one of the CMake scripts. However, currentlyAddClang
is not copied/installed in the build directory. A fix has been proposed here. One can also work around this by pointing clang-tutor to Clang's source directory (i.e. the location ofAddClang
). But that would mean that Ubuntu's pre-build packages alone are no longer sufficient to build the project.SUMMARY
Both approaches break clang-tutor when using Ubuntu's pre-build LLVM/Clang packages. I think that SOLUTION 2 would be more canonical, but we may need for D94533 to be merged.
The text was updated successfully, but these errors were encountered: