Skip to content

Instantly share code, notes, and snippets.

@willnode
Last active May 26, 2025 06:13
Show Gist options
  • Save willnode/88da35d0c0542276b4631746d8fc3de1 to your computer and use it in GitHub Desktop.
Save willnode/88da35d0c0542276b4631746d8fc3de1 to your computer and use it in GitHub Desktop.
Build Redox OS in MacOS Apple Silicon

This is a way to compile Redox OS in MacOS Apple Silicon using Podman.

WIP -- This gist is being updated to match with the book but specifics to MacOS Apple Silicon for top DX. For native bootstrap follow another gist (also WIP)

Clone

cd ~/Document
git clone https://gitlab.redox-os.org/redox-os/redox
cd redox
git submodule update --init --recursive
# Install necessary tooling except things that don't work
sed -i '' '/macfuse/d' ./native_bootstrap.sh
sed -i '' '/[email protected]/d' ./native_bootstrap.sh
sed -i '' '/x86_64-elf-gcc/d' ./native_bootstrap.sh
./native_bootstrap.sh -d

Setup .config

Set arch target. Write this to ./.config:

PODMAN_BUILD=1
ARCH=aarch64
CONFIG_NAME=desktop

--- section below is not updated yet ---

Patch pkgutils

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"  }

Patch binutils and gcc

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 change x86_64-unknown-redox to aarch64-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 \
		&& \

Build Prefix

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"
@Xunjin
Copy link

Xunjin commented Nov 22, 2024

Should this excerpt:

sh ./native_bootstrap.sh -d -e qemu
brew install coreutils

As right now, only native_bootstrap.sh and podman_bootstrap.sh are available

@thynus
Copy link

thynus commented Feb 16, 2025

I am going to try this out on an m3 macbook air. Thank you for putting this together! I am going to replace all the brew statements with port and see what happens.

= = = = = = =
sudo port install coreutils

bootstrap.sh not available using
native_bootstrap.sh

sh ./native_bootstrap.sh -d -e qemu

---> Configuring osxfuse
---> Building osxfuse
Error: Failed to build osxfuse: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_fuse_osxfuse/osxfuse/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port osxfuse failed

= = = = = = =

Any ideas on how to get past this point? osxfuse is version 3.8.3 but I would need version 4.8.3 (macOS 14.7) which requires security changes in my recovery environment.

@thynus
Copy link

thynus commented Feb 19, 2025

= = = = = = =
switching to ARM Ubuntu:

relibc does not compile; known problem with ARM hosts.

= = = = = = =

@willnode
Copy link
Author

Hello guys, I actually no longer recommends this approach. Please try running virtualized ubuntu if you can. I might will update this approach if i got some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment