[all-commits] [llvm/llvm-project] cb180d: [cmake] FindLibXml2: keep user-provided LIBXML2_DE...
Ryan VanderMeulen via All-commits
all-commits at lists.llvm.org
Tue Sep 8 06:59:26 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cb180d50a81674b467887eab836f563607ae89e8
https://github.com/llvm/llvm-project/commit/cb180d50a81674b467887eab836f563607ae89e8
Author: Ryan VanderMeulen <ryanvm at gmail.com>
Date: 2026-09-08 (Tue, 08 Sep 2026)
Changed paths:
M llvm/cmake/modules/FindLibXml2.cmake
Log Message:
-----------
[cmake] FindLibXml2: keep user-provided LIBXML2_DEFINITIONS (#221294)
LLVM's `FindLibXml2.cmake` (added in #166867) unconditionally does
`set(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER})` and puts
`PC_LIBXML_CFLAGS_OTHER` on the imported targets. CMake's own
`FindLibXml2` module only takes pkg-config's flags when the library it
found is the one pkg-config describes; otherwise it keeps whatever
`LIBXML2_DEFINITIONS` the user passed and exposes it through
`INTERFACE_COMPILE_OPTIONS`.
This matters when cross-compiling against a static libxml2 on Windows.
Passing `-DLIBXML2_DEFINITIONS=-DLIBXML_STATIC
-DLIBXML2_LIBRARIES=.../libxml2s.lib` worked with LLVM 22 (CMake's
module): the define reached both the `xmlReadMemory` configure check and
the consumers of `LibXml2::LibXml2`. With LLVM 23 it is silently
dropped, `xmlexports.h` declares the API `__declspec(dllimport)`, the
check fails to link against the static library and
`LLVM_ENABLE_LIBXML2=FORCE_ON` aborts with `Failed to configure
libxml2`. (pkg-config on the Linux host finds the host's libxml2, so
`PC_LIBXML_CFLAGS_OTHER` is empty and unrelated to the library actually
being used.)
Mirror CMake's behaviour: keep the user's definitions unless pkg-config
found the same library, and attach them to both `LibXml2::LibXml2` and
`LibXml2::LibXml2Static`.
Seen while building the Firefox clang 23 toolchains (x86_64 and aarch64
`-pc-windows-msvc`, cross-compiled from Linux with
`LLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON`).
---
**AI tool use disclosure** (per the [LLVM AI Tool Use
Policy](https://llvm.org/docs/AIToolPolicy.html)): this change was
developed with Claude Code assisting in the analysis and drafting. The
root cause was established against real 23.1.0 binaries; this cmake
change itself has so far only been verified to apply to 23.1.0 and main
and by code reading, while Firefox's CI validated the equivalent
workaround of passing -DLIBXML_STATIC via the compiler flags. The author
reviewed the change and is accountable for and able to answer questions
about it. Commits carry an `Assisted-by:` trailer.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list