Building GCC on Macintosh

19 Apr 2018

gcc-8-20180415:
C, C++, Fortran bootstrap built successfully.
C40 2017.04: 4.0GHz i7 QC, 8MB L3, 16GB 1866MHz, 3.1TB Fusion, M395+2GB, 5120x2880, G+802.11ac.
36 minutes 39 seconds, 5.82 GB, 105136 files.

gcc-7-20180412:
C, C++, Fortran bootstrap built successfully.
C40 2017.04: 4.0GHz i7 QC, 8MB L3, 16GB 1866MHz, 3.1TB Fusion, M395+2GB, 5120x2880, G+802.11ac.
31 minutes 6 seconds, 5.46 GB, 99305 files.


10 Apr 2018

gcc-8-20180408:
C, C++, Fortran bootstrap built successfully.
C40 2017.04: 4.0GHz i7 QC, 8MB L3, 16GB 1866MHz, 3.1TB Fusion, M395+2GB, 5120x2880, G+802.11ac.
36 minutes 48 seconds, 5.82 GB, 105072 files.

https://twitter.com/danallen46/status/983792188277440513


6 Apr 2018

gcc-8-20180401:
C, C++, Fortran bootstrap built successfully.
C40 2017.04: 4.0GHz i7 QC, 8MB L3, 16GB 1866MHz, 3.1TB Fusion, M395+2GB, 5120x2880, G+802.11ac.
38 minutes 47 seconds, 5.82 GB, 104983 files.


31 Mar 2018

gcc-8-20180325:
C, C++, Fortran bootstrap built successfully.
C40 2017.04: 4.0GHz i7 QC, 8MB L3, 16GB 1866MHz, 3.1TB Fusion, M395+2GB, 5120x2880, G+802.11ac.
37 minutes 26 seconds, 5.82 GB, 104928 files.

gcc-7-20180329:
C, C++, Fortran bootstrap built successfully.
C31 2013.12: 3.1GHz i7, 8MB L3, 16GB 1600MHz, 1.1TB Fusion, GT750M 1GB, 1920x1080, G+802.11ac.
36 minutes 34 seconds, 5.46 GB, 99274 files.


21 Mar 2018

I built gcc-8-20180318 today on my iMac 27" (4.0 GHz i7, 16 GB RAM, 3 TB Fusion). I used macOS 10.13.3 and the Xcode 9.2 command line toolset (Apple clang-900.39.2). It took 37 minutes 48 seconds to do a triple bootstrap build of C, C++, and Fortran. It resulted in 104,835 files using 5.78 GB of drive space.


19 Mar 2018

I built the latest snapshots of gcc-7 and gcc-8 today. I used macOS 10.13.3 and the Xcode 9.2 command line tools.
gcc-7-20180315 built fine in 37m 9s on a 3.1GHz i7 iMac.
gcc-8-20180311 built fine in 36m 15s on a 4.0GHz i7 iMac.

https://twitter.com/danallen46/status/975775233507442689


8 Mar 2018

I bootstrap built gcc-8-20180304 (C, C++, Fortran) ok in 36m 57s.
104,658 files used 5.72 GB for the build.
iMac 27", 4.0 GHz i7, 16 GB RAM, 3 TB Fusion, macOS 10.13.3, Xcode 9.2.

https://twitter.com/danallen46/status/971819963743813632


11 Aug 2016

Update: I built gcc-6.1 using Xcode 7.3.1's command-line tools and did not have to make this fix. gcc-6.1 bootstrapped itself perfectly without any issues.


4 Jun 2016

Fix for building gcc-4.8.5 using Xcode 7

Building gcc-4.8.5 with Apple's Xcode 7 on the Mac will not complete due to a bug in gcc code generating some assembly language that Xcode 7 will not allow, while earlier versions of Xcode worked. If you are using an earlier Xcode before El Capitan 10.11, this fix is therefore not needed.

So to fix this problem, in the source file:


  gcc-4.8.5/gcc/config/darwin.c

there is the darwin_mark_decl_preserved function. All you need to do is to add one line of code to the start of the function. The fixed function in its entirety is shown below, with the change noted by my DKA comment.

void
darwin_mark_decl_preserved (const char *name)
{
  if (darwin_label_is_anonymous_local_objc_name (name)) return; /* DKA 4 Jun 2016 */
  fprintf (asm_out_file, "\t.no_dead_strip ");
  assemble_name (asm_out_file, name);
  fputc ('\n', asm_out_file);
}

You should be able to do a

  ./configure
  make -j8
and a while later have a working C, C++, and Fortran compiler. I have personally built gcc-4.8.5 using Xcode 7.3.1 successfully once I made this fix.

I did not invent the fix. I found the fix here:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66523
 Created:  4 Jun 2016
Modified: 19 Apr 2018