riscv 交叉编译器错误:无效的 -march= 选项:`rv64imafdc_zicsr'

问题描述 投票:0回答:1

我是海湾合作委员会世界的新手。 我不知道这是否是发帖的正确位置,但我遇到了一些非常烦人的问题。

我已经创建了一个类Unix系统,虽然它还不是很完整,但我想为它做一个交叉编译链,以便我可以使用一些开源c库。

我修改这些文件:

config.sub、fixincludes/mkfixinc.sh、config.gcc、gcc/config/caffeinix.h、libgcc/config.host

但是我编译gcc后,运行时遇到了问题。 我尝试编译一个测试文件(除了 main 函数之外什么都没有),但出现以下错误:

❯ ./riscv64-caffeinix-gcc -o test test.c

Assembler messages:
Fatal error: invalid -march= option: `rv64imafdc_zicsr'

一切都会生成......

如何摆脱它?

我可以提供的信息:

主机:Ubuntu 22.04

Newlib(自己编译的):2.5.0

以及编译后的gcc信息:

❯ ./riscv64-caffeinix-gcc -march=rv64gc -Q --help=target

The following options are target specific:
-mabi= lp64d
-malign-data= xlen
-march= rv64imafdc_zicsr_zifencei
-mbig-endian [disable]
-mbranch-cost=N 3
-mcmodel= medlow
-mcpu=PROCESSOR
-mcsr-check [disable]
-mdiv [enable]
-mexplicit-relocs [enable]
-mfdiv [enable]
-minline-atomics [enable]
-misa-spec= 20191213
-mlittle-endian [enable]
-mplt [enable]
-mpreferred-stack-boundary= 0
-mrelax [enable]
-mriscv-attribute [enable]
-msave-restore [disable]
-mshorten-memrefs [enable]
-msmall-data-limit=N 8
-mstack-protector-guard-offset=
-mstack-protector-guard-reg=
-mstack-protector-guard= global
-mstrict-align [enable]
-mtune=PROCESSOR rocket

Supported ABIs (for use with the -mabi= option):
ilp32 ilp32d ilp32e ilp32f lp64 lp64d lp64f

Known encoding models (for use with the -mcmodel= option):
medany medlow

Supported ISA specs (for use with the -misa-spec= option):
2.2 20190608 20191213

Known data alignment choices (for use with the -malign-data= option):
natural xlen Valid arguments to -mstack-protector-guard=: global tls Known valid arguments for -mcpu= option: sifive-e20 sifive-e21 sifive-e24 sifive-e31 sifive-e34 sifive-e76 sifive-s21 sifive-s51 sifive-s54 sifive-s76 sifive-u54 sifive-u74 thead-c90 6 Known valid arguments for -mtune= option: rocket sifive-3-series sifive-5-series sifive-7-series thead-c906 size sifive-e20 sifive-e21 sifive-e24 sifive-e31 sifive-e34 sifive-e76 sifive-s21 sifive-s51 sifive-s54 sifive-s76 sifive-u54 sifive-u74 thead-c906

