This is a way to compile Redox OS in MacOS Apple Silicon without using podman.
git clone --recurse-submodules https://gitlab.redox-os.org/redox-os/redox.git
cd redox
sh ./bootstrap.sh -d -e qemu
brew install coreutils
Set arch target. Write this to ./.config
:
ARCH=x86_64
ARCH=aarch64 is currently not compile on relibc AFAIK
This patch has on going merge request: https://gitlab.redox-os.org/redox-os/pkgutils/-/merge_requests/40
Please patch the submodule to ./cookbook/pkgutils
.
cd ./cookbook/pkgutils
git remote set-url origin https://gitlab.redox-os.org/willnode/pkgutils.git
git checkout patch-1
git pull
Then modify these files: ./cookbook/Cargo.toml
, ./installer/Cargo.toml
[patch.crates-io]
redox_pkgutils = { path = "../cookbook/pkgutils" }
Currently, these modified components are using old upstream that doesn't support compiling with MacOS Apple Silicon.
I forked these repos and updated their upstream as needed in my personal forks. Let's use them.
mkdir -p prefix
cd prefix
git clone https://gitlab.redox-os.org/willnode/binutils-gdb
git clone https://gitlab.redox-os.org/willnode/gcc
mkdir -p x86_64-unknown-redox && cd $_
touch binutils.tar.bz2
touch gcc.tar.bz2
ln -s ../binutils-gdb binutils
ln -s ../gcc gcc
cd ./gcc && ./contrib/download_prerequisites
cd ../../..
If you use
aarch64
please changex86_64-unknown-redox
toaarch64-unknown-redox
Lastly, install GMP and put it as part of bintuils
's configure. This is because a newer utils needs it.
brew install gmp
brew info gmp
Copy its directory dir and put if on binutils
's configure. This is in file mk/prefix.mk
around line 94-99.
"$(ROOT)/$</configure" \
--target="$(TARGET)" \
--program-prefix="$(TARGET)-" \
--prefix="" \
--disable-werror \
+ --with-libgmp-prefix=/opt/homebrew/Cellar/gmp/6.2.1_1 \
&& \
After everything done, execute the build:
time make all
It will build all prefix builds..
Unfortunately, it will stop after error[E0463]: can't find crate for `std`.
. So after the build stop, comment this line in ./Makefile
:
# Cross compiler recipes
-include mk/prefix.mk
+# include mk/prefix.mk
Next we need to install gnu-tar
and set it as the alias for tar
:
brew install gnu-tar
export PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"