Reputation: 4509
There is similar question to this but I am not satisfied with the answer.
I tried installing clang. After trying to install clang I ended up with two clang. One is /usr/bin/clang or clang++ and other /opt/local/bin/clang-mp-3.3 or clang++-mp-3.3 (which I installed from macport)
They act same when I compile simple program but differently when I try to compile other big and complex C++ code. I tried reading documentation to get some overview.
Here from this ticket I was able to know macport clang is more close to gcc. I know that clang does front end job (as c type language interpreter) and llvm is back end. What and how did difference came in first place? Thank you for your time.
Upvotes: 4
Views: 1292
Reputation: 132869
There is similar question to this but I am not satisfied with the answer.
Maybe you like my answer better:
https://stackoverflow.com/a/77404955/15809
The difference in a nutshell is that Apple has an own fork of the LLVM project and the clang builds they ship with Xcode all come from that fork, which may use custom build settings, disable/enable certain optional features, and may even contain custom code patches and system adoption. So while Apple's clang is based on the LLVM clang at its core, it may contain adoption for better macOS system or Xcode IDE integration.
The build you get with MacPorts has been made from the LLVM repo and does not contain any Apple specific adoptions unless those were merged back into the original LLVM repo. Also MacPorts offers more bleeding edge builds. E.g. the current Xcode 15 Beta 2 (not even a final one) ships a clang version still based on LLVM 16, whereas the current LLVM release is LLVM 17 and LLVM 18 is already visible on the horizon and available as a preview by installing clang-devel
in MacPorts.
Upvotes: 0
Reputation: 1984
TL;DR: They should behave similarly (possibly with added optimizations/features on one of them), if they're close enough in terms of llvm releases. But there's no information I can use to find out what you mean.
From what I've seen from the Portfile, the {llvm,clang}-3.4 ports (and the other similar ones, I assume) install a plain llvm and/or clang.
For example: The latest released Xcode comes with:
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
Apple doesn't tell us the specific revision number, but we know their private clang was based on a revision of llvm branched off of trunk between the middle of 2013 and early 2014.
I also don't understand what you mean with “macport clang is more close to gcc”. This doesn't seem to make any sense, but I may be misinterpreting. Apple's clang is fairly close to mainline clang, AFAIK. They have their releases, which are based on an unknown revision, but still.
Clang is the C front-end of the llvm project. It is steered by the llvm community, and all (public) work happens in the main llvm repository (on clang's directory). But you can still install llvm without clang, or clang without (most of?) the other llvm utilities. That's the reason why you have separate packages for clang and for llvm, on macports.
Why do you say they behave differently, and how differently do they behave? Are you compiling with the same options? Which ones? Are they both from the same release, like 3.3 and 3.3svn (this only means they have, at most, about 6 months between them, it won't make them the exact same version)?
Upvotes: 1