Building Clang with shared libraries

So I decided to try to improve my iterative dev time (instigated by playing around with LLD) & while LLVM passes all its test with cmake BUILD_SHARED_LIBS=ON, clang does not. I hit the following error.

Has anyone seen this/worked around it/know what it’s about?

/usr/local/google/home/blaikie/install/bin/clang++   -fcolor-diagnostics -Wdeprecated -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Werror -std=c++11 -fcolor-diagnostics -fno-common -Woverloaded-virtual -Wno-nested-anon-types -g  -Wl,-allow-shlib-undefined tools/clang/unittests/Driver/CMakeFiles/ClangDriverTests.dir/ToolChainTest.cpp.o tools/clang/unittests/Driver/CMakeFiles/ClangDriverTests.dir/MultilibTest.cpp.o  -o tools/clang/unittests/Driver/ClangDriverTests  lib/libgtest.so.3.8.0svn lib/libgtest_main.so.3.8.0svn lib/libLLVMSupport.so.3.8.0svn lib/libclangDriver.so.3.8.0svn -Wl,-rpath,"\$ORIGIN/../lib" && :
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/unittests/Driver/ToolChainTest.cpp:31: error: undefined reference to 'clang::DiagnosticIDs::DiagnosticIDs()'
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/unittests/Driver/ToolChainTest.cpp:33: error: undefined reference to 'clang::DiagnosticsEngine::DiagnosticsEngine(llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> const&, clang::DiagnosticOptions*, clang::DiagnosticConsumer*, bool)'
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/unittests/Driver/ToolChainTest.cpp:35: error: undefined reference to 'clang::vfs::InMemoryFileSystem::InMemoryFileSystem()'
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/unittests/Driver/ToolChainTest.cpp:58: error: undefined reference to 'clang::vfs::InMemoryFileSystem::addFile(llvm::Twine const&, long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >)'
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/unittests/Driver/ToolChainTest.cpp:72: error: undefined reference to 'clang::DiagnosticsEngine::~DiagnosticsEngine()'
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/unittests/Driver/ToolChainTest.cpp:32: error: undefined reference to 'clang::DiagnosticConsumer::~DiagnosticConsumer()'
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/include/clang/Basic/Diagnostic.h:1313: error: undefined reference to 'vtable for clang::DiagnosticConsumer'
/usr/local/google/home/blaikie/install/bin/ld: the vtable symbol may be undefined because the class is missing its key function
/usr/local/google/home/blaikie/dev/llvm/src/include/llvm/ADT/IntrusiveRefCntPtr.h:54: error: undefined reference to 'clang::DiagnosticIDs::~DiagnosticIDs()'
tools/clang/unittests/Driver/CMakeFiles/ClangDriverTests.dir/ToolChainTest.cpp.o:/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/unittests/Driver/ToolChainTest.cpp:vtable for (anonymous namespace)::ToolChainTest_VFSGCCInstallation_Test::TestBody()::TestDiagnosticConsumer: error: undefined reference to 'clang::DiagnosticConsumer::IncludeInDiagnosticCounts() const'
tools/clang/unittests/Driver/CMakeFiles/ClangDriverTests.dir/ToolChainTest.cpp.o:/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/unittests/Driver/ToolChainTest.cpp:vtable for (anonymous namespace)::ToolChainTest_VFSGCCInstallation_Test::TestBody()::TestDiagnosticConsumer: error: undefined reference to 'clang::DiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&)'
clang-3.4: error: linker command failed with exit code 1 (use -v to see invocation)

So I decided to try to improve my iterative dev time (instigated by
playing around with LLD) & while LLVM passes all its test with cmake
BUILD_SHARED_LIBS=ON, clang does not. I hit the following error.

Has anyone seen this/worked around it/know what it's about?

It was a bug :wink: r249608 should help.

- Ben

So I decided to try to improve my iterative dev time (instigated by
playing around with LLD) & while LLVM passes all its test with cmake
BUILD_SHARED_LIBS=ON, clang does not. I hit the following error.

Has anyone seen this/worked around it/know what it's about?

It was a bug :wink: r249608 should help.

Seems to have done the trick - thanks a bunch!