Building GCC on arm macOS

Iain Sandoe iain@sandoe.co.uk
Wed Feb 17 13:50:26 GMT 2021


Roman Bolshakov <r.bolshakov@yadro.com> wrote:

> On Wed, Feb 17, 2021 at 10:35:59AM +0000, Iain Sandoe wrote:
>> Roman Bolshakov <r.bolshakov@yadro.com> wrote:
>>
>>> stage1 of GCC build (master branch as of yesterday) fails with the error:
>>>
>>> *** Configuration aarch64-apple-darwin20.3.0 not supported
>>> make[2]: *** [configure-stage1-gcc] Error 1
>>> make[1]: *** [stage1-bubble] Error 2
>>> make: *** [all] Error 2
>>>
>>> Is it expected issue?
>>
>> Yes, that’s expected (it is not a bug).
>>
>>> I had impression that GCC works on Apple Silicon
>>> macs.
>>
>> There is an experimental branch here :
>> https://github.com/iains/gcc-darwin-arm64
>>
>> but it is not yet ready for inclusion in GCC master,

> Thanks for the reference.
> I'm trying to build from your master-wip-apple-si branch and it doesn't
> build too:
>
> The directory that should contain system headers does not exist:
>  /usr/include

(this is not specific to Arm64 - it applies to building for x86_64 on  
modern macOS).

These days (on macOS) there are no headers installed in /usr/include even  
when the developer tools are installed.

So, you have to configure a path to the SDK [which contains the headers and  
the library stubs] (from, say, an installation of the command line tools -  
or from Xcode).

Two approaches:

1) [this is what I tend to use]

Install the command line tools.
Now there will be an SDK at  
/Library/Developer/CommandLineTools/SDKs/MacOS.sdk

so you can configure with…
/path/to/source/configure —prefix=….  
—with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOS.sdk ….

2) You can ask where the SDK is for an installation with Xcode only.

/path/to/source/configure —prefix=…. —with-sysroot=`xcrun —show-sdk-path`  ….

====

In general, it is best not to add configuration options unles you know  
*why* you’re adding them - but for modern macOS, it is a good idea to avoid  
the default install path /usr/local … most people install now into /opt/…..

You can find general information on building GCC here :  
https://gcc.gnu.org/install/

=====

My configure lines look like this:

/src-local/gcc-master/configure  
--prefix=/opt/iains/aarch64-apple-darwin20/gcc-11-0-0  
--build=aarch64-apple-darwin20  
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk  
--disable-libstdcxx-pch --enable-languages=all

and you can see some test results here:

https://github.com/iains/gcc-darwin-arm64/issues/30

HTH,
Iain



More information about the Gcc-help mailing list