riscv-software-src / riscv-tools

RISC-V Tools (ISA Simulator and Tests)
1.13k stars 446 forks source link

M1 Mac support #330

Open xhw1 opened 3 years ago

xhw1 commented 3 years ago

Hi,

Is there a way to install riscv-tools on m1 Macs? when I run brew install riscv-tools I got error:

==> Installing riscv/riscv/riscv-tools dependency: riscv-gnu-toolchain
        ==> ./configure --prefix=/opt/homebrew/Cellar/riscv-gnu-toolchain/master
==> make
Last 15 lines from /Users/xiaohan/Library/Logs/Homebrew/riscv-gnu-toolchain/02.make:
      toplev::main(int, char**) in libbackend.a(toplev.o)
      gt_pch_save(__sFILE*) in libbackend.a(ggc-common.o)
      gt_pch_save(__sFILE*) in libbackend.a(ggc-common.o)
      gt_pch_restore(__sFILE*) in libbackend.a(ggc-common.o)
      gt_pch_restore(__sFILE*) in libbackend.a(ggc-common.o)
ld: symbol(s) not found for architecture arm64
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [cc1] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [cc1plus] Error 1
rm gcov.pod fsf-funding.pod lto-dump.pod gpl.pod cpp.pod gfdl.pod gcc.pod gcov-dump.pod gcov-tool.pod
make[1]: *** [all-gcc] Error 2
make: *** [stamps/build-gcc-newlib-stage1] Error 2
jim-wilson commented 3 years ago

No. riscv-tools needs a gcc cross compiler, and a cross compiler still needs info about the build system (i.e. the M1 Mac) so it can figure out how to translate stuff from the build system to the target system. FSF GCC currently has no build system support for M1 Macs. This needs to be added upstream, and then pulled down into riscv-gnu-toolchain. That could be a while. See for instance https://github.com/riscv/riscv-gnu-toolchain/issues/800