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?
Thanks
Klaus