How to install Clang 9 on Mac? - macos

Here's what I have on my Mac:
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
my app needs to be compiled with clang version 9, how can I install it on my Mac?
I went to LLVM official site, but I don't see Clang 9 there.
Any help is greatly appreciated!

I downloaded Xcode 9.2 and then did xcode-select -s /Applications/Xcode.app/Contents/Developer and then my clang --version shows Apple LLVM version 9.0.0 (clang-900.0.39.2), which is what I want.
Hope this could help others who encounter the same or similar issue.

Related

How can I upgrade the built-in Apple Clang on MacOS?

My clang on MacOS that is provided by Apple seems to be a bit outdated.
> clang -v
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
But my MacOS is up to date: MacOS Ventura 13.0.1
I have recently installed Xcode version 14.1,
but I think the Xcode developer tools (CLI tools) are installed independently.
How can I upgrade the clang that is provided by Apple on MacOS?
According to Xcode on Wikipedia it looks like the clang used by Xcode is newer.
Some command outputs:
>where clang
/usr/bin/clang
>xcode-select -p
/Library/Developer/CommandLineTools
>sudo xcode-select -r
xcode-select -p
/Applications/Xcode.app/Contents/Developer
This looks like you've got remnants of an Xcode 12.5 installation on your system.
Things I would try/check:
what does where clang say? Is it /usr/bin/clang?
what's the output of xcode-select -p? It should be something like /Applications/Xcode.app/Contents/Developer (depending on where/how you installed Xcode).
If the output doesn't look right, try xcode-select -s <path> with the path to your Xcode installation, or try resetting with xcode-select -r
running sudo xcode-select --install may force a new installation of the commandline tools
In any case, the output of clang -v on my Ventura box is
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
as one would expect.

gcc -print-multi-os-directory error on mac

My mac version is Sierra. Xcode 8.0
gcc info
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I think gcc is not problem. My project build option is -print-multi-os-directory. but my gcc unsupported... what's the problem???
thanks
on mac your GCC is Clang as you may see in output
in clang option -print-multi-os-directory is unsupported
On current trunk (line 2079)
Was marked as unsupported here
You may try to install pure gcc via brew install gcc command
Also why do you need this option? Do you have any special checks in you project ?(this option just print path )
Since you are trying to build binutils:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/configure;h=97693870c462d5e5231bd2b512a76b7c271b9133;hb=7fa393306ed8b93019d225548474c0540b8928f7#l10348
Try to figure out why you get in condition when multi-os option is used.
This happened because your compiler passed test:

Updating gcc4.2.1 to gcc6.2.0 on mac

I have already installed gcc 6.2.0 with homebrew and it is located in
/usr/local/Cellar/gcc6
I also have edited my path, so when i write
which gcc
the answer is
/usr/local/Cellar/gcc6/6.2.0/bin/gcc
Still when i want to find out which version is currently used the answer is:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.1.0
Thread model: posix
InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I dont know what else to do. Thank you for your help.

Which version of gcc is installed on Mac (Yosemite)

I am confused by what version of gcc is installed on my Mac, which is has OS X Yosemite (10.10.5) installed on it. I also have Xcode v6.3.1 installed.
Entering the commands below reveals the following info:
gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
clang -v
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
which gcc
/usr/bin/gcc
which clang
/usr/bin/clang
As far as I can tell, gcc is not aliased to clang.
Can someone please enlighten me what this means?
In newer versions of XCode gcc and clang are linked to the same binary in the SDK. clang will say that it's at least gcc 4.2, this is a little weird, but works for lots of software that checks for gcc and it is compatible in general.
echristo#dzur ~> /usr/bin/clang -v
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
echristo#dzur ~> /usr/bin/gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
If you take a look at the directory InstalledDir you can see the programs that are actually there.
I had a similar problem, I wanted to know what version of gcc should I install on my Yosemite, since most of UNIX tools need GCC it is a vital package.
if gcc -version doesn't shows the version, it means you do not have one.
you need to install a gcc first, then check for its version! funny? but according to your Xcode command line and OS version you have not a lot of options, let the brew decide which version you should install, It also installs dependencies.
To install GCC,
install Homebrew From HomeBrew Website
Open Terminal
Run command: brew install gcc
I have installed my GCC just now, here is the snapshot, notice the dependent module names and the gcc version at the following picture, they are Yosemite tailored :

Installing Clang on Mac

This is the first time I am working on Mac and I wanted to install the latest version of Clang, so I installed Xcode 5 and Xcode command line tools.
But the Clang version I got from the Xcode (in the terminal, I typed clang --version). It gives me following output:
clang++ --version
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
I am confused what Clang version it is. I read that the latest Clang is version 3.5. Is the one above similar? (I need complete support for C++11). What is the difference?
Apple uses its own version numbers for Clang and LLVM which correspond with the Xcode version they are bundled with.
The actual Clang version is in indicated by the (based on LLVM X.Xsvn) part. So you have version 3.3, which is the most recent official release as you can see from the LLVM website. That version implements all the major C++11 features as you can see from the C++ support status page.

Resources