linux 怎么编译.v,学习第一步:RISC-V GCC工具链编译安装~

原标题:学习第一步:RISC-V GCC工具链编译安装~

RISC-V GCC工具链编译安装

要学习riscv架构,首先第一步,要搞定riscv的gcc交叉编译器。下面就对riscv的gcc交叉编译器,进行详细的介绍。

riscv gcc工具下载

Riscv的gcc交叉编译器,以开源的方式托管在github上。链接如下:

https://github.com/riscv/riscv-gnu-toolchain

09591509643da44ab76447a3971b9925.png

该仓库,里面包含了一些子仓库。

使用以下这个命令,将所有仓库,都clone下来。

git clone --recursive https://github.com/riscv/riscv-gnu-toolchain

以下是各个仓库的github地址:

riscv-gcc

https://github.com/riscv/riscv-gcc

riscv-glibc

https://github.com/riscv/riscv-glibc

riscv-newlib

https://github.com/riscv/riscv-newlib

riscv-dejagnu

https://github.com/riscv/riscv-dejagnu

riscv-gdb

https://github.com/riscv/riscv-binutils-gdb.git

riscv-binutils

https://github.com/riscv/riscv-binutils-gdb.git

riscv-qemu

https://github.com/riscv/riscv-qemu.git

编译riscv gcc

下载完毕后,就要开始编译。首先在riscv-gnu-toolchain根目录下,创建build目录。用于编译riscv gcc。

riscv gcc可以编译成以下几个版本

riscv32-unknown-elf-gcc

riscv64-unknown-elf-gcc

riscv32-unknown-linux-gnu-gcc

riscv64-unknown-linux-gnu-gcc

riscv64-multilib-elf-gcc

riscv64-liunx-multilib-gcc

以下编译,是基于 riscv架构支持 imc三种指令集,来进行编译的。如果想要支持其他的指令集,只需要修改 —-with-arch选项。

1、riscv32-unknown-elf-gcc

执行以下命令:

../configure --prefix=/opt/riscv32 --with-arch=rv32imc --with-abi=xxx

make

—-mabi可以选择如下:

ilp32

ilp32f

ilp32d

编译完成后,在/opt/riscv/bin目录下,有riscv32-unknown-elf-gcc的所有工具。

c7c7be0d475248073961f6bd659d4692.png

通过 riscv32-unknown-elf-gcc -v命令,可以得到该工具链的配置信息。

Using built-in specs.

COLLECT_GCC=./riscv32-unknown-elf-gcc

COLLECT_LTO_WRAPPER=/opt/riscv/libexec/gcc/riscv32-unknown-elf/8.2.0/lto-wrapper

Target: riscv32-unknown-elf

Configured with: /tools/riscv-gnu-toolchain-1/build/../riscv-gcc/configure --target=riscv32-unknown-elf --prefix=/opt/riscv --disable-shared --disable-threads --enable-languages=c,c++ --with-system-zlib --enable-tls --with-newlib --with-sysroot=/opt/riscv/riscv32-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --src=../../riscv-gcc --enable-checking=yes --disable-multilib --with-abi=ilp32 --with-arch=rv32imc 'CFLAGS_FOR_TARGET=-Os -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-Os -mcmodel=medlow'

Thread model: single

gcc ve

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值