Skip to content

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Jul 4, 2024

This PR began as an attempt to drop GCC support, after repeated reports
on fallouts when trying to use it on macOS.

Then it transformed into a 3-week project turning up the issues causing
the fallouts, ending up including llvm and all available Xcode / macOS
SDK, macOS runner image, build tools and compiler vendors and versions.
Accumulating 400 sub-commits.

I developed and tested all fixes under this PR, then merged them as
separate patches.

This PR retained CI jobs updates, extensively reworking and extending
them: [1]

At first it seemed GCC and the Apple SDK is "naturally" growing more
incompatible, as Apple added further non-standard features to their
headers. This is partly true, but reality is more complicated.

Besides some issues local to curl, there were bugs in Apple SDK
headers, Homebrew GCC builds, feature missing in the old llvm version
pre-installed on GitHub CI runner images, and subtle incompatibilities
between GCC and llvm/clang when handling language extensions.

Resulting compiler errors seldom pointed to a useful direction, and
internet search was silent about these issues too. Thus, I had to peel
them off layer by layer, using trial and error, and by recognizing
patterns of failures accross 150-200 builds combinations. Exposing
configure logs, and curl_config.h in the CI logs helped too.

  1. GCC header compatibility layer ("hack" as GCC calls it)

The toughest issue is GCC's built-in compatibility layer:
https://github.com/gcc-mirror/gcc/tree/master/fixincludes

This patch layer is further patched by a "Darwin compatibility" project
applied on top by Homebrew GCC via:
https://github.com/iains/gcc-12-branch
https://github.com/iains/gcc-13-branch
https://github.com/iains/gcc-14-branch

The hack layer is designed in a way that breaks more builds than it
fixes, esp. in context of GHA runners. The idea is to build GCC
specifically for the SDK for the target macOS version. The problem with
this approach is that the Xcode + SDK installed on the local/CI machine
often does not match with the SDK used on while building GCC on
Homebrew's build machines. In these cases the GCC compatibility layer
turns into an "uncompatibility" layer and consistently breaks builds.
curl cannot offer a fix for this, because the solution (I found) is to
patch the toolchain on the local machine. I implemented this for our CI
builds and curl-for-win. In other case the user must do this patching
manually, or choose a compatible GCC + Xcode/SDK combination.

An upstream fix doesn't seem trivial either, because the issue is
ingrained in the compatibility layer's design. Offering an -fapplesdk
(or recognizing -target) option and/or fixing them within the compiler
would seem like a more robust option, and also how mainline llvm solves
this.

Here's a table summarizing the GCC + SDK combinations and curl build
failures: [2]

More info: #10356 (comment)

db135f8 #14119 macos: add workaround for gcc, non-c-ares, IPv6, compile error
Ref: curl/curl-for-win@e2db3c4
Ref: curl/curl-for-win@f5c58d7

  1. Homebrew GCC's availability extension

A recent minor Homebrew GCC upgrade caused major breakage. The "Darwin
compatibility" patch applied to GCC implemented the availability
compiler attribute in GCC. Apple SDK detected this and enabled using
them, but as it turns out GCC accepts compiler attributes with slightly
different rules than llvm/clang, and how the Apple SDK uses them,
breaking builds.

Affected Homebrew GCC versions are: 12.4.0, 13.3.0 and 14.1.0.

Possibly tracked here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796
More info: llvm/llvm-project#81767

Commit implementing the availability macro:
gcc-12: iains/gcc-12-branch@fd5530b
gcc-13: iains/gcc-13-branch@cb7e4ec
gcc-14: iains/gcc-14-branch@ff62a10

That applied to Homebrew GCC (12.4.0):
Homebrew/homebrew-core@b904223#diff-89dd0b4176eca7fcc24b591943509bf8a8d6ea904d71e5dfcd6b78fed62fc574R44-R48

Ref: #13700
More info: #14091 (comment)

e91fcba #14155 macos: undo availability macro enabled by Homebrew gcc

  1. Proprietary Apple SDK macros

Apple SDK expects certain macros predefined by the compiler. Missing
them may causes odd issues. Mainline llvm is keeping up with Apple
clang, but it needs a fresh version, while the one installed on GitHub
runners is old (v15). I patched these in lib/curl_setup.h.

baa3270 #14134 build: fix llvm 16 or older + Xcode 15 or newer, and gcc

  1. Apple SDK header bug

Without certain predefined macros, SDK headers can take a codepath where
it mis-defines its own TARGET_OS_OSX macro, which makes it break its
own headers later. I patched it in lib/curl_setup.h.

ff784af #14159 build: fix llvm 17 and older + macOS SDK 14.4 and newer

  1. TargetConditionals.h requires sys/types.h

Fixed in curl. It caused feature-detection failurs with autotools, and
could break builds in certain configurations.

e1f6192 #14130 configure: fix SystemConfiguration detection

  1. Differences between autotools and CMake compiler options

Fixed it by syncing compiler warning options.

59cadac #14128 build: sync warning options between autotools, cmake & compilers

  1. Differences between autotools and CMake dependency detection

Fixed it by improving detection of libidn2, with some more fixes
pending for the next feature window.

f43adc2 #14137 cmake: detect libidn2 also via pkg-config
Ref: #14136 cmake: detect nghttp2 via pkg-config, enable by default

  1. libidn2 detection bug with CMake

