Skip to content

LLVM / Clang system config file setting breaks with -no-canonical-prefixes #220757

Open
@chandlerc

Description

@chandlerc

brew gist-logs <formula> link OR brew config AND brew doctor output

> brew config
HOMEBREW_VERSION: 4.4.31
ORIGIN: https://github.com/Homebrew/brew
HEAD: 0046519c08cd3967e0934c82195361ac7e76c567
Last commit: 5 days ago
Branch: stable
Core tap JSON: 19 Apr 21:14 UTC
Core cask tap JSON: 19 Apr 21:14 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 3.3.8 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.8/bin/ruby
CPU: deca-core 64-bit arm_firestorm_icestorm
Clang: 16.0.0 build 1600
Git: 2.39.5 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.4-arm64
CLT: 16.3.0.0.1.1742442376
Xcode: 16.2
Rosetta 2: false

> brew doctor
Your system is ready to brew.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

Use clang with the flag -no-canonical-prefixes, which results in generally better paths by preserving useful symlinks, and has worked for many years.

What happened (include all command output)?

> echo "int main() {}" | clang -c -o test.o -x c -

> clang -o test test.o -v
Homebrew clang version 20.1.3
Target: arm64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/20.1.3/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin24.cfg
System configuration file directory: /opt/homebrew/etc/clang
User configuration file directory: /Users/chandlerc/.config/clang
 "/usr/bin/ld" -demangle -lto_library /opt/homebrew/Cellar/llvm/20.1.3/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 15.0.0 15.4 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -mllvm -enable-linkonceodr-outlining -o test test.o -lSystem /opt/homebrew/Cellar/llvm/20.1.3/lib/clang/20/lib/darwin/libclang_rt.osx.a

> clang -no-canonical-prefixes -o test test.o -v
Homebrew clang version 20.1.3
Target: arm64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
System configuration file directory: /opt/etc/clang
User configuration file directory: /Users/chandlerc/.config/clang
 "/usr/bin/ld" -demangle -lto_library /opt/homebrew/opt/llvm/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 15.0.0 15.0.0 -mllvm -enable-linkonceodr-outlining -o test test.o -lSystem /opt/homebrew/opt/llvm/lib/clang/20/lib/darwin/libclang_rt.osx.a
ld: library 'System' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Note that in the failing execution the system configuration file directory becomes /opt/etc/clang instead of /opt/homebrew/etc/clang. The result is that it fails to find the configuration file and include the relevant SDK paths.

What did you expect to happen?

Both clang invocations should find the configuration directory and succeed.

Step-by-step reproduction instructions (by running brew commands)

The above should be a complete sequence of steps to reproduce. Requires having `llvm` installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedTask(s) needing PRs from the community or maintainersupstream issueAn upstream issue report is needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions