simonjwright / building-gcc-macos-native

Scripts for building GCC on macOS
BSD 3-Clause "New" or "Revised" License
15 stars 1 forks source link

Building GCC for macOS

This set of scripts supports building GCC Ada, or GNAT, on macOS as a native compiler, and then its supporting tools.

python3 is required. If not installed, you can download a binary from python.org.

Building

Building is done in a set of shell scripts. The scripts are to some extent order-dependent, and this is catered for here by a Makefile.

The Makefile's targets are shown in the diagram (all and basic are organisational, basic builds everything except the libadalang-related components). Dependencies

Also, to support in particular aarch64 builds of the two compiler components for Alire,

The scripts are named by adding .sh to the target.

Additionally, the script gdb.sh builds GDB (not useful on aarch64?)

Building

The common information is in common.sh, which is sourced by the other scripts and sets environment variables. Please study common.sh and edit for your circumstances.

Building on Apple silicon

Building for aarch64 is natural. Building for x86_64 requires a little more work.

The Software Development Kits (SDKs) support both architectures. Once you have an x86_64 compiler, you don't need to worry about this (fingers crossed), but for the GCC build you have to be running an x86_64 shell:

arch -x86_64 /bin/bash

(you may need to set some environment variables, expecially the PATH that picks up the build compiler).

Making

Some variables can be overridden during the make invocation:

Assuming you've got this directory in ~/building-gcc-macos-native, all your source code in ~/gcc-src/package-src, common.sh is set up,and you're going to build just gprbuild under ~/tmp/arch64, you would say in ~/tmp/aarch64

 make -f ~/building-gcc-macos-native/Makefile gprbuild \
     VERSION=14.2.0-3 BOOTSTRAP=disable

The individual components will appear in gcc/, gprconfig/, xmlada/ and gprbuild/.

Additional considerations for sources