When cross-compiling LLVM to ARM, using CMake+Ninja, I realized that libxml2 depends on lzma, but the dependency is not explicit on the build.ninja file under the "build bin/c-index-test"'s LINK_LIBRARIES (which is the only one that cares about it). Oscar Fuentes proposed the following workarounds / solutions: A quick and dirty fix is to change this on clang/tools/c-index-test/CMakeLists.txt: target_link_libraries(c-index-test ${LIBXML2_LIBRARIES} lzma) That affects that instance only (maybe it is the only one.) And if you pretend to install that change, first check that XML2 always requires lzma (to not break the build on systems where it doesn't and libzma is absent.) A more robust fix shall work on llvm/cmake/config-ix.cmake: when XML2 is detected, add lzma as a dependency. This has the some caveat mentioned on the previous paragraph. Finally, the real fix shall be implemented on FindLibXml2.cmake, which belongs to the CMake project. It should take care of declaring that xml2 libraries depend on lzma, but apparently it doesn't.
Oscar, I was reading a bit and found that, as of 2.8.0 (May 23 2012)m libXML2 depends on LZMA on all cases. On my x86 machine, Ubuntu lists it as a dependency: $ apt-cache depends libxml2 libxml2 Depends: libc6 Depends: liblzma5 Depends: zlib1g PreDepends: multiarch-support multiarch-support:i386 Recommends: xml-core Replaces: libxml2:i386 Breaks: libxml2:i386 But config doesn't show them: $ xml2-config --libs -L/usr/lib -lxml2 Which shouldn't break anything (since libxml2 depends on lzma, the library could only exist IF lzma is installed/compiled correctly). But in this case, I'm copying the libraries manually (because it's for another architecture) AND ld 2.21 *now* requires explicit dependency declaration. So, I think it should be safe to say that libxml2 2.8.0+ always depends on lzma. I'll send a patch for review.
Renato, Your description makes me think that declaring a dependency of the xml2 libraries on lzma is safe enough, but please note that I'm not the maintainer of the CMake build. So send the patch to llvm-commits as usual and wait for approval. OTOH, it would be a good long-term investment to report this issue on the CMake build tracker.
> Your description makes me think that declaring a dependency of the xml2 > libraries on lzma is safe enough, Only for 2.8.0+, I'm trying to find a way to check for version numbers. I'm not a CMake expert, and a google search only returned me custom-made solutions. :( > but please note that I'm not the > maintainer of the CMake build. So send the patch to llvm-commits as usual > and wait for approval. Sure. > OTOH, it would be a good long-term investment to report this issue on the > CMake build tracker. That's a good point. This issue is probably not critical enough to make a special case in Clang.
Opened a bug in libxml2, to make xml2-config report -llzma as a dependency. https://bugzilla.gnome.org/show_bug.cgi?id=707545 But that won't fix the immediate problem, and it's not something that CMake should be doing anything, also, since the real problem is in the config tool. Do you think we should just add a quick hack on c-index-test until that gets fixed in libxml2? It'll take a while (years?) for a fix to appear on desktop systems, making our temporary fix quite long lived, but if we don't do that, then every cross-compilation will have the same problem. I'll find out how to do the version check...
Adding Doug (FYI), as he's the CMake expert.
Fixed as of r190409