Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

[Tutorial] Build RISCV GNU toolchain on macOS(with V extension enabled) #323

Open
ksco opened this issue Jan 5, 2022 · 3 comments
Open

Comments

@ksco
Copy link

ksco commented Jan 5, 2022

Here is a step by step guide on how to compile the RISCV-GNU-Toolchain on macOS 10.15.3. The process of trying to compile is not smooth, so I think this may be useful to others.

git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git -b rvv-intrinsic
cd riscv-gnu-toolchain

macOS's file system is case insensitive by default, this will cause problems with git clone, you can create a new APFS case sensitive volume in the Disk Utility.app to solve this.

Next, edit .gitmodules file, change [submodule "riscv-glibc"] section to:

[submodule "riscv-glibc"]
        path = riscv-glibc
        url = https://github.com/riscvarchive/riscv-glibc.git
        branch = riscv-glibc-2.29

Next, run following command to download submodules:

git submodule sync
git -c http.sslVerify=false submodule update --init --recursive --force

Next, run following command to compile the whole thing:

./configure --prefix=/path/to/riscv-gnu-toolchain/build/ --with-arch=rv64gcv_zfh --with-abi=lp64d
make linux -j$(nproc)

macOS's ulimit is 256 by default, this is not enough when compiling glibc, you will get a Too many open files error, run ulimit -n 2048 .

If you encounter this problem: Undefined symbols for architecture x86_64: "_libintl_setlocale", referenced from: _main in cross-rpc_main.o, you can change riscv-gnu-toolchain/riscv-glibc/sunrpc/Makefile:L178 to$(BUILD_CC) $^ $(BUILD_LDFLAGS) -L/usr/lib -lintl -o $@

References:

@ksco ksco changed the title [Tutorial] build RISCV GNU toolchain on macOS [Tutorial] build RISCV GNU toolchain on macOS(with V extension enabled) Jan 5, 2022
@ksco ksco changed the title [Tutorial] build RISCV GNU toolchain on macOS(with V extension enabled) [Tutorial] Build RISCV GNU toolchain on macOS(with V extension enabled) Jan 5, 2022
@imkiva
Copy link

imkiva commented Mar 13, 2022

And you will need this patch haiku/buildtools@9c6e710 if building on macos-aarch64

@cheyao
Copy link

cheyao commented Jan 8, 2023

The rvv-intrinsic branch now doesn't exist, do you have any replacement?

@ksco
Copy link
Author

ksco commented Jan 9, 2023

The rvv-intrinsic branch now doesn't exist, do you have any replacement?

It's rvv-next now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants