Skip to content

Conversation

cho-m
Copy link
Member

@cho-m cho-m commented Sep 15, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Prioritise LLVM clang over GCC on macOS. This has a higher chance of succeeding when there is no manual override of cc/cxx as many formulae are linked to libc++.

However, when the formula has a GCC dependency but no LLVM, then try GCC first. This usually means that we want GCC/libstdc++


Ideally, formulae should work by adding fails_with :clang and then depends_on "gcc" or depends_on "llvm" => :build but right now we need to manually force ENV.llvm_clang (often from gcc dep for gfortran) breaking compiler selection.

LLVM Clang is usually our 2nd preference on macOS due to libc++. And 3rd is GCC (since using GCC often causes linkage to libstdc++ or libgomp which can cause issues in dependency trees)


No changes done on Linux side for now.

@cho-m cho-m force-pushed the compilers-priority branch from 05876ee to 5e9f160 Compare September 16, 2025 02:29
@cho-m
Copy link
Member Author

cho-m commented Sep 16, 2025

I haven't been able to figure out where this test failure is happening.

  1) Homebrew::Cmd::Migrate migrates a renamed Formula
     Failure/Error:
       expect { brew "migrate", "testball1" }
         .to output(/Migrating formula testball1 to testball2/).to_stdout
         .and not_to_output.to_stderr
         .and be_a_success

       expected block to output /Migrating formula testball1 to testball2/ to stdout, but output nothing
       Diff for (output /Migrating formula testball1 to testball2/ to stdout):
       @@ -1 +1 @@
       -/Migrating formula testball1 to testball2/
       +""
     # ./test/cmd/migrate_spec.rb:15:in 'block (2 levels) in <top (required)>'
     # ./test/support/helper/spec/shared_context/integration_test.rb:50:in 'block (2 levels) in <top (required)>'

Not able to reproduce locally but is hit on re-run for CI.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

As long as we're confident the our LLVM clang compiler is (more) stable for formulae on macOS than GCC: seems good, thanks 👍🏻

However, when the formula has a GCC dependency, then try GCC first
@cho-m cho-m force-pushed the compilers-priority branch from 5e9f160 to ee4bbde Compare September 16, 2025 18:40
@cho-m
Copy link
Member Author

cho-m commented Sep 16, 2025

As long as we're confident the our LLVM clang compiler is (more) stable for formulae on macOS than GCC: seems good, thanks 👍🏻

On arm64 macOS, I would consider it more stable since GCC still needs a large patch to build.

On Intel macOS, harder to say. But we at least use LLVM Clang more than GCC in Homebrew/core (excluding Fortran parts) so it has at least been okay for the last few years.

There are still quirks to using LLVM Clang outside of superenv (due to the libc++ situation) but currently should be good for building formulae.

@MikeMcQuaid
Copy link
Member

Ok, sounds good, thanks @cho-m!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Sep 17, 2025
Merged via the queue into main with commit 43ec9b3 Sep 17, 2025
36 checks passed
@MikeMcQuaid MikeMcQuaid deleted the compilers-priority branch September 17, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants