简体   繁体   English

如何仅为RV32I基本整数指令和扩展M编译C代码?

[英]How can I compile C code only for the RV32I base integer instruction and the extension M?

I have started to work with risc-v few days ago, but yesterday I had a problem. 几天前我已经开始使用risc-v了,但昨天我遇到了问题。 The problem is the following: 问题如下:

I want to compile code for example for the RV32I base integer instruction set and I want to add too the "M" Standard Extension. 我想为RV32I基本整数指令集编译代码,我想添加“M”标准扩展。

When I compile the C code I use the following command 当我编译C代码时,我使用以下命令

riscv64-unknown-elf-gcc Program.c -o Program.o -m32 -march=RV32IM

Now if for example I want to see assembler code, I use 现在,如果我想看到汇编程序代码,我使用

riscv64-unknown-elf-objdump -d Program.c > Program.dump

Now, if I explore the dump file "Program.dump" . 现在,如果我探索转储文件“Program.dump”。 I have noticed that sometimes appear assembly instructions as: 我注意到有时会出现汇编指令:

   10c6c:   00a12427            fsw fa0,8(sp)
   10dd0:   00a42023            sd a0,8(sp)

among many other cases. 在许多其他情况下。

If I see the "RISC-V Instruction Set Manual, Volume I: User-Level ISA, Version 2.0" at page 52 I observe that the fsw instruction belongs a RV32F Standard Extension and the sd instruction , it belongs to RV64I. 如果我在第52页看到“RISC-V指令集手册,第I卷:用户级ISA,版本2.0”,我发现fsw指令属于RV32F标准扩展和sd指令,它属于RV64I。

For this reason, I am confused I don't know if my problem is that I am not compiling well. 出于这个原因,我很困惑,我不知道我的问题是我的编译不好。

My question is: How can I compile C code only for the RV32I base integer instruction and the extension M? 我的问题是:如何仅为RV32I基本整数指令和扩展M编译C代码?

As Chris pointed out, the problem seems to be that the libraries have not been built for RV32I. 正如克里斯指出的那样,问题似乎是没有为RV32I构建库。

This is a copy&paste from my instructions here for how to build a pure RV32I toolchain+libraries from git rev 5b1febd (2015-07-05) of riscv-gnu-toolchain: 这是一个复制和粘贴从我的指示, 在这里如何建立一个纯RV32I工具链+从git的转库5b1febd riscv,GNU工具链的(2015年7月5日):

sudo mkdir /opt/riscv32i
sudo chown $USER /opt/riscv32i

git clone https://github.com/riscv/riscv-gnu-toolchain riscv-gnu-toolchain-rv32i
cd riscv-gnu-toolchain-rv32i
git checkout 5b1febd

mkdir build; cd build
../configure --with-xlen=32 --with-arch=I --prefix=/opt/riscv32i
make -j$(nproc)

This will install a RV32I toolchain with the riscv32-unknown-elf- command prefix. 这将使用riscv32-unknown-elf-命令前缀安装RV32I工具链。

There seems to be a problem with --with-xlen=32 --with-arch=I in current git head of riscv-gnu-toolchain. 在riscv-gnu-toolchain的当前git头中似乎存在--with-xlen=32 --with-arch=I的问题。 I've now reported the issue on github. 我现在已经在github上报告了这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM