@@ -848,7 +848,9 @@ build_single_target() {
848848 _OSVER=" $( printf ' %02d%02d' \
849849 " $( printf ' %s' " ${macminver} " | cut -d ' .' -f 1) " \
850850 " $( printf ' %s' " ${macminver} " | cut -d ' .' -f 2) " ) "
851- _CMAKE_GLOBAL+=" -DCMAKE_OSX_ARCHITECTURES=${_machines} "
851+ if [ " ${_CC} " != ' gcc' ]; then
852+ _CMAKE_GLOBAL+=" -DCMAKE_OSX_ARCHITECTURES=${_machines} "
853+ fi
852854 elif [ " ${_OS} " = ' linux' ]; then
853855 if [ " ${_HOST} " != " ${_OS} " ] || \
854856 [ " ${unamem} " != " ${_machine} " ]; then
@@ -1190,15 +1192,39 @@ build_single_target() {
11901192
11911193 # Explicitly set the SDK root.
11921194 # We set it for all build tools for macOS to gain control over this.
1193- _SYSROOT=" $( xcrun -sdk macosx --show-sdk-path) " # E.g. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
1195+ _SYSROOT=" $( xcrun -sdk macosx --show-sdk-path 2> /dev/null) " # E.g. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
1196+
1197+ # Installed/selected Xcode version and SDK version:
1198+ xcodebuild -version || true
1199+ xcrun -sdk macosx --show-sdk-path || true
11941200
1195- # Standard gcc (as of v13.2.0 and v14.1.0) fails to compile some headers in macOS SDK 13.x.
1196- # Issue: https://github.com/curl/curl/issues/10356
1197- # Revert to SDK 12.x as a workaround, e.g. /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
11981201 if [ " ${_CC} " = ' gcc' ]; then
1199- tmp=" $( echo " ${_SYSROOT} " | sed -E ' s/[0-9\.]+\.sdk$/12.sdk/g' ) "
1200- if [ -d " ${tmp} " ]; then
1201- _SYSROOT=" ${tmp} "
1202+
1203+ libgccdir=" $( dirname \
1204+ " $( " ${_CCPREFIX} gcc${_CCSUFFIX} " -print-libgcc-file-name) " ) "
1205+
1206+ if [ -d " ${libgccdir} /include-fixed" ]; then
1207+ # dump SDK major version used while building Homebrew gcc:
1208+ grep -a -h -r -E -o ' .+[0-9.]+\.sdk/' " ${libgccdir} /include-fixed" | sed -E ' s/^\t+//g' | tr -d ' "' | sort -u || true
1209+
1210+ # Homebrew gcc (as of v14.1.0) ships with set of SDK header overrides.
1211+ # These are compatible with the specific SDK version the Homebrew build
1212+ # machines used at build-time. We only know the major version number of
1213+ # that SDK, and there is no guarantee that ours (or the CI machine) has
1214+ # the same versions installed or selected. To make it work anyway, we
1215+ # zap known to be incompatible/problematic parts of the gcc hacks.
1216+
1217+ # Unbreak Homebrew gcc builds by moving problematic SDK header overlay
1218+ # directories/files out of the way:
1219+ find " ${libgccdir} /include-fixed" | sort
1220+ patch_out=' dispatch os AvailabilityInternal.h'
1221+ patch_out+=' stdio.h' # for Xcode 16 error: unknown type name 'FILE'
1222+ for f in ${patch_out} ; do
1223+ if [ -r " ${libgccdir} /include-fixed/${f} " ]; then
1224+ echo " ! Zap gcc hack: '${libgccdir} /include-fixed/${f} '"
1225+ mv " ${libgccdir} /include-fixed/${f} " " ${libgccdir} /include-fixed/${f} -BAK"
1226+ fi
1227+ done
12021228 fi
12031229 fi
12041230
0 commit comments