riscv-collab / riscv-gnu-toolchain

GNU toolchain for RISC-V, including GCC
Other
3.49k stars 1.15k forks source link

Cannot build on Mac (aarch64) #1577

Open MarcoBonino opened 1 week ago

MarcoBonino commented 1 week ago

Hello! I'm trying to build on MacOS aarch64 (M3 chip). However some tools like riscv64-unknown-elf-gcc and riscv64-unknown-elf-g++ are missing.

I'm from a case sensitive filesystem. And I installed the required tools:

brew install python3 gawk gnu-sed gmp mpfr libmpc isl zlib expat texinfo flock libslirp

This is my configure:

# get gmp, mpfr and libmpc available during ./configure script execution 
export CPPFLAGS="-I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/lib"
./configure --prefix=/Volumes/linux/bin-riscv-gnu-toolchain

And I get:

checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for fgrep... /usr/bin/grep -F
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for bash... /bin/sh
checking for __gmpz_init in -lgmp... yes
checking for mpfr_init in -lmpfr... yes
checking for mpc_init2 in -lmpc... yes
checking for curl... /usr/bin/curl
checking for wget... /opt/homebrew/bin/wget
checking for ftp... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating scripts/wrapper/awk/awk
config.status: creating scripts/wrapper/sed/sed

Then I simply run make.

Could you provide support on this ? If possible would be also nice to have the MacOS toolchain already built as it was done for the Ubuntu builds.

Thanks!

TommyMurphyTM1234 commented 1 week ago

Do you actually need to build the toolchain yourself or could you use an existing binary distribution like @ilg-ul's xPack version perhaps?

If you do really need to build your own toolchain and are having problems then the first step is to provide the complete steps that you are taking (from a clean git clone through configure and make) and also capture and upload a build log for analysis (e.g. make 2>&1 | tee build.log).

However, bear in mind that most active participants on this repo do not have access to the necessary hardware in order to reproduce/investigate macOS build problems and unfortunately no macOS users have stepped up to help here in this regard to date.

TommyMurphyTM1234 commented 1 week ago

Also, if you search all open and closed issues here using appropriate terms like "macOS", "Brew", "XCode" etc. you may find some useful information about issues and workarounds when building on Apple hardware.

TommyMurphyTM1234 commented 1 week ago

And, another option is to use the xPack build mechanism:

MarcoBonino commented 1 week ago

@TommyMurphyTM1234 thanks for sharing useful information. Right now it is ok to use a prebuilt toolchain, in case the build is really need I will come back in case I cannot build.

I'm using the toolchain you liked, but I'm getting a linker error: https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/issues/37

Do you think is something about the toolchain itself or a gcc problem or something else ?

TommyMurphyTM1234 commented 6 days ago
wossoneri commented 5 days ago

try this https://github.com/riscv-software-src/homebrew-riscv

TommyMurphyTM1234 commented 2 days ago

try this https://github.com/riscv-software-src/homebrew-riscv

Did this help at all @MarcoBonino?