This is an archive of the discontinued LLVM Phabricator instance.

Add a new library, libclang-cxx
Needs ReviewPublic

Authored by pirama on Aug 6 2018, 1:50 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

The current libclang.so exports only the symbols required for the stable
C api. This is opposed to libLLVM.so, which exports all the symbols
from the LLVM libraries, including those from the C++ API. This patch
adds libclang-cxx.so that is similar to libLLVM.so and exports all
symbols from the clang libraries. The motivation for this library is to
be used by Clang tools that use Clang's C++ api. They no longer need to
link against the individual static libraries.

Diff Detail

Event Timeline

pirama created this revision.Aug 6 2018, 1:50 PM
chapuni added a subscriber: chapuni.Aug 6 2018, 3:18 PM
pirama updated this revision to Diff 165118.Sep 12 2018, 10:52 AM

Add empty source file to silence CMake warning.
Support more platforms, similar to libLLVM.so

As I mentioned in the discussion, we decided to carry build rules for the proposed library in downstream. I've updated this to make it more general, and will leave it open in case there's more interest to revive it in the future.

The motivation for this library is to
be used by Clang tools that use Clang's C++ api. They no longer need to
link against the individual static libraries.

I would personally consider that to be a regression.
It hides layering violations.
Of course, in downstream one might not care.

kristina added a subscriber: kristina.EditedSep 12 2018, 11:32 AM

I'm in support as long as it's a configuration option defaulting similar to LLVM's one. Should likely follow the same naming convention as LLVM, ie. clang-shlib. Clang has a lot of tools it ships with especially if you consider extras, I think this is one of the cases where an exception for libClang-8.so can be made as long as it's not a default. It would make builds of things like clang-tidy much faster without requiring a fully shared library build.

IIRC libclang is a tool in itself, and is not mandatory for Clang driver tool build which is the most fundamental part to most customers, while this new library is not. There are a lot of things the downstream discussions have not covered it seems since this only accounts for for a full Clang+Tools+ARCMT+StaticAnalyzer+Extra (ie. tidy, include fixer) build. This just fails to account for so much. The pairing of libclang and the new shared library defeats the entire point of it altogether, since libclang is not required by the driver. Nor by most in-tree tools.

kristina added a comment.EditedSep 12 2018, 12:29 PM

To elaborate, consider a scenario where a customer wants to build the clang driver, diagtool and just for the sake of the argument change-namespace from extras. Clang tools do not provide nearly the same level of control as most LLVM tools, so in that scenario, you'd have to maintain your own CMakeLists.txt for clang tools(/extra) to neuter unwanted artifacts like clang-tidy or libclang.so (the C API re-exporter) etc.

Unless I deeply misunderstand the functionality of toggles within LLVM's main build system, the only way of neutering those artifacts while still being able to use libclang-cxx.so would be surgery on several CMakeLists as it's not the same as, say, LLVM_TOOL_LLVM_YAML_NUMERIC_PARSER_FUZZER_BUILD=Off which is possible for top level LLVM tools.