Skip to content

Conversation

@drpaneas
Copy link

@drpaneas drpaneas commented Oct 26, 2025

This PR started for adding supporting only for Mac-arm64, however when I managed it, I've noticed linux-aarch64 was also incredibly easy to add, and also fix mac-intel which was using an outdated image (macos-12).

This has been tested and works in my Apple M2 Pro - 15.6 (24G84). It should work for others as well. I've tried to make the absolute minimum of changes possible and all the changes are in individual commits. They are affecting only Darwin arm64, so all other platforms should have absolutely zero changes (unaffected). In other words, risk merging it is minimal: all changes are platform-isolated to ARM64 macOS. That said, this PR has Zero changes to target architecture (arm-vita-eabi), Zero changes to generated binaries for PS Vita; only affects the build host environment.

I will provide some instructions to help you review this quickly but also understand the changes:

Read commits in this logical order (not chronological), so you can understand the problem I faced:

VitaSDK toolchain fails to build on Apple Silicon (M1/M2/M3) Macs due to:

  1. Autotools doesn't recognize aarch64-apple-darwin triple
  2. GMP assembly code is x86-specific
  3. Legacy zlib macros conflict with modern macOS headers
  4. GCC configure scripts have ARM64 compatibility issues

After this PR: Developers can build VitaSDK natively on ARM64 Macs.

Autotools Support

  1. 381d12a - "Fix ARM64 macOS support with conditional config file updates"

    • 📁 Creates update_config_files.sh script
    • 🎯 Review focus: Check platform detection logic is correct
  2. 68d1fca - "Fix permission error in new config.{sub,guess}"

    • 🐛 Defensive programming (chmod before overwrite)

Library Fixes

  1. 87c9446 - "fix(zlib): Remove legacy Mac fdopen workaround"

    • 🧹 Removes obsolete 1990s Metrowerks compiler code
    • 🎯 Review focus: Verify removed code is truly obsolete
  2. 85ef304 - "Fix GMP compilation on Apple Silicon by disabling assembly"

    • 🎯 Review focus: Check conditional is Darwin AND arm64
  3. 03cea05 - "Fix ARM64 macOS support for MPFR"

    • 🔧 Path correction (minor fix)

Toolchain Fixes

  1. 50a3dc9 - "fix binutils patch fdopen conflict"

    • 📄 New patch: 0004-fix-zlib-fdopen-macos.patch
    • 🎯 Review focus: Verify patch only removes problematic fdopen macro
  2. 6a13fa7 + c3b74e5 - "Fix GCC 10.3.0 build" + "Use patch; not script"

    • 📄 New patch: 0002-fix-macos-arm64.patch
    • 🎯 Review focus: Check patch addresses real compiler errors
    • 💡 Note: c3b74e5 refactors shell script → patch (improvement!)
  3. f09b66d - "Fix gdb"

    • 📄 Two patches: zlib fdopen + clang enum warnings
    • 🎯 Review focus: Verify #pragma clang diagnostic is narrowly scoped
  4. f48f0ab - "Reset libzip git repo before patching"

    • 🔄 Ensures idempotent rebuilds

What Each Component Does

🛠️ Scripts

File Purpose Platform Guard?
cmake/update_config_files.sh Downloads latest autotools config files for ARM64 recognition ✅ Yes (Darwin + arm64)

🩹 Patches

File Fixes Applies To
patches/zlib.patch Removes obsolete fdopen workaround macOS (all architectures)
patches/binutils/0004-fix-zlib-fdopen-macos.patch Same fdopen issue in binutils macOS (all architectures)
patches/gcc/0002-fix-macos-arm64.patch zlib fdopen + safe-ctype.h + config.host macOS (all architectures)
patches/gdb-zlib-fdopen-macos.patch Same fdopen issue in gdb macOS (all architectures)
patches/gdb-enum-fix.patch Suppress Clang enum warning Clang only (scoped pragma)

⚙️ CMake Changes

All changes in CMakeLists.txt:

  • Add patch commands (unconditional but idempotent)
  • Add script invocations (platform-guarded inside scripts)
  • Add GMP --disable-assembly flag (conditional: Darwin AND arm64)

How to test this

Just build it like this:

# On ARM64 Mac
cd buildscripts
mkdir build && cd build
cmake ..
make

# Expected: Successful build of complete toolchain
# Deliverable: Post build logs or success screenshot

Basic CI

Minimal: Check CI passes on existing platforms (Linux, Windows, x86_64 Mac)
Ideal: Request contributor confirm these commands succeed:

# After successful build
./build/vitasdk/bin/arm-vita-eabi-gcc --version  # Should show GCC 10.3.0
./build/vitasdk/bin/vita-elf-create --help       # Should work

The new commit here, is fixing the rest of the systems.
cdb0e19

Green CI: https://github.com/drpaneas/buildscripts/actions/runs/18910235182

Remove obsolete compiler-specific code for Metrowerks CodeWarrior
that was used back in 90s. The removed workarounds for fdopen()
and <unix.h> inclusion are no longer needed as modern macOS
(pre OS X) provides standard POSIX support.

Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
Resolves "invalid host type" errors during libelf configuration
by ensuring autotools recognizes aarch64-apple-darwin triple.

The solution is platform-specific to avoid unnecessary changes
on working systems and includes robust error handling.

Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
Conditionally disable GMP assembly optimizations on ARM64 macOS
to resolve build failures due to incompatible x86 assembly code.

GMP's platform-specific assembly doesn't support ARM64, so we
fall back to the portable C implementation on Apple Silicon M
while maintaining assembly optimizations on other platforms.

Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
- Fix zlib fdopen macro conflict with macOS headers
- Wrap safe-ctype.h macros in #ifndef __cplusplus to avoid C++ std library conflicts
- Remove -no-pie flags from configure scripts
- Add aarch64-darwin to config.host for host-darwin.o compilation
- Remove zlib .dylib files to force static linking

Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
libzip is git-cloned, and patch modifies files causing conflicts on rebuild.

Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
- Fix Linux aarch64
- Fix macOS x86_64 by patching GMP to disable assembly optimizations.
- Fix macOS arm64 by setting 4 cores instead of all of them (GH hiccup)
- Cosmetic changes for the CI

Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
@drpaneas drpaneas changed the title Add Mac arm64 support Add Mac-arm64, Linux-aarch64 support and fix mac-intel Oct 29, 2025
@drpaneas
Copy link
Author

Please review :)

Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
@drpaneas
Copy link
Author

Another successful CI run after the latest refactor to minify the changes
https://github.com/drpaneas/buildscripts/actions/runs/18959983797

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant