【问题标题】:error in first gcc cross compiler compile stage (arm-none-eabi/bin/as: unrecognized option '--64')第一个 gcc 交叉编译器编译阶段出错(arm-none-eabi/bin/as:无法识别的选项 '--64')
【发布时间】:2020-11-12 13:07:43
【问题描述】:

我正在关注 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。我在网上搜索但找不到相同的案例。谁能给我一些想法?

【问题讨论】:

    标签: gcc compilation arm


    【解决方案1】:

    这很可能是您的目标 ARM 架构 armv8-a(这是一个 64 位架构)与您正在构建的工具链 arm-none-eabi 不匹配:您应该改为定位 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
    

    ARM gcc 工具链是使用以下选项构建的:

    /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))
    

    【讨论】:

    • 谢谢,那你的意思是我应该在配置中删除--with-arch=armv8-a?我明天可以试试。
    • 我刚刚扩充了我的答案。
    • 顺便说一句,如果这个或任何答案已经解决了您的问题(我认为它已经解决了),请通过单击复选标记考虑accepting it。这向更广泛的社区表明您已经找到了解决方案,并为回答者和您自己提供了一些声誉。没有义务这样做。您使用的程序是否有效是另一个话题,可能会引发更多问题。
    • 您需要使用 aarch64-whatever-as 而不是 arm-whatever-as。 arm-whatever-as won't build for aarch64.不同的 gnu 目标(不同的、完全不兼容的指令集)。
    【解决方案2】:

    所以:

    nop
    

    为 arm (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 工具的不同构建。

    赞成 Frants 的回答顺便说一句,这只是该答案的一个演示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-19
      • 2014-11-14
      • 1970-01-01
      • 2011-08-20
      • 2014-09-26
      • 1970-01-01
      • 2016-12-26
      • 1970-01-01
      相关资源
      最近更新 更多