Which version of gcc is installed on Mac (Yosemite) - macos

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 :

Related

Using -march=native flag with clang on Apple M1 [duplicate]

Whenever I try to compile any C++ program with march=native on a Macbook with a M1 chip, I get the following error when using clang:
clang: error: the clang compiler does not support '-march=native'
However, it used to work on an older Macbook with an Intel CPU. Does clang not support this architecture (yet)?
clang --version gives:
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.2.0
In Apple clang version 13.0.0, -mcpu=apple-m1 is now available.
$ clang --print-supported-cpus
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: arm64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Available CPUs for this target:
a64fx
apple-a10
apple-a11
apple-a12
apple-a13
apple-a14
apple-a7
apple-a8
apple-a9
apple-latest
apple-s4
apple-s5
carmel
cortex-a34
cortex-a35
cortex-a53
cortex-a55
cortex-a57
cortex-a65
cortex-a65ae
cortex-a72
cortex-a73
cortex-a75
cortex-a76
cortex-a76ae
cortex-a77
cortex-a78
cortex-x1
cyclone
exynos-m3
exynos-m4
exynos-m5
falkor
generic
kryo
lightning
neoverse-e1
neoverse-n1
saphira
thunderx
thunderx2t99
thunderx3t110
thunderxt81
thunderxt83
thunderxt88
tsv110
vortex
-mcpu=apple-a14 might be the best one for M1.
As far as I know this is not Apple M1 specific, it occurs also with clang for various other architectures (mostly various other arm processors).
e.g. See this bug report here https://github.com/DMOJ/judge-server/issues/303
Basically every build of clang for a new architecture must choose to provide defaults for "march=native" for the target for which the compiler is built or not; and if not then you will see this error message. Even for those arm processors who do have optimisation targets you often have to use specifically "-mcpu=xxx" instead of "-march".
e.g. For the iphone you would use -mcpu=apple-a11 -mcpu=apple-a12 etc.
However no such target has been implemented yet for Apple M1
In Clang 15, -march=native now exists for Apple M1 (I personally use it).
another solutions is update clang with brew
lang: error: the clang compiler does not support '-march=native'
1° - Install llvm con brew
brew install llvm
2° - Check clang version
cd /opt/homebrew/opt/llvm
.clang --version
Result:
Homebrew clang version 15.0.6
Target: arm64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
3° - modify path with the new version, for example add to .zshrc
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"

How to install Clang 9 on Mac?

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.

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:

Could not exec the linker `cc` error when running "cargo build"

I just installed Rust on my Mac and rustc --version --verbose displays
rustc 1.0.0-nightly (91bdf23f5 2015-03-09) (built 2015-03-08)
binary: rustc
commit-hash: 91bdf23f504f79ed59617cde3dfebd3d5e39a476
commit-date: 2015-03-09
build-date: 2015-03-08
host: x86_64-apple-darwin
release: 1.0.0-nightly
I cloned a couple of repositories (postgres-extension and erlang-rust-nif) and ran cargo build upon both of them. Both reported the error
error: could not exec the linker `cc`: No such file or directory (os error 2)
error: aborting due to previous error
Additionally, I wasn't able to compile a simple Rust file printing "hello world" using rustc. I was only able to compile them by passing the flags rustc -C linker=gcc hello_world.rs.
clang --version displays
clang version 3.4.2 (http://llvm.org/git/llvm.git 5c6aa738fb3325ae499454877f1e2926d2368135)
Target: x86_64-apple-darwin12.2.1
Thread model: posix
gcc --version displays
gcc (Homebrew gcc49 4.9.2_1) 4.9.2
It looks like you have installed GCC and LLVM/clang via Homebrew. Checking out the shared macOS configurations, the linker defaults to cc. I have installed the macOS developer tools:
$ clang --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
$ cc --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
This is potentially something that Rust itself could fix, but you'd have to file a bug report / enhancement request. It's possible that you might be able to work around this by symlinking clang as cc, instead of just aliasing it, as aliases probably don't exist in the environment that Rust is calling out from.

port select --list gcc returns none(active)

I am running Yosemite and get xcode 6.1 installed on it. I also installed manually gcc with brew install gcc command.
However when i run port select --list gcc command, it returns the following message
Available versions for gcc:
none (active)
the gcc version shows clang with LLVM.
gcc --version
Configured with: --prefix=/Volumes/DEV/Applications/Xcode.app/Contents/Developer/usr -- with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

Resources