分析C代码编译成RISC-V汇编后如何执行
环境搭建
-
环境Ubuntu 22.04LTS
-
新建文件夹RISCV并进入
-
使用git下载工具链
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
-
安装依赖
sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
-
配置编译选项
./configure --prefix=/opt/riscv --enable-multilib
-
编译
make -j4
,根据自己设备的核心数设置多线程 -
修改
/etc/profile
将/opt/riscv/bin
添加到PATH
,并使用source /etc/profile
重新加载 -
在终端中输入
riscv64
并使用tab补全,若能出现补全则为配置完成。
-
安装GCC
sudo apt install gcc-risc