Re: Compiling GCC 11 for Windows targeting ARM on Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 10 Jan 2022 at 16:49, Thomas Sobczynski via Gcc-help
<gcc-help@xxxxxxxxxxx> wrote:
>
> I would appreciate insight on a compilation error while building GCC 11 to run on Windows, targeting bare metal ARM, from a GNU/Linux build environment (specifically Ubuntu via WSL2).
>
> I have a current (within a few days) clone of the Git repo at the HEAD of releases/gcc-11.
>
>
> *** Source tree:
> $ git status
> On branch releases/gcc-11
> Your branch is up to date with 'origin/releases/gcc-11'.
>
>
> *** Build environment:
> $ gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
> OFFLOAD_TARGET_NAMES=nvptx-none:hsa
> OFFLOAD_TARGET_DEFAULT=1
> Target: x86_64-linux-gnu
> Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
> Thread model: posix
> gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
>
>
> For better or worse, I'm using GNU Make to drive the build process from the next level up from the GCC source tree, i.e. my Make is calling $(MAKE) to invoke the GCC build. Extracting the recipe steps, here is how I'm attempting to build GCC:
>
> Recipe steps:
>
> # Obtain GCC source for the release branch of interest.
> #
> # "If you do not intend to make changes to the source, you can avoid installing these build tools by running contrib/gcc_update."
> # https://gcc.gnu.org/git.html
>
> git clone --branch releases/gcc-11 --depth 1 git://gcc.gnu.org/git/gcc.git $(COMPILER_ROOT)/gcc
> cd $(COMPILER_ROOT)/gcc && contrib/gcc_update
>
> # "If you also intend to build binutils (either to upgrade an existing installation or for use in place of the corresponding tools of your OS), unpack the binutils distribution ... in the same directory..."
> # https://gcc.gnu.org/install/download.html
> # https://www.gnu.org/software/binutils/
>
> git clone --branch binutils-2_37 --depth 1 git://sourceware.org/git/binutils-gdb.git $(COMPILER_ROOT)/gcc/binutils
>
> # "Likewise the GMP, MPFR and MPC libraries can be automatically built together with GCC. You may simply run the contrib/download_prerequisites script in the GCC source directory to set up everything."
>
> cd $(COMPILER_ROOT)/gcc && contrib/download_prerequisites
>
> # Configuration
> # https://gcc.gnu.org/install/configure.html
> #
> # "The build machine is the system which you are using, the host machine is the system where you want to run the resulting compiler (normally the build machine), and the target machine is the system for which you want the compiler to generate code."
> # We're going to use WSL + Ubuntu + GCC to build a toolchain to run on Windows targeting ARM.
>
> cd $(COMPILER_ROOT)/build && $(COMPILER_ROOT)/gcc/configure --host=x86_64-w64-mingw32 --target=arm-none-eabi --prefix=${TOOLCHAIN_ROOT} --enable-vtable-verify --with-multilib-list=aprofile,rmprofile --enable-target-optspace --enable-languages=c,c++,lto --enable-large-address-aware
>
[snip]
> /bin/bash: arm-none-eabi-gcc: command not found
> make[3]: *** [Makefile:2165: specs] Error 127
> make[3]: Leaving directory '/home/tsobczynski/Compiler/build/gcc'
> make[2]: *** [Makefile:4458: all-gcc] Error 2
> make[2]: Leaving directory '/home/tsobczynski/Compiler/build'
> make[1]: *** [Makefile:983: all] Error 2
> make[1]: Leaving directory '/home/tsobczynski/Compiler/build'
> make: *** [Makefile:53: /home/tsobczynski/Compiler/build/foo] Error 2
>
>
>
> Granting that I am proceeding from a position of ignorance, I am not expecting an attempted invocation of "arm-none-eabi-gcc". My reasoning is that the build process is taking place on GNU/Linux, while "arm-none-eabi-gcc" is the name I expect for one of the compiler executables that will run on Windows. Just prior to the error, the GCC build copies xgcc.exe to gcc-cross.exe, which I presume is the compiler executable that will ultimately correspond to "arm-none-eabi-gcc.exe".

But that .exe can only run on the --host system, i.e. on Windows. To
build the target libs for the --target system (i.e. arm) you need an
arm compiler that runs on the --build host (i.e. x86_64 Linux).

So to build this combination you need to already have an arm cross
compiler to run on your build system.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux