Compiling GCC-SVN on MacOS 10.15

It could be so easy, but with every MacOS release several things change and some break — again so with MacOS Catalina (aka MacOS 10.15).

For GCC compilation, the directory /usr/include finally is gone for good (no .pkg-file to install aftwards to make it available again — see previous entry on GCC on MacOS 10.14).

With /usr/include gone, one needs to specify the SDK’s directory containing the native system files:

--with-build-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/

The MacOS system header files have evolved. Bootstrapping the compiler fails compiling in libstdc++/libsupc++ the file atexit_thread.cc:

libtool: compile: /Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/./gcc/xgcc -shared-libgcc -B/Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/./gcc -nostdinc++ -L/Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/x86_64-apple-darwin19.0.0/libstdc++-v3/src -L/Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/x86_64-apple-darwin19.0.0/libstdc++-v3/src/.libs -L/Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/x86_64-apple-darwin19.0.0/libstdc++-v3/libsupc++/.libs -B/Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/usr/x86_64-apple-darwin19.0.0/bin/ -B/Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/usr/x86_64-apple-darwin19.0.0/lib/ -isystem /Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/usr/x86_64-apple-darwin19.0.0/include -isystem /Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/usr/x86_64-apple-darwin19.0.0/sys-include --sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/ -fno-checking -I/Users/hpcraink/DATA/SOFTWARE/gcc-svn/libstdc++-v3/../libgcc -I/Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/x86_64-apple-darwin19.0.0/libstdc++-v3/include/x86_64-apple-darwin19.0.0 -I/Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/x86_64-apple-darwin19.0.0/libstdc++-v3/include -I/Users/hpcraink/DATA/SOFTWARE/gcc-svn/libstdc++-v3/libsupc++ -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=atexit_thread.lo -g -O2 -c ../../../../libstdc++-v3/libsupc++/atexit_thread.cc -fno-common -DPIC -D_GLIBCXX_SHARED -o atexit_thread.o
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/wait.h:110,
from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdlib.h:66,
from /Users/hpcraink/DATA/SOFTWARE/gcc-svn/BUILD-MacOS/x86_64-apple-darwin19.0.0/libstdc++-v3/include/cstdlib:75,
from ../../../../libstdc++-v3/libsupc++/atexit_thread.cc:25:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/resource.h:443:34: error: expected initializer before ‘__OSX_AVAILABLE_STARTING’
443 | int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
| ^~~~~~~~~~~~~~~~~~~~~~~~

This is due to the system header’s file Availability.h not defining the macro __OSX_AVAILABLE_STARTING, since the just-compiled cc1 does not offer defined(__has_feature)

One needs to amend the header Availability.h with the following patch:

--- Availability.h 2019-11-10 15:02:48.000000000 +0100
+++ Availability.h.WORKS 2019-11-10 15:05:10.000000000 +0100
@@ -290,6 +290,12 @@
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg)
#endif
#endif
+
+ #ifndef __OSX_AVAILABLE_STARTING
+   #define __OSX_AVAILABLE_STARTING(_osx, _ios)
+   #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep)
+   #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg)
+ #endif
#endif /* __OSX_AVAILABLE_STARTING */

#else
Dieser Beitrag wurde unter Allgemein, Tec veröffentlicht. Setze ein Lesezeichen auf den Permalink.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.