我正在跟踪gcc裸机交叉编译器的构建过程。以下是有关ARM GCC阶段1的说明。
5. Configure, build and install ARM GCC stage 1. This step creates a
bootstrap ARM toolchain without any of the standard C libraries. Note that
in the following commands any text within square brackets must only be used
when building the arm-none-eabi (or armeb-none-eabi) toolchain.
You do not type the square brackets themselves, only the text between them.
$ cd build-<target>/gcc_stage1
$ ../../gcc-linaro-5.3-2016.05/configure --target=<target> \
--prefix=<install_dir> \
--with-arch=armv8-a \
[--with-fpu=crypto-neon-fp-armv8] \
--disable-multilib \
--disable-werror \
--enable-languages=c \
--disable-shared \
--without-headers \
--with-newlib \
--with-gnu-as \
--with-gnu-ld
$ make all-gcc <-- error here "--64"
$ make install-gcc
$ cd ../..
对于配置,我给出了命令
../../gcc-linaro-5.3-2016.05/configure --target=arm-none-eabi --prefix=/opt/arm-toolchain --with-arch=armv8-a --with-fpu=crypto-neon-fp-armv8 --disable-multilib --disable-werror --enable-languages=c --disable-shared --without-headers --with-newlib --with-gu-as --with-gnu-ld
然后,当我运行make all-gcc
时,出现以下错误。 (为简洁起见,仅显示了最后一个部分,该日志是第二次给出命令后的记录,因此仅显示了最后一个错误部分。)
TARGET_CPU_DEFAULT="" \
HEADERS="auto-host.h ansidecl.h" DEFINES="" \
/bin/bash ../../../gcc-linaro-5.3-2016.05/gcc/mkconfig.sh config.h
config.h is unchanged
TARGET_CPU_DEFAULT="TARGET_CPU_generic" \
HEADERS="options.h insn-constants.h config/dbxelf.h config/elfos.h config/arm/unknown-elf.h config/arm/elf.h config/arm/bpabi.h config/newlib-stdint.h config/arm/aout.h config/vxworks-dummy.h config/arm/arm.h config/initfini-array.h defaults.h" DEFINES="LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4" \
/bin/bash ../../../gcc-linaro-5.3-2016.05/gcc/mkconfig.sh tm.h
tm.h is unchanged
TARGET_CPU_DEFAULT="" \
HEADERS="config/arm/arm-protos.h config/arm/aarch-common-protos.h tm-preds.h" DEFINES="" \
/bin/bash ../../../gcc-linaro-5.3-2016.05/gcc/mkconfig.sh tm_p.h
tm_p.h is unchanged
TARGET_CPU_DEFAULT="" \
HEADERS="auto-host.h ansidecl.h" DEFINES="" \
/bin/bash ../../../gcc-linaro-5.3-2016.05/gcc/mkconfig.sh bconfig.h
bconfig.h is unchanged
g++ -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../../gcc-linaro-5.3-2016.05/gcc -I../../../gcc-linaro-5.3-2016.05/gcc/build -I../../../gcc-linaro-5.3-2016.05/gcc/../include -I../../../gcc-linaro-5.3-2016.05/gcc/../libcpp/include \
-o build/genmddeps.o ../../../gcc-linaro-5.3-2016.05/gcc/genmddeps.c
/opt/arm-toolchain/arm-none-eabi/bin/as: unrecognized option '--64'
Makefile:2428: recipe for target 'build/genmddeps.o' failed
make[1]: *** [build/genmddeps.o] Error 1
make[1]: Leaving directory '/home/ckim/Downloads/arm-toolchain/build-arm-none-eabi/gcc_stage1/gcc'
Makefile:4108: recipe for target 'all-gcc' failed
make: *** [all-gcc] Error 2
日志显示了我在正确使用之前构建的as
。我在网上搜索,但找不到相同的情况。有人可以给我一些想法吗?
答案 0 :(得分:2)
这可能是因为您似乎要针对的ARM体系结构arm-none-eabi
(一种64位体系结构)与您正在构建的工具链aarch64-none-elf
之间存在不匹配:您应该针对../../gcc-linaro-5.3-2016.05/configure --target=aarch64-elf --prefix=/opt/arm-toolchain --with-arch=armv8-a --with-fpu=crypto-neon-fp-armv8 --disable-multilib --disable-werror --enable-languages=c --disable-shared --without-headers --with-newlib --with-gu-as --with-gnu-ld
代替:就像这样:
/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc
COLLECT_LTO_WRAPPER=/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/bin/../libexec/gcc/aarch64-none-elf/9.2.1/lto-wrapper
Target: aarch64-none-elf
Configured with: /tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/gcc/configure --target=aarch64-none-elf --prefix=/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/build-aarch64-none-elf/install// --with-gmp=/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/build-aarch64-none-elf/host-tools --with-mpfr=/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/build-aarch64-none-elf/host-tools --with-mpc=/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/build-aarch64-none-elf/host-tools --with-isl=/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/build-aarch64-none-elf/host-tools --disable-shared --disable-nls --disable-threads --disable-tls --enable-checking=release --enable-languages=c,c++,fortran --with-newlib --with-pkgversion='GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)' --with-bugurl=https://bugs.linaro.org/
Thread model: single
gcc version 9.2.1 20191025 (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10))
ARM gcc工具链是使用以下选项构建的:
{{1}}
答案 1 :(得分:0)
so.s:
nop
为手臂构建(aarch32)
arm-none-eabi-as so.s -o so.o
arm-none-eabi-objdump -d so.o
so.o: file format elf32-littlearm
Disassembly of section .text:
00000000 <.text>:
0: e1a00000 nop ; (mov r0, r0)
为aarch64(64位臂)构建
aarch64-none-elf-as so.s -o so.o
aarch64-none-elf-objdump -d so.o
so.o: file format elf64-littleaarch64
Disassembly of section .text:
0000000000000000 <.text>:
0: d503201f nop
和用于演示目的的mips
mips-elf-as so.s -o so.o
mips-elf-objdump -d so.o
so.o: file format elf32-bigmips
Disassembly of section .text:
00000000 <.text>:
0: 00000000 nop
x86
as so.s -o so.o
objdump -D so.o
so.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <.text>:
0: 90 nop
两个不同的指令集两个不同的gnu目标(例如x86,mips和arm)是不同的目标,并且是gnu工具的不同版本。
Uprante Frants回答,这只是该答案的一个证明。