1
clang --version
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

which clang
/usr/bin/clang

I'm on Mac, 10.13.6, any instructions would be appreciated!

Fisher Coder
  • 3,278
  • 12
  • 49
  • 84

1 Answers1

3

You can use which -a clang to list all of the clangs on your PATH. Ones which aren't on your PATH, like if you've installed Clang somewhere out of the ordinary, won't be shown.

A complication is that /usr/bin/clang is actually a trampoline that launches the clang within the currently active developer dir, selected by xcode-select or the DEVELOPER_DIR environment variable. So, knowing that /usr/bin/clang is there doesn't tell you either which one it will bounce to or which other versions could be activated. xcrun -f clang will tell the first (which will be bounced to). To my knowledge, there's no way to get Apple's tools to list out the possible developer dirs. So, if you have multiple versions of Xcode (or the Command Line Tools) installed, which -a clang won't see them.

A more reliable way would be to search the file system. You could use find / -type f -perm +a+x -name clang, but that will be slow. The other thing you can try is Spotlight, but I find that the internals of Xcode app bundles are not indexed.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • I did `which -a clang`, and output is `/usr/bin/clang`, and your explanation is very thorough and makes total sense, thanks! – Fisher Coder Apr 02 '19 at 20:12