-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't build on apple silicon mac (arm64) #800
Comments
GCC needs some build/host OS support, and there is no gcc support for darwin (aka MacOS) running on arm. So this isn't going to work. Someone needs to port GCC to aarch64-darwin first. And then we need to pull those patches down into riscv-gnu-toolchain. Apple no longer does GNU toolchain work, so I doubr that Apple will provide the missing gcc support. Some volunteer will need to do the work. So it could be a while before this support is available. The build/host support is a lot easier than the target support though. If you are motivated you could try adding this yourself. In riscv-gcc, see gcc/config.gcc and search for darwin. Note the x86_64-darwin and powerpc64-darwin stuff. You need to add something similar for aarch64-darwin. You can try just copying the x86_64 files from the gcc/config/i386 dir to the gcc/config/aarch64 dir, changing variable names and file names as necessary, and it might just work if darwin didn't change for the aarch64 port. |
You can running in Rosetta2. Just use homebrew to install it. Then add link: |
I did not try building the RISC-V GCC cross-toolchain on Apple Silicon yet, so I'm not sure how well it goes, but anyway you should try it with the available Apple clang, since, as Jim mentioned, GCC is not yet available and it might not be for a while: Given the uncertain future of GCC on macOS, these days I'm experimenting with Apple clang 12, for now on an Intel Mac, since I don't have an Arm one yet, but I guess they are very similar. So far I managed to compile, with minor issues, all packages that I needed, thus I'm confident that migrating the native compiler in my build scripts from GCC to clang is possible. |
The latest GCC available on macports (devel branch) works fine on arm64, I can confirm that.
|
We still need patches for riscv-gnu-toolchain/riscv-gcc to bulid on arm64-apple-darwin20. There is some host support that is required in the RISC-V gcc sources that get compiled as part of the RISC-V toolchain build. It may be a while before those patches get upstreamed to the FSF GCC and then pulled down into riscv-gnu-toolchain. |
@ChoungJX 's method works, for clarifying: you need to use arch --x86_64 install another homebrew. https://stackoverflow.com/a/64997047/3013527 here is a reference. |
I found a kludge that worked well enough it was codified for home-brew, riscv-software-src/homebrew-riscv#47 It just disabled mmap on precompiled headers on M1. |
Attached is the patch I use for my toolchain ( I'm switching over to using this project rather than my own but not there yet ). diff -Naur gcc-10.2.0/gcc/config/host-darwin.c gcc-10.2.0.new/gcc/config/host-darwin.c /* Yes, this is really supposed to work. / return ret; |
This patch is based off: osx-cross/homebrew-avr#248 and riscv-collab/riscv-gnu-toolchain#800 (comment)
This patch is based off: osx-cross/homebrew-avr#248 and riscv-collab/riscv-gnu-toolchain#800
This patch is based off: osx-cross/homebrew-avr#248 and riscv-collab/riscv-gnu-toolchain#800
So is there any way I can try to build on my m1 macbook. |
I also have successful builds on Apple SIlicon, but with the GNU 11.3 sources plus some patches: |
thx,I will try to use your method |
The patch for 11.3 is small:
12.1 builds without patches. Or you can directly use one of the binaries, they are available for most platforms. |
Hi @cmuellner and @kito-cheng - do you think that this can be closed? |
One idea would be to close MacOS issues and redirect people to https://github.com/riscv-software-src/homebrew-riscv |
Btw, the current version of MacOS is 13.0.1. And even homebrew-riscv does not build with that (at least I did not manage to get it building within 2 hours because of tons of configuration issues, dependency issues and path issues). |
Thanks @cmuellner - I'll do this for any open MacOS build issues. |
ld: symbol(s) not found for architecture arm64
The text was updated successfully, but these errors were encountered: