Compiling the RISC-V GNU Compiler Toolchain on OS X
#1
Hello everyone,

i want the RISC-V GNU Compiler Toolchain to work on OS X. Here are my steps so far and what goes wrong.


Code:
brew install gawk gnu-sed gmp mpfr libmpc isl zlib



Code:
git clone --recursive https://github.com/pulp-platform/pulp-riscv-gnu-toolchain


Code:
./configure --prefix=/opt/riscv --with-arch=rv32imfdc --with-cmodel=medlow --enable-multilib make

Then i created a disk image of 8 GiB with a case sensitive APFS file system and copied all the files into that disk image. Inside that disk image i run make.


Code:
make

Make returns the following error message which is the same error message if i do not run make inside the disk image.

Code:
/Users/rene/code/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/rltty.c:83:7: error: implicit declaration of function 'ioctl' is invalid in C99
     [-Werror,-Wimplicit-function-declaration]
 if (ioctl (tty, TIOCGWINSZ, &w) == 0)
     ^
/Users/rene/code/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/rltty.c:720:3: error: implicit declaration of function 'ioctl' is invalid in C99
     [-Werror,-Wimplicit-function-declaration]
 ioctl (fildes, TIOCSTART, 0);
 ^
/Users/rene/code/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/rltty.c:759:3: error: implicit declaration of function 'ioctl' is invalid in C99
     [-Werror,-Wimplicit-function-declaration]
 ioctl (fildes, TIOCSTOP, 0);
 ^
3 errors generated.
make[3]: *** [rltty.o] Error 1
make[2]: *** [all-readline] Error 2
make[1]: *** [all] Error 2
make: *** [stamps/build-binutils-newlib] Error 2
Reply
#2
Hi, you should do
Code:
brew install g++ gcc
to have more recent versions of GCC available (currently I think version 9).
Then, before building, run
Code:
export CXX=g++-9 CC=gcc-9

It did work for me. If you are building for MacOS on ARM64 instead of Intel look here: https://github.com/riscv-software-src/ho...-772306695

Finally, the RISC-V toolchain will work fine on MacOS, but the other PULP SDK tools, in particular GVSoC, are Linux-only as far as I know, so you will need to use a container or VM to make it work.
Reply
#3
Hello fconti,

thank you very much for the very quick reply. This helps a lot because we need to work with the PULP platform in a real production environment.

I did `brew install g++ gcc`. Here is the reply from HomeBrew.

Code:
Warning: No available formula with the name "g++".
Reply
#4
Probably I noted it down wrong, and GCC is enough to install both GCC and G++. Anyways, better to use the Homebrew version than the one provided by MacOS, which is actually Clang+LLVM.

On the other hand, if you need this for production, I strongly suggest you use a Ubuntu 20.04 virtual machine (or a container if you prefer). Everything will work out of the box and you'll save yourself a lot of trouble.
Reply
#5
We created a Dockerfile for the toolchain. I will create a new post to publish it.

Apart from that, personally i think it is better if PULP either removes the content on how to compile for Mac or correct it. It is pretty annoying wasting time with instructions that do not work.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)