lab 環境架設
===
###### tags: `6.1810`
# Mac OS install RISC-V compiler toolchain issue
使用 Mac OS 安裝 RISC-V toolchain 時會有問題
執行
```shell=
$ brew tap riscv-software-src/riscv
$ brew install riscv-gnu-toolchain
```
會有問題
原因是有兩個 submodule 名稱更改了,
`riscv-binutils -> binutils` 以及 `riscv-gcc -> gcc`
解決方式:
打開 brew formula
`$ brew edit riscv-gnu-toolchain`
更改以下程式碼
```diff=
# need to pull in needed submodules (now that they are disabled above)
system "git", "submodule", "update", "--init", "--recursive", "newlib"
- system "git", "submodule", "update", "--init", "--recursive", "riscv-binutils"
- system "git", "submodule", "update", "--init", "--recursive", "riscv-gcc"
+ system "git", "submodule", "update", "--init", "--recursive", "binutils"
+ system "git", "submodule", "update", "--init", "--recursive", "gcc"
...
# Workaround for M1
# See https://github.com/riscv/homebrew-riscv/issues/47
- system "sed", "-i", ".bak", "s/.*=host-darwin.o$//", "riscv-gcc/gcc/config.host"
- system "sed", "-i", ".bak", "s/.* x-darwin.$//", "riscv-gcc/gcc/config.host"
+ system "sed", "-i", ".bak", "s/.*=host-darwin.o$//", "gcc/gcc/config.host"
+ system "sed", "-i", ".bak", "s/.* x-darwin.$//", "gcc/gcc/config.host"
```
重新安裝 toolchain
`$ brew install riscv-gnu-toolchain`
# references
https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1117#issuecomment-1229446707