[clang] df239a6 - clang: Add a cmake toggle to disable libclang's libxml2 dependency

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 10:34:30 PDT 2022


Author: Nico Weber
Date: 2022-10-26T13:34:19-04:00
New Revision: df239a6c17fa51274e38f185e72ac02c2f8fb914

URL: https://github.com/llvm/llvm-project/commit/df239a6c17fa51274e38f185e72ac02c2f8fb914
DIFF: https://github.com/llvm/llvm-project/commit/df239a6c17fa51274e38f185e72ac02c2f8fb914.diff

LOG: clang: Add a cmake toggle to disable libclang's libxml2 dependency

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.

Differential Revision: https://reviews.llvm.org/D136700

Added: 
    

Modified: 
    clang/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 7c41eadc7bf9..6f590c830b23 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -147,7 +147,12 @@ list(INSERT CMAKE_MODULE_PATH 0
   "${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.*")


        


More information about the cfe-commits mailing list