[clang] Use the same PKGBUILD for extra/clang extra/llvm extra/lldb
Description:
Currently
extra/clang is built with -DBUILD_SHARED_LIBS=ON (generate
/usr/lib/libclangAST.so ... instead of libclangAST.a)
-DLLVM_LINK_LLVM_DYLIB=ON (link against libLLVM-7.so)
extra/llvm extra/lldb are built with -DBUILD_SHARED_LIBS=OFF (default) (generate /usr/lib/libLLVMSupport.a , not libLLVMSupport.so)
The discrepancy makes it easy to have collision of static constructors when the user links libLLVMSupport.a and libclangAST.so
# If the user builds
https://github.com/MaskRay/ccls
with cmake -H. -BRelease -DSYSTEM_CLANG=on
-DLLVM_ENABLE_RTTI=on # no -DUSE_SHARED_LLVM=on
% ccls
CommandLine Error: Option 'help-list' registered more than
once!
This is because both libLLVM-7.so (needed by libclang*.so) and libLLVMSupport.a define the static constructors of some cl::opt options (e.g. https://github.com/llvm-mirror/llvm/tree/master/lib/Support/CommandLine.cpp#L2039 HLOp "help-list")
I suggest unifying PKGBUILD of
* extra/llvm
* extra/clang (depends on llvm)
* extra/lldb (depends on both llvm and clang)
and using -DLLVM_BUILD_LLVM_DYLIB=ON -DUSE_SHARED_LIBS=ON for the unified build. (there will be libclangAST.so libLLVMSupport.so but no .a)
The separate build is also wasteful.
Note, -DLLVM_BUILD_LLVM_DYLIB=ON creates libLLVM-7.so, which is a unified .so containing all external symbols of libLLVM*.a or libLLVM*.so