Fixed the root cause and also the trigger in the CI config.

764fbab #14175 cmake: fix builds with detected libidn2 lib but undetected header

  1. Suppressed compiler warnings inside Apple-specific curl code

Fixed these warnings, which allowed to stop silencing them.

b05dc7e #14122 sectransp: fix HAVE_BUILTIN_AVAILABLE checks to not emit warnings
5fa534b #14162 sectransp: fix clang compiler warnings, stop silencing them

  1. CMake mis-detecting a CA bundle path on macOS

d2ef625 #14182 cmake: sync CA bundle/path detection with autotools

  1. Failure to build tests with LibreSSL or wolfSSL with CMake

Fixed by dropping unnecessary includes, makign test builds dependent
on dependency headers.

3765d75 #14172 cmake: fix building unit1600 due to missing ssl/openssl.h

  1. curl tests with CMake

curl's CMake was missing bits for running the C preprocessor accurately.
It made tests 1119 and 1167 fail. I implemented the missing bits.

efc2c51 #14124 tests: include current directory when running test Perl commands
c09db8b #14129 cmake: create configurehelp.pm like autotools does
67cc1e3 #14125 test1119: adapt for .md input

  1. GCC missing __builtin_available() support

curl source code assumes this is available to enable certain codepaths.
It's also intermixed with monotonic timer support.

  1. Monotonic timer support with GCC

Detected by GCC, while it probably shouldn't be. llvm/clang detects it
depending on target OS version. I've been playing with this, but so far
without a conclusion or fix.

  1. Runtime/test failures with GCC

I couldn't find the reason for most of this. A bunch of RTSP tests fail
with GCC. SecureTransport + HTTP/2 is failing a bunch of tests. With
OpenSSL it fails two of those. SecureTransport builds also fail one DoH
test.

  1. Runtime/test failure in llvm/clang

AppleIDN support received a fix with two more remaining.

fd02508 #14179 #14176 IDN: fix ß with AppleIDN

  1. Other issues found and fixed while working on this:

2c15aa5 GHA/macos: delete misplaced CFLAGS, drop redundant CMake option
80fb7c0 #14126 configure: limit SystemConfiguration test to non-c-ares, IPv6 builds
cfd6f43 #14127 build: tidy up __builtin_available feature checks (Apple)
bae5553 #14174 runtests: show name and keywords for failed tests in summary
09cdf7e #14178 cmake: delete unused HAVE_LIBSSH2, HAVE_LIBSOCKET macros
d3595c7 #14186 configure: CA bundle/path detection fixes
58772b0 #14187 runtests: set SOURCE_DATE_EPOCH to fix failing around midnight
18f1cd7 #14183 tests: sync feature names with curl -V
4c22d97 #14181 build: use #error instead of invalid syntax

Pending merges:

Summary:

In general GCC doesn't seem to be a good fit with curl and macOS for
now. These "lucky" combinations (GitHub Actions runner) will build out
of the box now: macos-14 + Xcode 15.0.1 + gcc-11, gcc-12, gcc-14. The
rest builds with the ugly workaround in place, but all this still leaves
some runtime issues.

More info and links in the commit messages and source code.

