Env: macOS Catalina
10.15.7
Step1: git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
Although it doesn't need
--recursive
in README, this issue still happened on mac.
Step2: brew install python3 gawk gnu-sed gmp mpfr libmpc isl zlib expat
Step3: cd riscv-gnu-toolchain
directory and ./configure --prefix=/opt/riscv --enable-multilib
To build either cross-compiler with support for both 32-bit and 64-bit
Step4: find your .zshrc
, append this line export PATH="$PATH:/opt/riscv/bin"
and then source .zshrc
DONE !!
After installing riscv-gnu-toolchain, I chose to building qemu for macOS first and installed qemu.
Step 1:
brew install libffi gettext glib pkg-config autoconf automake pixman ninja
Explained
Step2:
curl -L https://download.qemu.org/qemu-5.2.0.tar.xz > qemu-5.2.0.tar.xz
(why qemu 5.2.0)
Step3:
tar xf qemu-5.2.0.tar.xz
Step4:
cd qemu-5.2.0
andmkdir build && cd build
Step5:
../confgiure
Step6:
make
andmake install
DONE!