Skip to content

Commit 74c652e

Browse files
committed
Adding LZMA as dep for XML2 on 2.8.0 or higher
LibXML2 config doesn't specify lzma as a dependency, which breaks cross-compilation builds using new linkers (ld 2.21 or higher). There is a bug on libxml2 to fix that, but since it's going to take a while for things to go round and back, so we should have a harmless addition of the library until then. llvm-svn: 190409
1 parent d8d47fa commit 74c652e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/cmake/config-ix.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,20 @@ endif()
300300
find_package(LibXml2)
301301
if (LIBXML2_FOUND)
302302
set(CLANG_HAVE_LIBXML 1)
303+
# When cross-compiling, liblzma is not detected as a dependency for libxml2,
304+
# which makes linking c-index-test fail. But for native builds, all libraries
305+
# are installed and checked by CMake before Makefiles are generated and everything
306+
# works according to the plan. However, if a -llzma is added to native builds,
307+
# an additional requirement on the static liblzma.a is required, but will not
308+
# be checked by CMake, breaking native compilation.
309+
# Since this is only pertinent to cross-compilations, and there's no way CMake
310+
# can check for every foreign library on every OS, we add the dep and warn the dev.
311+
if ( DEFINED CMAKE_CROSSCOMPILING )
312+
if (NOT PC_LIBXML_VERSION VERSION_LESS "2.8.0")
313+
message(STATUS "Adding LZMA as a dep to XML2 for cross-compilation, make sure liblzma.a is available.")
314+
set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} "-llzma")
315+
endif ()
316+
endif ( CMAKE_CROSSCOMPILING )
303317
endif ()
304318

305319
include(CheckCXXCompilerFlag)

0 commit comments

Comments
 (0)