Skip to content

Add macOS (Apple Silicon) Docker build script#53

Open
noafroboy wants to merge 3 commits intoopen64-compiler:developfrom
noafroboy:macos-build-script
Open

Add macOS (Apple Silicon) Docker build script#53
noafroboy wants to merge 3 commits intoopen64-compiler:developfrom
noafroboy:macos-build-script

Conversation

@noafroboy
Copy link

Summary

  • Add build-open64-docker.sh: a fully automated build script for compiling Open64 inside Docker on macOS with Apple Silicon
  • Add a "Building on macOS" section to the README

What the script does

The script runs a complete Open64 build in two Docker containers:

  1. ARM64 container (native): builds and runs the targ_info generators (isa_gen, targ_si_gen, etc.) to produce pre-generated headers. These generators segfault under Rosetta x86_64 emulation, so they must run natively.

  2. x86_64 container (Rosetta): runs the full configure + build using the pre-generated targ_info files. Runtime libraries are built with LIB_BUILD_COMPILER=GNU to avoid using the freshly-built opencc, which also crashes under Rosetta.

The script auto-detects CPU cores and RAM, installs all dependencies (LLVM/Clang 11, build tools) inside the container, and caches pre-generated files for faster reruns.

Dependencies

This script works best with the following companion PRs (which fix build issues on modern Linux):

Test plan

  • On macOS (Apple Silicon) with Docker Desktop + Rosetta: ./build-open64-docker.sh completes all 6 steps
  • Verify opencc binary exists: docker exec open64-build ls /build/osprey/targdir/driver/opencc
  • Script is idempotent: re-running skips targ_info generation when cached files exist

🤖 Generated with Claude Code

noafroboy and others added 3 commits February 28, 2026 22:19
Add build-open64-docker.sh, a fully automated script that builds Open64
from source on macOS (Apple Silicon) using Docker with Rosetta emulation.
The script handles:
- Pre-generating targ_info files natively on ARM64 (avoids Rosetta
  segfaults in the x86_64 host-tool generators)
- Auto-detecting available cores and RAM for optimal Docker allocation
- Installing all build dependencies (Ubuntu 20.04, LLVM 11)
- Configuring with --disable-jfe and building with system GCC for
  runtime libraries

Also add a "Building on macOS" section to the README pointing to the
script.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update build-open64-docker.sh with fixes from end-to-end testing:
- Add 'build' target to step 5 make command so it only compiles the
  compiler, not runtime libs (which crash under Rosetta with
  BUILD_COMPILER=SELF)
- Add 'set -o pipefail' to step 4 so configure failures aren't
  silently swallowed by the pipe to tail
- Fix targ_info generation: add -DTARG_X8664, compile intermediate
  .o files, and link GENERATED_OBJS incrementally (matching what the
  real build system does)

Update README to reference the build script in-repo instead of via
an external fork URL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove gcc-multilib/g++-multilib from apt-get install (not needed
  for a 64-bit-only build)
- Pass --disable-multilib to configure, which also forwards it to the
  bundled GCC via AC_CONFIG_SUBDIRS
- Remove --host/--target flags (no longer needed once the x86_64 to
  i686 downgrade is removed upstream)
- Remove make lib2 (32-bit runtime libraries not built with multilib
  disabled)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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