[PATCH] D136700: clang: Add a cmake toggle to disable libclang's libxml2 dependency

Nico Weber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 25 10:24:00 PDT 2022


thakis created this revision.
thakis added a reviewer: hans.
Herald added a project: All.
thakis requested review of this revision.

By default, libclang will still depend on libxml2 according to
LLVM_ENABLE_LIBXML2, but with this it's possible to make libclang
not depend on libxml2 even though LLVM does.

The motivation is that libclang uses a bigger API surface of libxml2
than LLVM, and we're statically linking a very minimal build of
libxml2 in our LLVM/clang distribution.


https://reviews.llvm.org/D136700

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -147,7 +147,12 @@
   "${LLVM_COMMON_CMAKE_UTILS}/Modules"
   )
 
-if(LLVM_ENABLE_LIBXML2)
+# This allows disabling clang's XML dependency even if LLVM finds libxml2.
+# By default, clang depends on libxml2 if LLVM does.
+option(CLANG_ENABLE_LIBXML2 "Whether libclang may depend on libxml2"
+       ${LLVM_ENABLE_LIBXML2})
+
+if(CLANG_ENABLE_LIBXML2)
   # Don't look for libxml if we're using MSan, since uninstrumented third party
   # code may call MSan interceptors like strlen, leading to false positives.
   if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136700.470551.patch
Type: text/x-patch
Size: 707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221025/89885ab1/attachment.bin>


More information about the cfe-commits mailing list