Scons: How to compile export templates for linux on mac with apple silicon

Godot Version

4.4

Question

Hey there! I want to compile the export templates so I can encrypt my builds. On my apple silicon machine, I’ve got it working for web, windows and mac but I can’t get it to work for linux.

I’ve followed the instructions on Compiling for Linux, *BSD — Godot Engine (stable) documentation in English but I get the following output (I’ve installed riscv-gnu-toolchain and mold with Homebrew):

nubels@ac1668b3 godot % scons platform=list                                                
scons: Reading SConscript files ...
The following platforms are available:
	ios
	macos
	web
	windows
Please run SCons again and select a valid platform: platform=<string>.
nubels@ac1668b3 godot % PATH="$RISCV_TOOLCHAIN_PATH/bin:$PATH" \
scons arch=rv64 use_llvm=yes linker=mold lto=none target=editor \
    ccflags="--sysroot=$RISCV_TOOLCHAIN_PATH/sysroot --gcc-toolchain=$RISCV_TOOLCHAIN_PATH -target riscv64-unknown-linux-gnu" \
    linkflags="--sysroot=$RISCV_TOOLCHAIN_PATH/sysroot --gcc-toolchain=$RISCV_TOOLCHAIN_PATH -target riscv64-unknown-linux-gnu"
scons: Reading SConscript files ...
Automatically detected platform: macos
Auto-detected 14 CPU cores available for build parallelism. Using 13 cores by default. You can override it with the `-j` or `num_jobs` arguments.
ERROR: Unsupported CPU architecture "rv64" for macOS. Supported architectures are: x86_64, arm64. 

RISC-V is a (rare) CPU architecture, not a platform to target, congrats if you do have a RISC-V linux machine like the Milk-V Jupiter.

I’m surprised to see linuxbsd missing from your platform list, maybe you need to install gcc for x86-64 instead of rv64?

Thanks a lot for your reply! I’m not familiar with the RISC-V architecture, I just followed the documentation.

I’ve got gcc installed but scons doesn’t list linuxbsd.

nubels@ac1668b3 godot % which gcc
/usr/bin/gcc
nubels@ac1668b3 godot % scons platform=list
scons: Reading SConscript files ...
The following platforms are available:
	ios
	macos
	windows
Please run SCons again and select a valid platform: platform=<string>.

But on apple sillicon (arm64 architecture) your gcc should target arm64

My gcc on x86-64 linux targets x86-64

$ gcc -v

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu

Still, Linux also supports arm64 so I feel that it should be displayed in the list so long as you have a valid libc and linker (like mold for the correct architecture).

You will need to add platform=linuxbsd to your scons command to build for linux, that’s why your final error states you are still trying to build for macOS

ERROR: Unsupported CPU architecture "rv64" for macOS. Supported architectures are: x86_64, arm64. 

Hmmm, when I add platform=linuxbsd I get the error saying invalid target platform…

nubels@mbp godot % PATH="$RISCV_TOOLCHAIN_PATH/bin:$PATH" \
scons arch=x86_64 platform=linuxbsd use_llvm=yes linker=mold lto=none target=editor \
    ccflags="--sysroot=$RISCV_TOOLCHAIN_PATH/sysroot --gcc-toolchain=$RISCV_TOOLCHAIN_PATH -target riscv64-unknown-linux-gnu" \
    linkflags="--sysroot=$RISCV_TOOLCHAIN_PATH/sysroot --gcc-toolchain=$RISCV_TOOLCHAIN_PATH -target riscv64-unknown-linux-gnu"
scons: Reading SConscript files ...
ERROR: Invalid target platform "linuxbsd".
The following platforms are available:
	ios
	macos
	windows
Please run SCons again and select a valid platform: platform=<string>. 

I think I need to set up a VM. I got confused by the cross compilation section because it’s the same for the other platforms but not for linux.

Yeah I’m not sure why linuxbsd isn’t listed as an available platform, did you install a mold version for x86_64? did you install glibc for x86_64? A virtual machine sounds like a good path to have a stable linux environment.

The other platforms do not have a RISC-V section because so far linux is the only operating system that has been built for RISC-V. RISC-V is an architecture like ARM64 or x86_64, it is not a platform by itself. Cross compiling linux is not related to, nor does it require RISC-V.