[1]: This PR:

  • add info about target OS version requirements per feature, with OS
    names and release years.
  • stop using -Wno-deprecated-declarations to suppress warnings.
  • use LDFLAGS=-w to suppress 'object file was built for newer macOS
    version than being linked' warnings.
    (there were tens of thousands of them in some jobs)
  • allow overriding Xcode version in all jobs.
  • improve job names.
  • abbreviate CMake as CM, autotools as AM for more compact job names.
  • shorten job names by using ! instead of no- and non-.
  • bump parellel tests to 10 (from 5).
  • drop using --enable-maintainer-mode ./configure option.
  • add gcc-12 no-ssl, autotools job with tests, ignore failing test
    results. (It's not yet clear why gcc-12 builds have different runtime
    results than clang/llvm ones.)
  • add comments with OS names and release years next to version numbers,
    e.g. 10.15 # Catalina (2019)
  • fix broken gcc-12 SecureTransport build.
  • show compiler, Xcode, SDK, gcc hack SDK versions, Homebrew
    preinstalled packages and C compiler predefined macros for each job.
    Useful for debugging all the strange problems these builds might have.
  • merge brew bundle and install steps.
  • move step names to the top.
  • dump configure log for both cmake and autotools also for successful
    builds. Useful for debugging.
  • dump curl_config.h in short (sorted #defines) and full form.
  • add support for the mainline llvm compiler.
  • set sysroot for gcc and llvm.
  • add timeout for cmake jobs.
  • add new job matrix: combinations
    It supports building all possible compiler, runner image, Xcode/SDK
    combinations, with cmake and autotools, target OS versions and with or
    without SecureTransport. It's quick. GHA limits the maximum number of
    matrix jobs at 256.
    I used this as a test-rig to fix the macOS build fallouts with gcc and
    llvm.
    I settled with 16 jobs, trying to maximize fallout coverage.
  • implement hack to make Homebrew gcc work with all available SDKs.
  • add handy mini-table about Xcode / SDK versions, OS names, years for
    each GHA images, with the defaults.
  • add tests for cmake jobs.
  • make cmake config hack to link GnuTLS less intrusive.
  • stop ignoring test 1452, seems fine now.
  • fix to enable libpsl in autotools builds.
  • enable libpsl in cmake builds.
  • add an llvm job with tests (both autotools and cmake).
  • delete similar macOS jobs from Circle CI. GHA is now arm64 too.

[2]: Homebrew GCC vs GHA runner images vs curl builds:

macOS      Xcode   gcc         gcc SDK hacks      Xcode SDK   SDK major Build Compile
          *default (Homebrew)  (CommandLineTools)             versions        error
--------  -------- ----------  ------------------ ----------  --------- ----- ---------------------
macos-12   13.1    GCC 11.4.0  MacOSX12           MacOSX12.0
macos-12   13.2.1  GCC 11.4.0  MacOSX12           MacOSX12.1
macos-12   13.3.1  GCC 11.4.0  MacOSX12           MacOSX12.3
macos-12   13.4.1  GCC 11.4.0  MacOSX12           MacOSX12.3
macos-12   14.0.1  GCC 11.4.0  MacOSX12           MacOSX12.3
macos-12   14.1    GCC 11.4.0  MacOSX12           MacOSX13.0  MISMATCH  FAIL  /Applications/Xcode_14.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/os/object.h:275:1: error: expected ';' before 'extern'
macos-12  *14.2    GCC 11.4.0  MacOSX12           MacOSX13.1  MISMATCH  FAIL  /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/os/object.h:275:1: error: expected ';' before 'extern'
macos-13   14.1    GCC 11.4.0  MacOSX13           MacOSX13.0
macos-13   14.2    GCC 11.4.0  MacOSX13           MacOSX13.1
macos-13   14.3.1  GCC 11.4.0  MacOSX13           MacOSX13.3
macos-13  *15.0.1  GCC 11.4.0  MacOSX13           MacOSX14.0  MISMATCH  FAIL  /Applications/Xcode_15.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h:103:1: error: unknown type name 'dispatch_queue_t'
macos-13   15.1    GCC 11.4.0  MacOSX13           MacOSX14.2  MISMATCH  FAIL  /Applications/Xcode_15.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h:103:1: error: unknown type name 'dispatch_queue_t'
macos-13   15.2    GCC 11.4.0  MacOSX13           MacOSX14.2  MISMATCH  FAIL  /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h:103:1: error: unknown type name 'dispatch_queue_t'
macos-14   14.3.1  GCC 11.4.0  MacOSX14           MacOSX13.3  MISMATCH  FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-14  *15.0.1  GCC 11.4.0  MacOSX14           MacOSX14.0
macos-14   15.1    GCC 11.4.0  MacOSX14           MacOSX14.2
macos-14   15.2    GCC 11.4.0  MacOSX14           MacOSX14.2
macos-14   15.3    GCC 11.4.0  MacOSX14           MacOSX14.4
macos-14   15.4    GCC 11.4.0  MacOSX14           MacOSX14.5
macos-14   16.0    GCC 11.4.0  MacOSX14           MacOSX15.0  MISMATCH  FAIL  /opt/homebrew/Cellar/gcc@11/11.4.0/lib/gcc/11/gcc/aarch64-apple-darwin23/11/include-fixed/stdio.h:83:8: error: unknown type name 'FILE'
macos-12   13.1    GCC 12.4.0  MacOSX12           MacOSX12.0
macos-12   13.2.1  GCC 12.4.0  MacOSX12           MacOSX12.1
macos-12   13.3.1  GCC 12.4.0  MacOSX12           MacOSX12.3
macos-12   13.4.1  GCC 12.4.0  MacOSX12           MacOSX12.3
macos-12   14.0.1  GCC 12.4.0  MacOSX12           MacOSX12.3
macos-12   14.1    GCC 12.4.0  MacOSX12           MacOSX13.0  MISMATCH  FAIL  /Applications/Xcode_14.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/os/object.h:275:1: error: expected ';' before 'extern'
macos-12  *14.2    GCC 12.4.0  MacOSX12           MacOSX13.1  MISMATCH  FAIL  /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/os/object.h:275:1: error: expected ';' before 'extern'
macos-13   14.1    GCC 12.4.0  MacOSX13           MacOSX13.0
macos-13   14.2    GCC 12.4.0  MacOSX13           MacOSX13.1
macos-13   14.3.1  GCC 12.4.0  MacOSX13           MacOSX13.3
macos-13  *15.0.1  GCC 12.4.0  MacOSX13           MacOSX14.0  MISMATCH  FAIL  /Applications/Xcode_15.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h:103:1: error: unknown type name 'dispatch_queue_t'
macos-13   15.1    GCC 12.4.0  MacOSX13           MacOSX14.2  MISMATCH  FAIL  /Applications/Xcode_15.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h:103:1: error: unknown type name 'dispatch_queue_t'
macos-13   15.2    GCC 12.4.0  MacOSX13           MacOSX14.2  MISMATCH  FAIL  /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h:103:1: error: unknown type name 'dispatch_queue_t'
macos-14   14.3.1  GCC 12.4.0  MacOSX14           MacOSX13.3  MISMATCH
macos-14  *15.0.1  GCC 12.4.0  MacOSX14           MacOSX14.0
macos-14   15.1    GCC 12.4.0  MacOSX14           MacOSX14.2
macos-14   15.2    GCC 12.4.0  MacOSX14           MacOSX14.2
macos-14   15.3    GCC 12.4.0  MacOSX14           MacOSX14.4
macos-14   15.4    GCC 12.4.0  MacOSX14           MacOSX14.5
macos-14   16.0    GCC 12.4.0  MacOSX14           MacOSX15.0  MISMATCH  FAIL  /opt/homebrew/Cellar/gcc@12/12.4.0/lib/gcc/12/gcc/aarch64-apple-darwin23/12/include-fixed/stdio.h:83:8: error: unknown type name 'FILE'
macos-12   13.1    GCC 13.3.0  MacOSX12           MacOSX12.0
macos-12   13.2.1  GCC 13.3.0  MacOSX12           MacOSX12.1
macos-12   13.3.1  GCC 13.3.0  MacOSX12           MacOSX12.3
macos-12   13.4.1  GCC 13.3.0  MacOSX12           MacOSX12.3
macos-12   14.0.1  GCC 13.3.0  MacOSX12           MacOSX12.3
macos-12   14.1    GCC 13.3.0  MacOSX12           MacOSX13.0  MISMATCH  FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-12  *14.2    GCC 13.3.0  MacOSX12           MacOSX13.1  MISMATCH  FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-13   14.1    GCC 13.3.0  MacOSX13           MacOSX13.0
macos-13   14.2    GCC 13.3.0  MacOSX13           MacOSX13.1
macos-13   14.3.1  GCC 13.3.0  MacOSX13           MacOSX13.3
macos-13  *15.0.1  GCC 13.3.0  MacOSX13           MacOSX14.0  MISMATCH  FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-13   15.1    GCC 13.3.0  MacOSX13           MacOSX14.2  MISMATCH  FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-13   15.2    GCC 13.3.0  MacOSX13           MacOSX14.2  MISMATCH  FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-14   14.3.1  GCC 13.3.0  MacOSX14           MacOSX13.3  MISMATCH  FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-14  *15.0.1  GCC 13.3.0  MacOSX14           MacOSX14.0            FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-14   15.1    GCC 13.3.0  MacOSX14           MacOSX14.2            FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-14   15.2    GCC 13.3.0  MacOSX14           MacOSX14.2            FAIL  /Users/runner/work/curl/curl/bld/lib/curl_config.h:792:19: error: two or more data types in declaration specifiers
macos-14   15.3    GCC 13.3.0  MacOSX14           MacOSX14.4
macos-14   15.4    GCC 13.3.0  MacOSX14           MacOSX14.5
macos-14   16.0    GCC 13.3.0  MacOSX14           MacOSX15.0  MISMATCH  FAIL  /opt/homebrew/Cellar/gcc@13/13.3.0/lib/gcc/13/gcc/aarch64-apple-darwin23/13/include-fixed/stdio.h:83:8: error: unknown type name 'FILE'
macos-12   13.1    GCC 14.1.0  MacOSX12           MacOSX12.0
macos-12   13.2.1  GCC 14.1.0  MacOSX12           MacOSX12.1
macos-12   13.3.1  GCC 14.1.0  MacOSX12           MacOSX12.3
macos-12   13.4.1  GCC 14.1.0  MacOSX12           MacOSX12.3
macos-12   14.0.1  GCC 14.1.0  MacOSX12           MacOSX12.3
macos-12   14.1    GCC 14.1.0  MacOSX12           MacOSX13.0  MISMATCH  FAIL  /Applications/Xcode_14.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/os/object.h:275:1: error: expected ';' before 'extern'
macos-12  *14.2    GCC 14.1.0  MacOSX12           MacOSX13.1  MISMATCH  FAIL  /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/os/object.h:275:1: error: expected ';' before 'extern'
macos-13   14.1    GCC 14.1.0  MacOSX13           MacOSX13.0
macos-13   14.2    GCC 14.1.0  MacOSX13           MacOSX13.1
macos-13   14.3.1  GCC 14.1.0  MacOSX13           MacOSX13.3
macos-13  *15.0.1  GCC 14.1.0  MacOSX13           MacOSX14.0  MISMATCH  FAIL  /Applications/Xcode_15.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h:70:1: error: type defaults to 'int' in declaration of 'DISPATCH_DECL_FACTORY_CLASS_SWIFT' [-Wimplicit-int]
macos-13   15.1    GCC 14.1.0  MacOSX13           MacOSX14.2  MISMATCH  FAIL  /Applications/Xcode_15.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h:70:1: error: type defaults to 'int' in declaration of 'DISPATCH_DECL_FACTORY_CLASS_SWIFT' [-Wimplicit-int]
macos-13   15.2    GCC 14.1.0  MacOSX13           MacOSX14.2  MISMATCH  FAIL  /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h:70:1: error: type defaults to 'int' in declaration of 'DISPATCH_DECL_FACTORY_CLASS_SWIFT' [-Wimplicit-int]
macos-14   14.3.1  GCC 14.1.0  MacOSX14           MacOSX13.3  MISMATCH
macos-14  *15.0.1  GCC 14.1.0  MacOSX14           MacOSX14.0
macos-14   15.1    GCC 14.1.0  MacOSX14           MacOSX14.2
macos-14   15.2    GCC 14.1.0  MacOSX14           MacOSX14.2
macos-14   15.3    GCC 14.1.0  MacOSX14           MacOSX14.4
macos-14   15.4    GCC 14.1.0  MacOSX14           MacOSX14.5
macos-14   16.0    GCC 14.1.0  MacOSX14           MacOSX15.0  MISMATCH  FAIL  /opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:83:8: error: unknown type name 'FILE'

Source: https://github.com/curl/curl/actions/runs/9883956647/job/27299564218

Closes #14097

@vszakats vszakats added build CI Continuous Integration appleOS specific to an Apple operating system labels Jul 4, 2024
@vszakats vszakats changed the title GHA: drop gcc 12 macOS jobs GHA: drop gcc 12 macOS jobs due to incompatibility Jul 4, 2024
Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to agree, keeping them around is now only causing us grief

@vszakats vszakats changed the title GHA: drop gcc 12 macOS jobs due to incompatibility GHA: drop gcc 12 macOS jobs due to incompatible SDK Jul 4, 2024
@vszakats
Copy link
Member Author

vszakats commented Jul 4, 2024

What's strange is that I cannot find any meaningful reference about this fallout on the internet, though something like this should hit elsewhere too.

On the other hand I also cannot spot anything (obvious) in curl that could trigger such error. In theory an innocent typedef or keyword redefine could do this.

Also lib/macos.c is doing one single SDK call, and I wonder if there is any other way to implement it:
31f631a #7121
1a5e41d #7128 #7129

In particular, #7128 also reported a GCC fallout, and that one was fixed by replacing one SDK header with another.
That report calls out lib/macos.c as fixing "a obscure, rare edge case".

Also related:
8b7cbe9 #11502 #11516

@vszakats
Copy link
Member Author

vszakats commented Jul 4, 2024

Also noting that such innocent typedef / keyword-redefine may also occur in a dependency header.

Like for example in this wolfSSL case with byte: d68a121

Though this fallout is unrelated to the TLS backend:
https://github.com/curl/curl/actions/runs/9791701214

As for the runner images:
working: https://github.com/actions/runner-images/blob/macos-14-arm64/20240625.2/images/macos/macos-14-arm64-Readme.md
failing: https://github.com/actions/runner-images/blob/macos-14-arm64/20240701.9/images/macos/macos-14-arm64-Readme.md

Notably GCC 12.4.0 (over 12.3.0):

--- macos-14-arm64-Readme-0625.md
+++ macos-14-arm64-Readme-0701.md
@@ -6,7 +6,7 @@
 # macOS 14
 - OS Version: macOS 14.5 (23F79)
 - Kernel Version: Darwin 23.5.0
-- Image Version: 20240625.2
+- Image Version: 20240701.9
 
 ## Installed Software
 
@@ -16,11 +16,11 @@
 - Clang/LLVM 14.0.3
 - Clang/LLVM (Homebrew) 15.0.7 - available on `$(brew --prefix llvm@15)/bin/clang`
 - GCC 11 (Homebrew GCC 11.4.0) - available by `gcc-11` alias
-- GCC 12 (Homebrew GCC 12.3.0) - available by `gcc-12` alias
+- GCC 12 (Homebrew GCC 12.4.0) - available by `gcc-12` alias
 - GCC 13 (Homebrew GCC 13.3.0) - available by `gcc-13` alias
 - GCC 14 (Homebrew GCC 14.1.0_1) - available by `gcc-14` alias
 - GNU Fortran 11 (Homebrew GCC 11.4.0) - available by `gfortran-11` alias
-- GNU Fortran 12 (Homebrew GCC 12.3.0) - available by `gfortran-12` alias
+- GNU Fortran 12 (Homebrew GCC 12.4.0) - available by `gfortran-12` alias
 - GNU Fortran 13 (Homebrew GCC 13.3.0) - available by `gfortran-13` alias
 - GNU Fortran 14 (Homebrew GCC 14.1.0_1) - available by `gfortran-14` alias
 - Kotlin 2.0.0-release-341
@@ -34,7 +34,7 @@
 - Bundler 2.5.14
 - Carthage 0.39.1
 - CocoaPods 1.15.2
-- Homebrew 4.3.7
+- Homebrew 4.3.8
 - NPM 10.7.0
 - NuGet 6.3.1.1
 - Pip3 24.0 (python 3.12)
@@ -51,7 +51,7 @@
 - 7-Zip 17.05
 - aria2 1.37.0
 - azcopy 10.25.1
-- bazel 7.2.0
+- bazel 7.2.1
 - bazelisk 1.20.0
 - bsdtar 3.5.3 - available by 'tar' alias
 - Curl 8.6.0
@@ -69,19 +69,19 @@
 - zstd 1.5.6
 
 ### Tools
-- AWS CLI 2.17.1
-- AWS SAM CLI 1.119.0
+- AWS CLI 2.17.5
+- AWS SAM CLI 1.120.0
 - AWS Session Manager CLI 1.2.633.0
 - Azure CLI 2.61.0
 - Azure CLI (azure-devops) 1.0.1
 - Bicep CLI 0.28.1
 - Cmake 3.29.6
-- CodeQL Action Bundle 2.17.5
+- CodeQL Action Bundle 2.17.6
 - Fastlane 2.221.1
 - SwiftFormat 0.54.0
 - Xcbeautify 2.4.0
 - Xcode Command Line Tools 15.3.0.0.1.1708646388
-- Xcodes 1.4.1
+- Xcodes 1.5.0
 
 ### Linters
 
@@ -139,13 +139,13 @@
 
 #### PowerShell Modules
 - Az: 12.0.0
-- Pester: 5.6.0
+- Pester: 5.6.1
 - PSScriptAnalyzer: 1.22.0
 
 ### Xcode
 | Version          | Build    | Path                           |
 | ---------------- | -------- | ------------------------------ |
-| 16.0 (beta)      | 16A5171c | /Applications/Xcode_16.0.app   |
+| 16.0 (beta)      | 16A5171r | /Applications/Xcode_16.0.app   |
 | 15.4             | 15F31d   | /Applications/Xcode_15.4.app   |
 | 15.3             | 15E204a  | /Applications/Xcode_15.3.app   |
 | 15.2             | 15C500b  | /Applications/Xcode_15.2.app   |
@@ -198,17 +198,17 @@
 | Simulator - watchOS 10.4                                | watchsimulator10.4                            | 15.3          |
 | Simulator - watchOS 10.5                                | watchsimulator10.5                            | 15.4          |
 | Simulator - watchOS 11.0                                | watchsimulator11.0                            | 16.0          |
-| visionOS 1.0                                            | xros1.0                                       | 15.2          |
 | Simulator - visionOS 1.0                                | xrsimulator1.0                                | 15.2          |
-| Simulator - visionOS 1.1                                | xrsimulator1.1                                | 15.3          |
+| visionOS 1.0                                            | xros1.0                                       | 15.2          |
 | visionOS 1.1                                            | xros1.1                                       | 15.3          |
+| Simulator - visionOS 1.1                                | xrsimulator1.1                                | 15.3          |
 | Simulator - visionOS 1.2                                | xrsimulator1.2                                | 15.4          |
 | visionOS 1.2                                            | xros1.2                                       | 15.4          |
 | visionOS 2.0                                            | xros2.0                                       | 16.0          |
 | Simulator - visionOS 2.0                                | xrsimulator2.0                                | 16.0          |
 | Asset Runtime SDK for macOS hosts targeting watchOS 9.4 | assetruntime.host.macosx.target.watchos9.4    | 14.3.1        |
-| Asset Runtime SDK for macOS hosts targeting iOS 16.4    | assetruntime.host.macosx.target.iphoneos16.4  | 14.3.1        |
 | Asset Runtime SDK for macOS hosts targeting tvOS 16.4   | assetruntime.host.macosx.target.appletvos16.4 | 14.3.1        |
+| Asset Runtime SDK for macOS hosts targeting iOS 16.4    | assetruntime.host.macosx.target.iphoneos16.4  | 14.3.1        |
 | DriverKit 22.4                                          | driverkit22.4                                 | 14.3.1        |
 | DriverKit 23.0                                          | driverkit23.0                                 | 15.0.1        |
 | DriverKit 23.2                                          | driverkit23.2                                 | 15.1, 15.2    |

@vszakats
Copy link
Member Author

vszakats commented Jul 4, 2024

Another interesting pattern is that it only affects CMake builds!

autotools jobs with the new image compile without issues:
https://github.com/curl/curl/actions/runs/9791701214/job/27036027532#step:10:254

This may mean Unity-related, or something CMake-specific.

@vszakats
Copy link
Member Author

vszakats commented Jul 4, 2024

@vszakats vszakats force-pushed the gha-macos-del-gcc branch from e57b6cc to c9a9d42 Compare July 4, 2024 16:10
@vszakats
Copy link
Member Author

vszakats commented Jul 4, 2024

Also not cmake related, it's just that we don't have an autotools job with gcc. (Despite calling gcc, but that's an alias for clang.)

@vszakats vszakats force-pushed the gha-macos-del-gcc branch from 1338a02 to 35593dd Compare July 4, 2024 17:25
@vszakats
Copy link
Member Author

vszakats commented Jul 4, 2024

Disabling CURL_MACOS_CALL_COPYPROXIES for gcc causes these:

TESTFAIL: These test cases failed: 567 568 569 570 571 572 577 689 1156 1539 3100

Ref: https://github.com/curl/curl/actions/runs/9797774554/job/27055046618?pr=14097#step:13:3647

edit: Nope, these fail with any gcc build.

@vszakats vszakats force-pushed the gha-macos-del-gcc branch from 35593dd to 8877523 Compare July 4, 2024 17:38
@github-actions github-actions bot added the cmake label Jul 4, 2024
@vszakats vszakats force-pushed the gha-macos-del-gcc branch 2 times, most recently from 22e3cc7 to ec72f3a Compare July 4, 2024 20:05
@vszakats
Copy link
Member Author

vszakats commented Jul 4, 2024

The best fix I could figure out is this ugly hack:

--- a/lib/macos.c
+++ b/lib/macos.c
@@ -30,7 +30,14 @@
 
 #include "macos.h"
 
+#if defined(__clang__)
 #include <SystemConfiguration/SCDynamicStoreCopySpecific.h>
+#else
+#include <CoreFoundation/CFDictionary.h>
+typedef const struct CF_BRIDGED_TYPE(id) __SCDynamicStore * SCDynamicStoreRef;
+CFDictionaryRef __nullable
+SCDynamicStoreCopyProxies(SCDynamicStoreRef __nullable store);
+#endif
 
 CURLcode Curl_macos_init(void)
 {

It works by avoiding the system headers that are incompatible at
various points depending on gcc and SDK version.

Another option is to find an alternative hack in place of what is
currently used in lib/macos.c.

Last but not least c-ares builds seem to be immune to this, because
they don't use the hack in lib/macos.c. Also non-IPv6 builds, that
doesn't seem much useful.

SecureTransport builds also require system headers and these
remain broken.

Also it turns out that a bunch of tests fail in macOS + gcc builds.
I haven't looked into it:

  • RTSP(all)
  • 1156
    --- log/check-expected	2024-07-04 20:16:35
    +++ log/check-generated	2024-07-04 20:16:35
    @@ -1 +1,3 @@
    -0[LF]
    +4: bad error code (22): resume=no, fail=no, http416=yes, content-range=no, expected=0[LF]
    +5: bad error code (22): resume=no, fail=no, http416=yes, content-range=yes, expected=0[LF]
    +1[LF]
  • 1539 – curl_easy_setopt() failed, with code 1 (Unsupported protocol)
    /* speak HTTP 1.0 - no chunked! */
    easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

@vszakats
Copy link
Member Author

vszakats commented Jul 4, 2024

Here's a CI run with gcc 11, 12, 13, 14 with SDK 14:
https://github.com/curl/curl/actions/runs/9800272567/job/27061944370?pr=14097

  • 11.4.0 works
  • 12.4.0 fails at CF_INLINE
  • 13.3.0 fails at __API_AVAILABLE2 and thousands of other places
  • 141.0 fails at CF_INLINE

Is there anyone who can make some sense out of this?

@vszakats
Copy link
Member Author

vszakats commented Jul 5, 2024

An even more bizarre run, with gcc 11, 12, 13, 14 on macos-12, 13, 14(latest) runners with both OpenSSL and SecureTransport.

There is a separate issue with gcc 11 + macos-14 + SecureTransport and autotools, where SystemConfiguration framework is not linked, and tests fail to link due to unresolved SCDynamicStoreCopyProxies symbol. This is caused by broken detection in CURL_DARWIN_SYSTEMCONFIGURATION: https://github.com/curl/curl/actions/runs/9800981762/job/27063595813#step:9:6351

TL;DR:

  1. gcc and Xcode don't mix well in recent years.
  2. the proxy hack added to lib/macos.c is a source of many problems.

@vszakats vszakats force-pushed the gha-macos-del-gcc branch from 036a09d to dd0b584 Compare July 5, 2024 00:32
@vszakats
Copy link
Member Author

vszakats commented Jul 5, 2024

So, while this patch for the hack restores some GCC compatibility, the compatibility situation between GCC and macOS SDK is fuzzy enough to make such builds fragile and overall impractical.

  1. SecureTransport builds are affected. It is easy to fix by not using this backend. It's on its way out anyway.
  2. For other builds these are the options:
    • Drop the hack lib/macos.c calling into SCDynamicStoreCopyProxies altogether.
      Is there a replcement for it? Will there be other hacks in the future when curl needs to call into an Apple framework?
      Can this call perhaps be made dynamically?
    • Disable the hack for GCC builds.
    • Apply the ugly patch for the hack, which fixes it for now with no loss of functionality.
    • Drop GCC support for macOS builds.

What do we prefer?

@vszakats vszakats force-pushed the gha-macos-del-gcc branch 6 times, most recently from a480435 to a186cb9 Compare July 5, 2024 20:54
@vszakats vszakats deleted the gha-macos-del-gcc branch July 18, 2024 23:28
@vszakats

This comment was marked as resolved.

@vszakats vszakats restored the gha-macos-del-gcc branch July 19, 2024 10:39
@vszakats vszakats reopened this Jul 19, 2024
@vszakats vszakats closed this in c349bd6 Jul 19, 2024
@vszakats
Copy link
Member Author

OK, did a revert and a re-issue.

@vszakats vszakats deleted the gha-macos-del-gcc branch July 19, 2024 10:47
vszakats added a commit that referenced this pull request Jul 29, 2024
This feature test always fails on non-Apple systems. (For Apple targets
it's supported by llvm and Apple clang.)

Syncs behaviour with CMake.

Follow-up to cfd6f43 #14127
Cherry-picked from #14097
Closes #14196
vszakats added a commit that referenced this pull request Aug 3, 2024
- also detect nghttp2 via `pkg-config` to match nghttp3 detection
  and autotools.

- enable nghttp2 by default to match autotools.

Cherry-picked from #14097
Closes #14136
vszakats added a commit to vszakats/curl that referenced this pull request Nov 8, 2024
As discovered earlier, Homebrew gcc is built against a specific Apple
SDK and doesn't work when matched up with a different SDK, e.g. the
one advertised as default by the macos runner image.

Before this patch this was resolved with brute force by zapping the
hack-layer gcc component to avoid the bad interference. This worked
for us, but it's fragile, accidental and doesn't translate to any
real-world build environment. Thus, impractical.

This patch avoids this by explicitly configuring the SDK gcc was built
for and meant to be used with.

It assumes that the gcc binaries preinstalled on the runner images
always ship with the SDK version they reference. It's non-trivial to
guarantee that given the different build/release/update cycles of the
projects involved, but since this is the only officially supported
way to use them, hopefully this is ensured to be kept in sync.
Since we don't do `brew update`, there is emphasis on preinstalled.

In curl-for-win CI jobs we do `brew update` and expect that scenario
to work too.

Follow-up to c349bd6 curl#14097
vszakats added a commit that referenced this pull request Nov 8, 2024
As discovered earlier, Homebrew gcc is built against a specific Apple
SDK version and doesn't work when matched up with a different version,
e.g. the one advertised as default by the macos runner image.

Before this patch this was resolved with brute force by zapping the
hack-layer gcc component to avoid the bad interference. This worked
for us, but it's fragile, accidental and doesn't translate to
real-world build environments. Thus, impractical.

Avoid this by explicitly selecting the SDK version gcc was built for and
meant to be used with, as shown by `gcc --print-sysroot`.

It assumes that the gcc binaries preinstalled on the runner images
always ship with the SDK version they reference. It also assumes
this works with and without `brew update`.

Also:
- add 4 quick build-only jobs to test all gcc/macos combos.
- list SDKs offered via CommandLineTools.

Suggested-by: Bo Anderson
Ref: Homebrew/homebrew-core#194778 (comment)

Follow-up to c349bd6 #14097
Closes #15518
vszakats added a commit that referenced this pull request Mar 6, 2025
It fixes tests 1539, and 2402, 2404 (for non-Secure Transport), on macOS
with the gcc compiler.

Also unignore these tests in GHA/macos for non-secure transport.

Ref: c349bd6 #14097 (issue 15.)
Ref: 7b0240c #16539
Ref: 2ec0037 #16482

Closes #16580
vszakats added a commit that referenced this pull request Mar 6, 2025
To fix this test on macOS with the gcc compiler.

Also unignore test 1156 in GHA/macos.

Ref: c349bd6 #14097 (issue 15.)
Ref: 7b0240c #16539
Ref: 2ec0037 #16482

Closes #16579
vszakats added a commit that referenced this pull request Mar 6, 2025
It runs fine now. Tested in all gcc-12 jobs after temporarly enabling
debug in them all (test 2100 requires debug-enabled).

Ref: c349bd6 #14097 (issue 15.)

Closes #16582
vszakats added a commit that referenced this pull request Mar 6, 2025
Before this patch `--http2` did not work in gcc builds with Secure
Transport, because ALPN relied on a compiler supporting the
`HAVE_BUILTIN_AVAILABLE` aka `__builtin_available()` feature. This
is clang-specific and missing from gcc (as of gcc v14).

Add support for ALPN and HTTP/2 when this compiler feature is missing.

Also drop test exceptions from GHA/macos in CI.

Follow-up to 092f681
Ref: c349bd6 #14097 (issue 15.)
Ref: #4314

Closes #16581
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
As discovered earlier, Homebrew gcc is built against a specific Apple
SDK version and doesn't work when matched up with a different version,
e.g. the one advertised as default by the macos runner image.

Before this patch this was resolved with brute force by zapping the
hack-layer gcc component to avoid the bad interference. This worked
for us, but it's fragile, accidental and doesn't translate to
real-world build environments. Thus, impractical.

Avoid this by explicitly selecting the SDK version gcc was built for and
meant to be used with, as shown by `gcc --print-sysroot`.

It assumes that the gcc binaries preinstalled on the runner images
always ship with the SDK version they reference. It also assumes
this works with and without `brew update`.

Also:
- add 4 quick build-only jobs to test all gcc/macos combos.
- list SDKs offered via CommandLineTools.

Suggested-by: Bo Anderson
Ref: Homebrew/homebrew-core#194778 (comment)

Follow-up to c349bd6 curl#14097
Closes curl#15518
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
It fixes tests 1539, and 2402, 2404 (for non-Secure Transport), on macOS
with the gcc compiler.

Also unignore these tests in GHA/macos for non-secure transport.

Ref: c349bd6 curl#14097 (issue 15.)
Ref: 7b0240c curl#16539
Ref: 2ec0037 curl#16482

Closes curl#16580
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
To fix this test on macOS with the gcc compiler.

Also unignore test 1156 in GHA/macos.

Ref: c349bd6 curl#14097 (issue 15.)
Ref: 7b0240c curl#16539
Ref: 2ec0037 curl#16482

Closes curl#16579
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
It runs fine now. Tested in all gcc-12 jobs after temporarly enabling
debug in them all (test 2100 requires debug-enabled).

Ref: c349bd6 curl#14097 (issue 15.)

Closes curl#16582
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
Before this patch `--http2` did not work in gcc builds with Secure
Transport, because ALPN relied on a compiler supporting the
`HAVE_BUILTIN_AVAILABLE` aka `__builtin_available()` feature. This
is clang-specific and missing from gcc (as of gcc v14).

Add support for ALPN and HTTP/2 when this compiler feature is missing.

Also drop test exceptions from GHA/macos in CI.

Follow-up to 092f681
Ref: c349bd6 curl#14097 (issue 15.)
Ref: curl#4314

Closes curl#16581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

appleOS specific to an Apple operating system build CI Continuous Integration cmake cmdline tool tests

Development

Successfully merging this pull request may close these issues.

2 participants