How can I find all Clang versions installed on my Mac?

回眸只為那壹抹淺笑 提交于 2020-06-29 04:49:15

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/55464544/how-can-i-find-all-clang-versions-installed-on-my-mac

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!