LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 17085 - libXML2 fails to spot lzma when cross-compiling
Summary: libXML2 fails to spot lzma when cross-compiling
Status: RESOLVED FIXED
Alias: None
Product: Build scripts
Classification: Unclassified
Component: cmake (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Renato Golin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-03 12:18 PDT by Renato Golin
Modified: 2013-09-10 10:55 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Renato Golin 2013-09-03 12:18:23 PDT
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.
Comment 1 Renato Golin 2013-09-04 14:30:11 PDT
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.
Comment 2 Óscar Fuentes 2013-09-04 14:58:09 PDT
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.
Comment 3 Renato Golin 2013-09-05 03:28:21 PDT
> 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.
Comment 4 Renato Golin 2013-09-05 04:13:23 PDT
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...
Comment 5 Renato Golin 2013-09-05 04:19:41 PDT
Adding Doug (FYI), as he's the CMake expert.
Comment 6 Renato Golin 2013-09-10 10:55:55 PDT
Fixed as of r190409