Re: problems building cross compiler on x86 host for arm

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

 



On 13/06/2024 08:14, Klaus Rudolph via Gcc-help wrote:
> 
> 
> Am 12.06.24 um 13:42 schrieb Richard Earnshaw (lists):
>> On 12/06/2024 11:30, Klaus Rudolph via Gcc-help wrote:
>>>
>>>
>>> I try to build a cross gcc compiler for an older ARM platform.
>>> Installing binutils was successful but gcc fails.
>>>
>>> Host platform linux x86_64 binutils version to cross build:2.42 gcc
>>> version to cross build: 14.1.0
>>>
>>> What I did ( sorry, very detailed, maybe I did something totally stupid... )
>>>
>>> First, I created a docker image with the following Dockerfile to get a
>>> root filesystem:
>>>
>>> Dockerfile:
>>> #########
>>> FROM debian:8 as base
>>> # Needed for old Debians
>>> RUN printf "deb [trusted=yes] http://archive.debian.org/debian jessie
>>> main\ndeb [trusted=yes] http://archive.debian.org/debian-security
>>> jessie/updates main" > /etc/apt/sources.list
>>>
>>> # Install dependencies available in the Debian repos
>>> RUN apt-get update && \
>>>      apt-get install -y \
>>>          build-essential automake libtool cmake wget \
>>>          libsnmp-dev libdb-dev \
>>>          libssl-dev \
>>>          libopus-dev libasound2-dev vim
>>> #############
>>>
>>>> podman build . --arch=arm
>>>
>>> and export the file system to my host filesystem:
>>>
>>>> podman image mount
>>>
>>> and copied the root filesystem simply with cp -pr <path>/*
>>> <some/place/at/my/host>
>>>
>>> I now used a simple Makefile for installing binutils:
>>>
>>> #########
>>> # cross compile binutils
>>> BINUTILS_VERSION=2.42
>>> GCC_VERSION=14.1.0
>>>
>>> #http://ftp.fu-berlin.de/gnu/binutils/ binutils-2.42.tar.xz
>>> binutils_cross:
>>>          wget -nc
>>> http://ftp.fu-berlin.de/gnu/binutils/binutils-$(BINUTILS_VERSION).tar.xz
>>>          tar xf binutils-$(BINUTILS_VERSION).tar.xz
>>>          (\
>>>                  cd binutils-$(BINUTILS_VERSION); \
>>>                  mkdir build_armv7 ; \
>>>                  cd build_armv7; \
>>>                  ../configure --prefix=/opt/armv7_$(GCC_VERSION)
>>> --with-sysroot=/opt/podman_debian8/merged --enable-multiarch
>>> --with-fpu=vfpv3-d16 --with-mode=thumb --with-arch=armv7-a
>>> --target=arm-linux-gnueabihf ; \
>>>                  make; \
>>>                  sudo make install; \
>>>                  )
>>> ##############
>>>
>>> binutils installation works without any error messages.
>>>
>>> Now I tried to install gcc with this part of the install Makefile:
>>>
>>> #########
>>> gcc_cross:
>>>          wget -nc
>>> http://ftp.fu-berlin.de/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.xz
>>>          tar xf gcc-$(GCC_VERSION).tar.xz
>>>          ( \
>>>                  cd gcc-$(GCC_VERSION); \
>>>                  ./contrib/download_prerequisites; \
>>>                  mkdir build_armv7;\
>>>                  cd build_armv7;\
>>>                  ../configure --prefix=/opt/armv7_$(GCC_VERSION)
>>> --enable-languages=c,c++ --with-sysroot=/opt/podman_debian8/merged
>>> --enable-multiarch --with-fpu=vfpv3-d16 --with-mode=thumb
>>> --with-arch=armv7-a --target=arm-linux-gnueabihf --disable-multilib; \
>>>                  make -j6;\
>>>                  sudo make install;\
>>>                  )
>>> ###########
>>>
>>>
>>> make[3]: *** [Makefile:2998: build/gengenrtl.o] Error 1
>>> make[3]: *** Waiting for unfinished jobs....
>>> yes
>>> checking how to run the C preprocessor...
>>> /opt/armv7_14.1.0/arm-linux-gnueabihf/bin/as: unrecognized option '--64'
>>> make[3]: *** [Makefile:2998: build/genhooks.o] Error 1
>>> /opt/armv7_14.1.0/arm-linux-gnueabihf/bin/as: unrecognized option '--64'
>>> make[3]: *** [Makefile:2998: build/sort.o] Error 1
>>> gcc -E
>>> /opt/armv7_14.1.0/arm-linux-gnueabihf/bin/as: unrecognized option '--64'
>>> make[3]: *** [Makefile:2998: build/genchecksum.o] Error 1
>>> checking for grep that handles long lines and -e... /usr/bin/grep
>>> checking for egrep... /usr/bin/grep -E
>>> checking for ANSI C header files... yes
>>> checking for sys/types.h... yes
>>> checking for sys/stat.h... yes
>>> /bin/sh ../../gcc/../move-if-change tmp-optionlist optionlist
>>> checking for stdlib.h... echo timestamp > s-options
>>> make[3]: Leaving directory
>>> '/home/krud/compiler_install/gcc-14.1.0/build_armv7/gcc'
>>> make[2]: *** [Makefile:4714: all-gcc] Error 2
>>>
>>>
>>> I  wonder why I see the "unrecognized option '--64'" message, as I try
>>> to cross build for arm32.
>>>
>>> Did I use some wrong configure options or have missed some? Maybe
>>> already in the first step while installing binutils?
>>
>> I think it's the PATH that you're using while building GCC.  Binutils installs several versions of the assembler under different names, but the one you'll want in a normal cross compiler will be called arm-none-eabi-as (not just 'as').  The problem is that your native compiler (which is used to build the 'gen*' programs needs an assembler as well, and since that is using the system compiler it uses 'as' directly; but you've overridden that with your cross assembler.
>>
> 
> I did not modify PATH. So I am wondering why the configure stuff should
> try to use the arm assembler if it should use the host x86_64 assembler.
> If it is the other way around it is maybe a problem, isn't it?
> 
> I have no idea what I can change in my build scripts.
> Can you give me a hint?
> 

I'm trying to give a hint, but I'm not psychic, so I can only go on the information you've supplied.

Firstly, please turn off -j from your make command.  Running parallel jobs is beneficial when everything is working, but it just confuses the logs when there are errors.

We see in the logs you have provided:

/opt/armv7_14.1.0/arm-linux-gnueabihf/bin/as: unrecognized option '--64'

The Arm assembler (which you've just built) does not support that flag; it looks to me like an option your host compiler would pass to the x86 assembler.  This is further re-enforced by:

make[3]: *** [Makefile:2998: build/gengenrtl.o] Error 1
make[3]: *** Waiting for unfinished jobs....

Which is a generator program (used to translate parts of the compiler's DSL into C code) and is intended to run on the build machine, so being built by your system compiler.  The only conclusion I can draw from this on the evidence available is that your system compiler is somehow picking up your newly installed assembler instead of the one in /usr/bin/as.  The most likely cause of this is that you have /opt/armv7_14.1.0/arm-linux-gnueabihf/bin/ in your path before /usr/bin.

R.

PS: two unrelated things about your configure options to gcc.  If you're targetting a hard-float environment (arm-linux-gnueabihf) then you need to add --with-float=hard to configure.  Secondly, --with-fpu is deprecated with more recent versions of GCC; the preferred approach is to use --with-arch=armv7-a+fp and leave the fpu option at it's default setting of 'auto'.

R.

> Thanks
>  Klaus
> 




[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