From 6879bbc23ff131a399d632c9a6948ce2e1b933e0 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 13:43:47 -0500 Subject: [PATCH 01/12] remove unneeded stuffs --- platforms/macos/build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 5dbe09b7e..7f5d79ec0 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -202,7 +202,6 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th cd "cctools-port-$cctools_commit/cctools" ./configure \ - --target="$ppc_triple" \ --enable-silent-rules \ --with-llvm-config=false \ CC=remcpe-clang \ @@ -293,7 +292,7 @@ for target in $targets; do cc="$platformdir/macos-cc" cxx="$platformdir/macos-c++" case $arch in - (i386|powerpc*) + (i386|powerpc*|ppc*) if [ "$arch" = 'i386' ]; then target_cflags="$cflags -march=pentium-m" set -- -DCMAKE_EXE_LINKER_FLAGS='-framework IOKit -framework Carbon -framework AudioUnit -undefined dynamic_lookup' From fe5892be30f56c627cf6e8d29a1e148dc9913d24 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 15:19:11 -0500 Subject: [PATCH 02/12] fix x86_64 build on linux --- platforms/macos/build.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 7f5d79ec0..288ed02c5 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -66,6 +66,22 @@ else ncpus="$(sysctl -n hw.ncpu)" fi +if [ "$(uname -s)" = "Darwin" ]; then + ar="${AR:-ar}" + ranlib="${RANLIB:-ranlib}" +else + ar="${AR:-"llvm-ar"}" + ranlib="${RANLIB:-"llvm-ranlib"}" +fi + +for var in ar ranlib; do + dep="$(eval "echo \$$var")" + if ! command -v "$dep" >/dev/null; then + printf '%s not found!\n' "$dep" + exit 1 + fi +done + for dep in "${CLANG:-clang}" make cmake; do if ! command -v "$dep" >/dev/null; then printf '%s not found!\n' "$dep" @@ -291,6 +307,8 @@ for target in $targets; do arch="${target%%-*}" cc="$platformdir/macos-cc" cxx="$platformdir/macos-c++" + target_ar="$ar" + target_ranlib="$ranlib" case $arch in (i386|powerpc*|ppc*) if [ "$arch" = 'i386' ]; then @@ -300,6 +318,8 @@ for target in $targets; do target_cflags= cc="$target-gcc" cxx="$target-g++" + target_ar="cctools-ar" + target_ranlib="cctools-ranlib" set -- -DCMAKE_EXE_LINKER_FLAGS='-framework IOKit -framework Carbon -framework AudioUnit -static-libgcc' fi export REMCPE_SDK="$old_sdk" @@ -375,8 +395,8 @@ for target in $targets; do -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ - -DCMAKE_AR="$(command -v cctools-ar)" \ - -DCMAKE_RANLIB="$(command -v cctools-ranlib)" \ + -DCMAKE_AR="$(command -v "$target_ar")" \ + -DCMAKE_RANLIB="$(command -v "$target_ranlib")" \ -DCMAKE_C_COMPILER="$cc" \ -DCMAKE_CXX_COMPILER="$cxx" \ -DCMAKE_FIND_ROOT_PATH="$REMCPE_SDK/usr;$PWD/sdl" \ From 0997b1e5dddae87a60f315751b7650f6fa97f649 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 16:01:09 -0500 Subject: [PATCH 03/12] fully use lto on ppc --- platforms/macos/build.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 288ed02c5..169f23772 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -316,6 +316,9 @@ for target in $targets; do set -- -DCMAKE_EXE_LINKER_FLAGS='-framework IOKit -framework Carbon -framework AudioUnit -undefined dynamic_lookup' else target_cflags= + if [ -n "$DEBUG" ]; then + target_cflags='-flto' + fi cc="$target-gcc" cxx="$target-g++" target_ar="cctools-ar" @@ -337,11 +340,7 @@ for target in $targets; do if [ -n "$DEBUG" ]; then opt='-O0' else - if [ "$arch" = 'i386' ]; then - opt='-O2' - else - opt='-O2 -flto' - fi + opt='-O2' fi if [ "$arch" != 'i386' ]; then sed -e 's/-fpascal-strings//g' configure > configure.patched From a7240c825ff43ec4ba654e44abba4f38c0424b8d Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 16:48:52 -0500 Subject: [PATCH 04/12] strip gcc --- platforms/macos/build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 169f23772..13670d092 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -218,6 +218,7 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th cd "cctools-port-$cctools_commit/cctools" ./configure \ + --target=ppc \ --enable-silent-rules \ --with-llvm-config=false \ CC=remcpe-clang \ @@ -262,9 +263,10 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th RANLIB_FOR_TARGET="$(command -v cctools-ranlib)" \ NM_FOR_TARGET="$(command -v ppc-nm)" \ LIPO_FOR_TARGET="$(command -v lipo)" \ + STRIP_FOR_TARGET="$(command -v ppc-strip)" \ "$@" make -j"$ncpus" - make -j"$ncpus" install + make -j"$ncpus" install-strip cd ../.. rm -rf "gcc-$gcc_version" From 356d17c5fc5301d877b93c15b707a797d5d8b7d6 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 17:03:34 -0500 Subject: [PATCH 05/12] fix --- platforms/macos/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 13670d092..84db060f6 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -359,8 +359,8 @@ for target in $targets; do CFLAGS="$opt $target_cflags" \ CXXFLAGS="$opt $target_cflags" \ CPPFLAGS='-DNDEBUG' \ - AR=cctools-ar \ - RANLIB=cctools-ranlib + AR="$target_ar" \ + RANLIB="$target_ranlib" make -j"$ncpus" make install -j"$ncpus" cd .. From 7d1f36bcc625a31b8d9183ba0e4ccee9886048f2 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 17:24:26 -0500 Subject: [PATCH 06/12] consistency --- platforms/macos/build.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 84db060f6..6425b8552 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -171,7 +171,6 @@ if [ -n "$outdated_toolchain" ]; then make -C ar strip ar/ar mv ar/ar ../../toolchain/bin/cctools-ar - cd ../.. rm -rf "cctools-port-$cctools_commit" @@ -234,7 +233,6 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th make -C as/ppc -j"$ncpus" strip as/ppc/ppc-as mv as/ppc/ppc-as ../../toolchain-ppc/bin/ppc-as - cd ../.. rm -rf "cctools-port-$cctools_commit" From 1d79ae9a5df25141905f3ef51d476bb6f4be5ac6 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 20:57:17 -0500 Subject: [PATCH 07/12] lto is enabled by default --- platforms/macos/build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 6425b8552..190b6127a 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -251,9 +251,8 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th --prefix="$workdir/toolchain-ppc" \ --target="$ppc_triple" \ --disable-multilib \ - --enable-lto \ --with-system-zlib \ - --enable-languages=c,c++,objc,lto \ + --enable-languages=c,c++,objc \ --with-sysroot="$old_sdk" \ --with-as="$(command -v ppc-as)" \ --with-ld="$(command -v ppc-ld)" \ From 26e2cf80ca882dfef5f39556016b4706aa777295 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 21:09:54 -0500 Subject: [PATCH 08/12] clean builds when toolchains are outdated --- platforms/macos/build.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 190b6127a..250f2cf93 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -268,6 +268,7 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th rm -rf "gcc-$gcc_version" printf '%s' "$ppctoolchainver" > toolchain-ppc/toolchainver + outdated_ppc_toolchain=1 fi # checks if the linker we build successfully linked with LLVM and supports LTO, @@ -291,7 +292,10 @@ fi # Delete old build files if build settings change or if the SDK changes. printf '%s\n' "$DEBUG" > buildsettings clang -v >> buildsettings 2>&1 -if [ -n "$outdated_sdk" ] || ! cmp -s buildsettings lastbuildsettings; then +if [ -n "$outdated_sdk" ] || + [ -n "$outdated_toolchain" ] || + [ -n "$outdated_ppc_toolchain" ] || + ! cmp -s buildsettings lastbuildsettings; then rm -rf build-* fi mv buildsettings lastbuildsettings From 72bd467108c4ff77d0d2050ec4e730d150b266c4 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 21:18:08 -0500 Subject: [PATCH 09/12] disable nls --- platforms/macos/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 250f2cf93..ef0fb1b16 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -251,6 +251,7 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th --prefix="$workdir/toolchain-ppc" \ --target="$ppc_triple" \ --disable-multilib \ + --disable-nls \ --with-system-zlib \ --enable-languages=c,c++,objc \ --with-sysroot="$old_sdk" \ From 2ec02ea0ed4e2cd72488d6e190f177bce5b905aa Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 21:53:58 -0500 Subject: [PATCH 10/12] fix --- platforms/macos/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index ef0fb1b16..0f4c97536 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -253,7 +253,7 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th --disable-multilib \ --disable-nls \ --with-system-zlib \ - --enable-languages=c,c++,objc \ + --enable-languages=c,c++,objc,lto \ --with-sysroot="$old_sdk" \ --with-as="$(command -v ppc-as)" \ --with-ld="$(command -v ppc-ld)" \ @@ -320,7 +320,7 @@ for target in $targets; do set -- -DCMAKE_EXE_LINKER_FLAGS='-framework IOKit -framework Carbon -framework AudioUnit -undefined dynamic_lookup' else target_cflags= - if [ -n "$DEBUG" ]; then + if [ -z "$DEBUG" ]; then target_cflags='-flto' fi cc="$target-gcc" From 92ae4110f8f09cef9e2f53f5e3f29fb86535db13 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 21:58:50 -0500 Subject: [PATCH 11/12] disable ppc lto --- platforms/macos/build.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index 0f4c97536..a97f45a32 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -253,7 +253,7 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th --disable-multilib \ --disable-nls \ --with-system-zlib \ - --enable-languages=c,c++,objc,lto \ + --enable-languages=c,c++,objc \ --with-sysroot="$old_sdk" \ --with-as="$(command -v ppc-as)" \ --with-ld="$(command -v ppc-ld)" \ @@ -320,9 +320,6 @@ for target in $targets; do set -- -DCMAKE_EXE_LINKER_FLAGS='-framework IOKit -framework Carbon -framework AudioUnit -undefined dynamic_lookup' else target_cflags= - if [ -z "$DEBUG" ]; then - target_cflags='-flto' - fi cc="$target-gcc" cxx="$target-g++" target_ar="cctools-ar" From d9fc5dbece8973802523653fde0ab57ca7778562 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Mon, 23 Feb 2026 22:44:43 -0500 Subject: [PATCH 12/12] bump version --- platforms/macos/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index a97f45a32..fcd3bfd1f 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -198,7 +198,7 @@ fi # Increase this if we ever make a change to the toolchain, for example # using a newer GCC version, and we need to invalidate the cache. -ppctoolchainver=1 +ppctoolchainver=2 ppc_triple='powerpc-apple-darwin8' targets="$targets $ppc_triple" if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; then