Hi,<br><br>Does anyone have experience with doing Canadian cross-builds of LLVM compiler? I need some help here... I'm a new with LLVM, so please don't be too harsh on me.<br><br>I am building LLVM cross-compiler (and as I mentioned I'm doing it via canadian cross-build):<br>



Build platform = Linux,<br>Host platform = Windows<br>Target platform = Linux<br><br>I'm using mingw32 compiler toolchain to cross-build LLVM cross-compiler. <br>(My CC=i386-mingw32-gcc, CXX=i386-mingw32-g++, LD=i386-mingw32-ld, etc)<br>


<br>During the build, configure complains that it can't run C compiled program on build platform (which makes sense, since mingw32 compiler creates an executable that cannot be run<br>
on build platform (linux)). <br><br>SRC_DIR="/home/ksanina"; export SRC_DIR; BUILD_DIR="/home/ksanina/build/mx-debug-llvm-all"; export BUILD_DIR; PWD="/home/ksanina"; export PWD; PATH="/usr/local/bin:/bin:/usr/bin"; export PATH; BUILD_DIR=/home/ksanina/build/mx-debug-llvm ; export BUILD_DIR ; INSTALL_DIR=/home/ksanina/install/mx-debug ; export INSTALL_DIR ; AR="i386-mingw32-ar"; export AR; AS="i386-mingw32-as"; export AS; CC="i386-mingw32-gcc"; export CC; CXX="i386-mingw32-g++"; export CXX; LD="i386-mingw32-ld"; export LD; CFLAGS="-m32 -g"; export CFLAGS; CXXFLAGS="-m32 -g"; export CXXFLAGS; LDFLAGS=""; export LDFLAGS; CFLAGS="-std=gnu89 $CFLAGS" <br>
make -f /home/ksanina/Makefile.llvm -C $BUILD_DIR all CONFIG_FLAGS="-<span style="color: rgb(204, 0, 0);">-host=i386-mingw32 --build=x86_64-linux-gnu --target=i386-linux --prefix=/home/ksanina/install/mx-debug --enable-validation</span>" MAKE_FLAGS="VERBOSE=1 " TESTSUITE=<br>
make[1]: Entering directory `/home/ksanina/build/mx-debug-llvm'<br>make VERBOSE=1  <br>make[2]: Entering directory `/home/ksanina/build/mx-debug-llvm'<br>if [ ! -f BuildTools/Makefile ]; then \<br>          /home/ksanina/llvm/autoconf/mkinstalldirs BuildTools; \<br>
      cd BuildTools ; \<br>      unset CFLAGS ; \<br>      unset CXXFLAGS ; \<br>      /home/ksanina/llvm/configure --build=x86_64-pc-linux-gnu \<br>        --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu; \<br>      cd .. ; \<br>
    fi; \<br>    (unset SDKROOT; \<br>     make -C BuildTools \<br>      BUILD_DIRS_ONLY=1 \<br>      UNIVERSAL= \<br>      ENABLE_OPTIMIZED=1 \<br>      ENABLE_PROFILING= \<br>      ENABLE_COVERAGE= \<br>      DISABLE_ASSERTIONS=1 \<br>
      ENABLE_EXPENSIVE_CHECKS= \<br>      CFLAGS= \<br>      CXXFLAGS= \<br>    ) || exit 1;<br>checking build system type... x86_64-pc-linux-gnu<br>checking host system type... x86_64-pc-linux-gnu<br>checking target system type... x86_64-pc-linux-gnu<br>
checking type of operating system we're going to host on... Linux<br>checking type of operating system we're going to target... Linux<br>checking target architecture... x86_64<br>checking for x86_64-pc-linux-gnu-gcc... i386-mingw32-gcc<br>
checking for C compiler default output file name... a.exe<br>checking whether the C compiler works... configure: error: cannot run C compiled programs.<br>If you meant to cross compile, use `--host'.<br>See `config.log' for more details.<br>
make[3]: Entering directory `/home/ksanina/build/mx-debug-llvm/BuildTools'<br>make[3]: *** No targets specified and no makefile found.  Stop.<br>make[3]: Leaving directory `/home/ksanina/build/mx-debug-llvm/BuildTools'<br>
make[2]: *** [cross-compile-build-tools] Error 1<br>make[2]: Leaving directory `/home/ksanina/build/mx-debug-llvm'<br>make[1]: *** [make] Error 2<br>make[1]: Leaving directory `/home/ksanina/build/mx-debug-llvm'<br>
make: *** [mx-debug-llvm-all] Error 2<br>rm /home/ksanina/build/mx-debug-llvm/.dir<br><br><br><br><br>To resolve this issue, I end up setting up additional environment variables, BUILD_CC=gcc BUILD_CXX=g++  BUILD_AR =ar BUILD_LD=ld etc.<br>
Also, I modified llvm/Makefile to use my BUILD_CC, BUILD_AS, BUILD_LD, etc instead of CC, AS, LD, etc.<br>
for cross-compile-build-tools target.<br><br>cross-compile-build-tools:<br>        $(Verb) if [ ! -f BuildTools/Makefile ]; then \<br>

          $(MKDIR) BuildTools; \<br>          cd BuildTools ; \<br>          unset CFLAGS ; \<br>          unset CXXFLAGS ; \<br>+         AR=$(BUILD_AR) ;\<br>+         AS=$(BUILD_AS) ;\<br>+         LD=$(BUILD_LD) ;\<br>



+         CC=$(BUILD_CC) ;\<br>+         CXX=$(BUILD_CXX) ;\<br>          $(PROJ_SRC_DIR)/configure --build=$(BUILD_TRIPLE) \<br>                --host=$(BUILD_TRIPLE) --target=$(BUILD_TRIPLE); \<br>          cd .. ; \<br>



<br><br>This workaround worked. But I'm sure there is some other,  more elegant way of doing it (without actually changing llvm/Makefile). I'm sure other people have done Canadian cross build and resolve this issue some other way. If you've done it before, please advise on how better to do it. <br>

<br>Thanks a lot!<br><br>Ekaterina.<br><br><br>