Skip to content

Commit cb87934

Browse files
committed
Updated for GCC 10 on Big Sur.
* README.md: updated. * gcc10-specs (*lib): added usr/lib -L paths for Xcode and Command Line Tools.
1 parent b0ebba4 commit cb87934

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

README.md

+26-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# MacOS Software Development Kit changes #
22

3-
These are experiments to cope with expected changes in Apple's approach to software development kits, specifically where to find the system headers (you'd expect `/usr/include`).
4-
53
Apple's development environment is _Xcode_. They provide a cut-down version called the Command Line Tools for those of us who don't need to develop for iPhone or Apple Watch. Xcode includes SDKs for those platforms, the Command Line Tools just for macOS (MacOSX, internally).
64

5+
## System includes ##
6+
77
Up until Mojave, the Command Line Tools (which you get by `xcode-select --install`) automatically installed `/usr/include`. Apple's developer tools (`clang` etc) know where to find the includes in the current SDK, but GCC doesn't.
88

99
With Mojave, you need to install the headers by
@@ -21,7 +21,7 @@ However, [Apple say](https://developer.apple.com/documentation/xcode_release_not
2121
2222
So, what to do about it?
2323

24-
## GNAT CE 2019 ##
24+
### GNAT CE 2019 ###
2525

2626
This work is prompted by AdaCore's GNAT GE 2019 release, which anticipates the lack of `/usr/include` by building the compiler using a system root inside the Xcode SDK:
2727
```
@@ -38,10 +38,29 @@ You can fix the second by `-I/usr/local/include`, `-L/usr/local/lib`.
3838

3939
An alternative (without installing Xcode) would be to copy `ce2109-specs` to `$prefix/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/specs` (`ce2019-specs` was generated by `gcc -dumpspecs` and judicious editing).
4040

41-
## FSF GCC ##
41+
I haven't done this for GNAT CE 2020.
42+
43+
### FSF GCC ###
44+
45+
A similar problem arises with FSF GCC, builds provided at [Sourceforge](https://sourceforge.net/projects/gnuada/files/GNAT_GCC%20Mac%20OS%20X/). So far I've been building on El Capitan, which has none of these problems, but this approach will have to stop when the built compiler won't run on new macOS versions. A problem for another day! but, for now, the built compiler needs to be taught to look in the SDK.
46+
47+
I'm providing a modified `specs` on the same lines as above. `gcc9-specs` is the version for GCC 9.1.0; it adds both possible SDKs to the include search path, GCC will take the first one it finds (absent `/usr/include`). `gcc10-specs` is included (as just `specs`) in the native GCC 10.1.0 release at Sourceforge.
48+
49+
## Big Sur and system libraries ##
4250

43-
A similar problem arises with FSF GCC, builds provided at [Sourceforge](https://sourceforge.net/projects/gnuada/files/GNAT_GCC%20Mac%20OS%20X/).
51+
With Big Sur, Apple have carried this approach through to system libraries; there's no `/usr/lib`, instead the libraries that you need to link against are in the SDKs. The symptom of this problem is that FSF GCC won't link, reporting
52+
```
53+
ld: library not found for -lSystem
54+
```
55+
and the fix is to include `-L$SDK/usr/lib` in the linker command. This is in the latest version of `gcc10-specs` (commit 244ecb2).
4456

45-
The approach I'm planning to adopt for future releases is to disable System Integrity Protection (which prevents altering important system directories, and is normally Not Recommended) and copy `usr/include` from inside whichever SDK is installed to the normal place, then build the compiler as normal.
57+
You can use this without installing by e.g. for Ada
58+
```
59+
gnatmake hello.adb -largs -specs=gcc10-specs
60+
```
61+
or for C (or C++, or Fortran!) by
62+
```
63+
gcc hello.c -specs=gcc10-specs
64+
```
4665

47-
For users who haven't done this (the majority, I expect) I'll provide a modified `specs` on the same lines. `gcc9-specs` is the version for GCC 9.1.0; it adds both possible SDKs to the include search path, GCC will take the first one it finds (absent `/usr/include`).
66+
You can install the change by copying `gcc10-specs` to `$prefix/lib/gcc/x86_64-apple-darwin15/10.1.0/specs` (note the file name change).

gcc10-specs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ cc1 -E %{traditional|traditional-cpp:-traditional-cpp}
5151
%{static}%{!static:-dynamic} %:remove-outfile(-ldl) %:remove-outfile(-lm) %:remove-outfile(-lpthread) %{fgnu-runtime: %{static|static-libgcc: %:replace-outfile(-lobjc libobjc-gnu.a%s); :%:replace-outfile(-lobjc -lobjc-gnu ) } } %{static|static-libgcc|static-libgfortran:%:replace-outfile(-lgfortran libgfortran.a%s)} %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp libgomp.a%s)} %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)} %{!Zdynamiclib: %{Zforce_cpusubtype_ALL:-arch %(darwin_arch) -force_cpusubtype_ALL} %{!Zforce_cpusubtype_ALL:-arch %(darwin_subarch)} %{Zbundle:-bundle} %{Zbundle_loader*:-bundle_loader %*} %{client_name*} %{compatibility_version*:%e-compatibility_version only allowed with -dynamiclib} %{current_version*:%e-current_version only allowed with -dynamiclib} %{Zforce_flat_namespace:-force_flat_namespace} %{Zinstall_name*:%e-install_name only allowed with -dynamiclib} %{keep_private_externs} %{private_bundle} } %{Zdynamiclib: -dylib %{Zbundle:%e-bundle not allowed with -dynamiclib} %{Zbundle_loader*:%e-bundle_loader not allowed with -dynamiclib} %{client_name*:%e-client_name not allowed with -dynamiclib} %{compatibility_version*:-dylib_compatibility_version %*} %{current_version*:-dylib_current_version %*} %{Zforce_cpusubtype_ALL:-arch %(darwin_arch)} %{!Zforce_cpusubtype_ALL: -arch %(darwin_subarch)} %{Zforce_flat_namespace:%e-force_flat_namespace not allowed with -dynamiclib} %{Zinstall_name*:-dylib_install_name %*} %{keep_private_externs:%e-keep_private_externs not allowed with -dynamiclib} %{private_bundle:%e-private_bundle not allowed with -dynamiclib} } %{Zall_load:-all_load} %{Zallowable_client*:-allowable_client %*} %{Zbind_at_load:-bind_at_load} %{Zarch_errors_fatal:-arch_errors_fatal} %{Zdead_strip:-dead_strip} %{Zno_dead_strip_inits_and_terms:-no_dead_strip_inits_and_terms} %{Zdylib_file*:-dylib_file %*} %{Zdynamic:-dynamic} %{Zexported_symbols_list*:-exported_symbols_list %*} %{Zflat_namespace:-flat_namespace} %{headerpad_max_install_names} %{Zimage_base*:-image_base %*} %{Zinit*:-init %*} %{mmacosx-version-min=*:-macosx_version_min %*} %{nomultidefs} %{Zmulti_module:-multi_module} %{Zsingle_module:-single_module} %{Zmultiply_defined*:-multiply_defined %*} %{!Zmultiply_defined*:%{shared-libgcc: %:version-compare(< 10.5 mmacosx-version-min= -multiply_defined) %:version-compare(< 10.5 mmacosx-version-min= suppress)}} %{Zmultiplydefinedunused*:-multiply_defined_unused %*} %{prebind} %{noprebind} %{nofixprebinding} %{prebind_all_twolevel_modules} %{read_only_relocs} %{sectcreate*} %{sectorder*} %{seg1addr*} %{segprot*} %{Zsegaddr*:-segaddr %*} %{Zsegs_read_only_addr*:-segs_read_only_addr %*} %{Zsegs_read_write_addr*:-segs_read_write_addr %*} %{Zseg_addr_table*: -seg_addr_table %*} %{Zfn_seg_addr_table_filename*:-seg_addr_table_filename %*} %{sub_library*} %{sub_umbrella*} %{isysroot*:-syslibroot %*} %{twolevel_namespace} %{twolevel_namespace_hints} %{Zumbrella*: -umbrella %*} %{undefined*} %{Zunexported_symbols_list*:-unexported_symbols_list %*} %{Zweak_reference_mismatches*:-weak_reference_mismatches %*} %{!Zweak_reference_mismatches*:-weak_reference_mismatches non-weak} %{w} %{pagezero_size*} %{segs_read_*} %{seglinkedit} %{noseglinkedit} %{sectalign*} %{sectobjectsymbols*} %{segcreate*} %{whyload} %{whatsloaded} %{dylinker_install_name*} %{dylinker}
5252

5353
*lib:
54-
%{!static:-lSystem}
54+
%{!static:-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem}
5555

5656
*link_gomp:
5757

0 commit comments

Comments
 (0)