Skip to content

Change LLVM detection on macOS#1123

Merged
marcoroth merged 1 commit intomarcoroth:mainfrom
citizen428:macos-clang-detection
Feb 5, 2026
Merged

Change LLVM detection on macOS#1123
marcoroth merged 1 commit intomarcoroth:mainfrom
citizen428:macos-clang-detection

Conversation

@citizen428
Copy link
Contributor

This PR changes how clang, clang-tidy, etc., are detected on macOS without requiring any changes for current users.

Rationale:
Not everyone uses Homebrew in this way. I personally only use it for application formulae and kegs, and manage my dev dependencies with Nix flakes (which is also what motivated #1120).

Proposed solution:
Use the Homebrew prefix by default on macOS, as it's a sensible choice. Users who install clang and friends some other way can probably figure out how to override the values as required for their environment (either by exporting environment variables or directly in the make invocation).

Verification:
I temporarily added the following task to the Makefile:

debug_cc:
	@echo "os:            $(os)"
	@echo "cc:            $(cc)"
	@echo "clang_format:  $(clang_format)"
	@echo "clang_tidy:    $(clang_tidy)"
	@echo "test_cflags:   $(test_cflags)"
	@echo "test_ldflags:  $(test_ldflags)"

I ran this before and after making the changes in this PR, the generated output was identical for the Homebrew use case:

❯ diff -s cc.old.txt cc.new.txt
Files cc.old.txt and cc.new.txt are identical

Notes:

  1. The debug_cc target could be generally useful, also for Linux users. If you want, I can add it to either this PR or separately.
  2. It's a sort of convention in Makefiles to call the variables CC, CFLAGS, etc. This is primarily because they can be overridden from the environment, and lower-case environment variables look a bit odd. However, I decided not to change this in this PR, as it's not really related to the problem I'm trying to solve here.

@citizen428 citizen428 mentioned this pull request Feb 5, 2026
@marcoroth
Copy link
Owner

marcoroth commented Feb 5, 2026

Thanks for opening this pull request!

The reason why we have been so "strict" about the exact clang, clang-format, clang-tidy binaries is because we have been seeing some differences in behavior on different versions of these tools.

Sometimes things would fail locally but not in CI, and the other way around. So we have been trying to be super intentional in the versions we use so the environment matches as close as possible.

That said, I know that this can be annoying and might not be relevant enough for most use cases. This was also in the earlier days of the project, so maybe it's not as relevant anymore and we can relax the constraints a bit so it's easier for people to set up the project.

@marcoroth marcoroth merged commit 296cd4c into marcoroth:main Feb 5, 2026
24 checks passed
@citizen428
Copy link
Contributor Author

I understand. Just to be clear, I am using the exact versions the project specifies, I just don't provide them through Homebrew but the equivalent Nix packages instead.

@citizen428 citizen428 deleted the macos-clang-detection branch February 5, 2026 12:41
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