Failed to build cling via cross compiler

${CROSS_COMPILE}gcc -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_GLOBAL_ISEL -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/tools/c-index-test -I/home/ericxh/work/git_work/interpreter/src/tools/clang/tools/c-index-test -I/home/ericxh/work/git_work/interpreter/src/tools/clang/include -Itools/clang/include -Iinclude -I/home/ericxh/work/git_work/interpreter/src/include -isystem /usr/include/libxml2 -fPIC -Werror=date-time -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=gnu89 -MD -MT tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o -MF tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o.d -o tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o -c /home/ericxh/work/git_work/interpreter/src/tools/clang/tools/c-index-test/c-index-test.c
In file included from /usr/include/libxml2/libxml/parser.h:810:0,
from /home/ericxh/work/git_work/interpreter/src/tools/clang/tools/c-index-test/c-index-test.c:15:
/usr/include/libxml2/libxml/encoding.h:31:26: fatal error: unicode/ucnv.h: No such file or directory
compilation terminated.

however, i succeeded to build the cling with native compiler, as in below

/usr/bin/cc -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_GLOBAL_ISEL -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/ericxh/work/git_work/interpreter/obj/tools/clang/tools/c-index-test -I/home/ericxh/work/git_work/interpreter/src/tools/clang/tools/c-index-test -I/home/ericxh/work/git_work/interpreter/src/tools/clang/include -I/home/ericxh/work/git_work/interpreter/obj/tools/clang/include -I/home/ericxh/work/git_work/interpreter/obj/include -I/home/ericxh/work/git_work/interpreter/src/include -isystem /usr/include/libxml2 -fPIC -Werror=date-time -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=gnu89 -o CMakeFiles/c-index-test.dir/c-index-test.c.o -c /home/ericxh/work/git_work/interpreter/src/tools/clang/tools/c-index-test/c-index-test.c

there is some difference on the “-D”, i believe it is the reason to cause the failure by CROSS_COMPILE, since “unicode/ucnv.h” is included only when LIBXML_ICU_ENABLED is enabled.
since all this command line are configured by cmake, so which additional cmake environment should be set.

Thanks
Xinghao Chen

i checked, actually only the toolchain matters.

with the same command line parameters, just replace the native compiler or cross compiler, the cross compiler will be failed, so might be the built-in options affects?

${CROSS_COMPILE}gcc -v
Using built-in specs.
COLLECT_GCC=/home/ericxh/work/toolchain/marvell-gcc-5.2.1-16.02.0-armv7/le/armv7-marvell-linux-gnueabihf-hard-5.2.1_i686_20151110/bin/arm-marvell-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/mnt/disk1/ericxh/work/toolchain/marvell-gcc-5.2.1-16.02.0-armv7/le/armv7-marvell-linux-gnueabihf-hard-5.2.1_i686_20151110/bin/…/libexec/gcc/arm-linux-gnueabihf/5.2.1/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /home/gccbuilder-i386/release/mgcc5.0/src/gcc-src/configure --host=i686-linux-gnu --build=i686-linux-gnu --target=arm-linux-gnueabihf --prefix=/home/gccbuilder-i386/release/mgcc5.0/Release/install/armv7-marvell-linux-gnueabihf-hard-5.2.1_i686 --enable-libssp --enable-shared --enable-threads --enable-lto --enable-libgomp --enable-gnu-indirect-function --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-pkgversion=‘Marvell GCC release 20151110-a53c013d’ --with-bugurl=mailto:mrvlgccbug@gmail.com --with-sysroot=/home/gccbuilder-i386/release/mgcc5.0/Release/install/armv7-marvell-linux-gnueabihf-hard-5.2.1_i686/arm-linux-gnueabihf/libc --with-build-sysroot=/home/gccbuilder-i386/release/mgcc5.0/Release/install/armv7-marvell-linux-gnueabihf-hard-5.2.1_i686/arm-linux-gnueabihf/libc --with-host-libstdcxx=’-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm’ --with-build-time-tools=/home/gccbuilder-i386/release/mgcc5.0/Release/install/armv7-marvell-linux-gnueabihf-hard-5.2.1_i686/arm-linux-gnueabihf/bin --enable-poison-system-directories --enable-symvers=gnu --enable-__cxa_atexit --enable-multiarch --enable-linker-build-id --disable-nls --disable-libstdcxx-pch --disable-libcc1 --with-specs=’%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}’ --with-arch=armv7-a --with-tune=marvell-pj4b --with-float=hard --with-fpu=vfpv3-d16 --enable-mvl-thumb2-multilibs
Thread model: posix

i might know the reason, actually the cross compiler doesn’t have LIBXML(no lib/include) support,
i don’t know why cmake have “#define CLANG_HAVE_LIBXML=1” in the config since it detects libxml in the host machine.

i tried to disable “CLANG_HAVE_LIBXML” manually in ./tools/clang/include/clang/Config/config.h, and build.ninja , it could pass.

so any elegant way to do this?

We don’t have experience with building cling through cross-compilation. If you have any wisdom to share what needs to be fixed and how then please let us know!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.