Assembler messages:
Fatal error: invalid -march= option: `rv64gc'
❯ ./riscv64-caffeinix-gcc -v

Using built-in specs.
COLLECT_GCC=./riscv64-caffeinix-gcc COLLECT_LTO_WRAPPER=/home/troy/repo/riscv-toolchain/riscv-gnu-toolchain/bin-gcc/libexec/gcc/riscv64-caffeinix/13.2.0/lto-wrapper target: riscv64-caffeinix configured as: ../gcc/configure --target=ris cv64-caffeinix --prefix=/home/troy/repo/riscv-toolchain/riscv-gnu-toolchain/bin-gcc/ --with-sysroot=/home/troy/repo/riscv-toolchain/bin-newlib/ --enable-languages=c --with-headers=/home/troy/repo/riscv-toolchain/bin-newlib/riscv64-caffeinix/include --with-arch=rv64imafdc --with-abi=lp64d --with-tune=rocket --with-isa-spec=20191213 --with-newlib
Threading model: single
Supported LTO compression algorithm: zlib
gcc version 13.2.0 (GCC)

❯ ./riscv64-caffeinix-gcc -o test test.c -v
Using built-in specs.
COLLECT_GCC=./riscv64-caffeinix-gcc
COLLECT_LTO_WRAPPER=/home/troy/repo/riscv-toolchain/riscv-gnu-toolchain/bin-gcc/libexec/gcc/riscv64-caffeinix/13.2.0/lto-wrapper
Target: riscv64-caffeinix
Configured with: ../gcc/configure --target=riscv64-caffeinix --prefix=/home/troy/repo/riscv-toolchain/riscv-gnu-toolchain/bin-gcc/ --with-sysroot=/home/troy/repo/riscv-toolchain/bin-newlib/ --enable-languages=c --with-headers=/home/troy/repo/riscv-toolchain/bin-newlib/riscv64-caffeinix/include --with-arch=rv64imafdc --with-abi=lp64d --with-tune=rocket --with-isa-spec=20191213 --with-newlib
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 13.2.0 (GCC)
COLLECT_GCC_OPTIONS='-o' 'test' '-v' '-mtune=rocket' '-march=rv64imafdc_zicsr' '-mabi=lp64d' '-misa-spec=20191213' '-march=rv64imafdc_zicsr'
 /home/troy/repo/riscv-toolchain/riscv-gnu-toolchain/bin-gcc/libexec/gcc/riscv64-caffeinix/13.2.0/cc1 -quiet -v -imultilib . test.c -quiet -dumpbase test.c -dumpbase-ext .c -mtune=rocket -march=rv64imafdc_zicsr -mabi=lp64d -misa-spec=20191213 -march=rv64imafdc_zicsr -version -o /tmp/ccH3vrdP.s
GNU C17 (GCC) version 13.2.0 (riscv64-caffeinix)
Compiled by GNU C version 11.4.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP

GGC parameters: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Ignoring nonexistent directory "/home/troy/repo/riscv-toolchain/bin-newlib/usr/local/include"
Ignoring nonexistent directory "/home/troy/repo/riscv-toolchain/riscv-gnu-toolchain/bin-gcc/lib/gcc/riscv64-caffeinix/13.2.0/../../../../riscv64-caffeinix/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/troy/repo/riscv-toolchain/riscv-gnu-toolchain/bin-gcc/lib/gcc/riscv64-caffeinix/13.2.0/include
 /home/troy/repo/riscv-toolchain/riscv-gnu-toolchain/bin-gcc/lib/gcc/riscv64-caffeinix/13.2.0/include-fixed
 /home/troy/repo/riscv-toolchain/bin-newlib/usr/include
End of search list.
Compiler executable checksum: 01f20c63f1ee93b4e7344797d234e600
COLLECT_GCC_OPTIONS='-o' 'test' '-v' '-mtune=rocket' '-march=rv64imafdc_zicsr' '-mabi=lp64d' '-misa-spec=20191213' '-march=rv64imafdc_zicsr'
 as -v --traditional-format -march=rv64imafdc_zicsr -march=rv64imafdc_zicsr -mabi=lp64d -misa-spec=20191213 -o /tmp/ccIwNEVC.o /tmp/ccH3vrdP.s
GNU assembler version 2.38 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.38
Assembler messages:
Fatal error: invalid -march= option: `rv64imafdc_zicsr'

感谢您的回复和帮助!

致以诚挚的问候。

特洛伊。

gcc operating-system riscv
1个回答
0
投票

罪魁祸首是:

 as -v --traditional-format -march=rv64imafdc_zicsr -march=rv64imafdc_zicsr -mabi=lp64d -misa-spec=20191213 -o /tmp/ccIwNEVC.o /tmp/ccH3vrdP.s
GNU assembler version 2.38 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.38

它尝试使用为主机 x86_64 系统配置的默认汇编器,而不是交叉编译目标(本来应该如此)。您的交叉编译 gcc 未正确配置(它会自行交叉编译,但不知道如何正确调用交叉编译 binutils)。有关正确的交叉编译器的示例,请参阅 Ubuntu 的 Linux risc-v 交叉编译器的工作原理:

$ riscv64-linux-gnu-gcc -o test test.c -v
...
 /usr/lib/gcc-cross/riscv64-linux-gnu/13/../../../../riscv64-linux-gnu/bin/as -v --traditional-format -fpic -march=rv64imafdc_zicsr_zifencei -march=rv64imafdc_zicsr_zifencei -mabi=lp64d -misa-spec=20191213 -o /tmp/ccG5Y80p.o /tmp/ccKoHWFj.s
GNU assembler version 2.42 (riscv64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.42

需要返回gcc交叉编译并确保在配置过程中可以找到riscv64-caffeinix-as。

© www.soinside.com 2019 - 2024. All rights reserved.