Skip to content

extend/ENV/super: set CC/CXX to real names for llvm_clang#22920

Merged
cho-m merged 1 commit into
mainfrom
llvm_clang-cc
Jul 3, 2026
Merged

extend/ENV/super: set CC/CXX to real names for llvm_clang#22920
cho-m merged 1 commit into
mainfrom
llvm_clang-cc

Conversation

@cho-m

@cho-m cho-m commented Jul 2, 2026

Copy link
Copy Markdown
Member

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • AI was used to generate or assist with generating this PR.

CC=llvm_clang/CXX=llvm_clang++ can cause issues in formulae if the value of CC/CXX is saved into binaries/scripts to be used at runtime. This PR follows similar pattern in my versioned GCC PR (#22889) so that the build scripts will see the actual name of the command, i.e. CC=clang/CXX=clang++.

This is also similar to how we handle swift shim:

export CC="clang"
export CXX="clang++"
# swift_clang isn't a shim but is used to ensure the cc shim
# points to the compiler inside the swift keg
export HOMEBREW_CC="swift_clang"

To make this work, need to adjust cc shim too so that it handles LLVM Clang the same as all other compilers. Previously, it would only apply LLVM's clang++ when named llvm_clang++. Now, even if compiler is invoked as clang++, g++, etc., brew should use HOMEBREW_CC=llvm_clang forward to LLVM's clang++.


This should avoid workarounds like

I tried removing above and running brew install --cc llvm_clang ecl. Snippets of output:

checking for gcc... clang
...
libtool: compile:  clang -fPIC -fno-common -DHAVE_CONFIG_H -I../src -I/private/tmp/ecl-20260702-80027-mytn21/ecl-26.5.5/src/bdwgc/libatomic_ops/src -I/opt/homebrew/opt/gmp/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/include -I/opt/homebrew/opt/bdw-gc/include -fPIC -Wall -Wextra -Wpedantic -Wno-long-long -g -O0 -fPIC -fno-common -D_THREAD_SAFE -MT atomic_ops.lo -MD -MP -MF .deps/atomic_ops.Tpo -c /private/tmp/ecl-20260702-80027-mytn21/ecl-26.5.5/src/bdwgc/libatomic_ops/src/atomic_ops.c  -fno-common -DPIC -o atomic_ops.o

And underlying 02.make.cc.log:

clang called with: -fPIC -fno-common -DHAVE_CONFIG_H -I../src -I/private/tmp/ecl-20260702-80027-mytn21/ecl-26.5.5/src/bdwgc/libatomic_ops/src -I/opt/homebrew/opt/gmp/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/include -I/opt/homebrew/opt/bdw-gc/include -fPIC -Wall -Wextra -Wpedantic -Wno-long-long -g -O0 -fPIC -fno-common -D_THREAD_SAFE -MT atomic_ops.lo -MD -MP -MF .deps/atomic_ops.Tpo -c /private/tmp/ecl-20260702-80027-mytn21/ecl-26.5.5/src/bdwgc/libatomic_ops/src/atomic_ops.c -fno-common -DPIC -o atomic_ops.o
superenv removed:  -Wall -Wextra -Wpedantic -g -O0
superenv added:    -w -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk --sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk -isystem/opt/homebrew/include -isystem/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers -fdebug-prefix-map=/private/tmp/ecl-20260702-80027-mytn21/ecl-26.5.5=.
superenv executed: /opt/homebrew/opt/llvm/bin/clang -w -Os -fPIC -fno-common -DHAVE_CONFIG_H -I../src -I/private/tmp/ecl-20260702-80027-mytn21/ecl-26.5.5/src/bdwgc/libatomic_ops/src -I/opt/homebrew/opt/gmp/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/include -I/opt/homebrew/opt/bdw-gc/include -fPIC -Wno-long-long -fPIC -fno-common -D_THREAD_SAFE -MT atomic_ops.lo -MD -MP -MF .deps/atomic_ops.Tpo -c /private/tmp/ecl-20260702-80027-mytn21/ecl-26.5.5/src/bdwgc/libatomic_ops/src/atomic_ops.c -fno-common -DPIC -o atomic_ops.o -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk --sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk -isystem/opt/homebrew/include -isystem/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers -fdebug-prefix-map=/private/tmp/ecl-20260702-80027-mytn21/ecl-26.5.5=.

Copilot AI review requested due to automatic review settings July 2, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts Superenv’s llvm_clang compiler setup so that CC/CXX/OBJC/OBJCXX are set to the “real” compiler names (clang/clang++) while keeping HOMEBREW_CC=llvm_clang so Homebrew’s superenv shims still route builds through the LLVM toolchain when desired.

Changes:

  • Override Superenv#llvm_clang to set CC/CXX (and ObjC variants) to clang/clang++ after the standard superenv compiler selection.
  • Update the superenv cc shim to consistently choose LLVM’s clang++ when HOMEBREW_CC=llvm_clang, even if invoked under other *++ names.
  • Add a unit spec verifying the llvm_clang environment variable behavior in Superenv.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Library/Homebrew/extend/ENV/super.rb Overrides llvm_clang to rewrite CC/CXX/OBJC/OBJCXX to clang/clang++ while preserving HOMEBREW_CC.
Library/Homebrew/shims/super/cc Removes the special-case llvm_(clang...) tool selection and instead routes *++ invocations to LLVM clang++ when HOMEBREW_CC=llvm_clang.
Library/Homebrew/test/ENV_spec.rb Adds coverage for Superenv’s llvm_clang environment variable values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cho-m cho-m added this pull request to the merge queue Jul 2, 2026
Merged via the queue into main with commit 7e48071 Jul 3, 2026
44 checks passed
@cho-m cho-m deleted the llvm_clang-cc branch July 3, 2026 00:16
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.

3 participants