5 ms·
Clang is the future. GCC is obsolete, and LLVM-GCC was just a temporary technology to help migrate from GCC to Clang. All new projects should absolutely be usin
by eridius 15y ago
Clang is the future. GCC is obsolete, and LLVM-GCC was just a temporary technology to help migrate from GCC to Clang. All new projects should absolutely be using Clang now, and any old projects that haven't already switched should seriously consider doing so.
- psychotik 15y agoIs switching as simple as changing the project config to use the new compiler, or is code migration/change needed?
- jamesjyu 15y agoYou'll probably get some minor warnings here and there due the differences in the Parser. But in my experience, it's been relatively painless.
- eridius 15y agoDepends on your code. For well-written code that conforms to standards, switching the compiler may be completely pain-free. For most code, you'll probably get a few warnings (since Clang's default warning set is different than GCC's). In rare occasions you'll hit an actual behavioral difference between GCC and Clang, but you'll typically only find those where you're already writing non-standards-compliant code. Also, if you do get some warnings when you switch to Clang, I would recommend fixing them rather than trying to squelch the warnings. Clang's warning set is pretty well-thought-out and things it flags as warnings are typically indicative of bad code (or coding practices).
- dman 15y agoYou might want to clarify that your statements are within the iOS / OSX context. Calling gcc obsolete in other contexts might not be entirely accurate.
- eridius 15y agoYou have a good point, though this entire post is in the context of iOS. But yes, GCC is only obsolete for OS X/iOS development.
- extension 15y agowhy?
- msbarnett 15y agoWhy what? Why is GCC obsolete for iOS/OS X dev? Because Apple will not be updating it in the future to track changes in the Objective-C language, runtime, and iOS and OS X platforms. Why won't Apple be updating it? Because they've indicated that they are not comfortable with contributing to projects based on the GPL, version 3, and they do not wish to be stuck forever on the last version of GCC released prior to that licensing change. Why is Clang the future? Because Apple has anointed it as compiler which will be receiving future updates to track changes in the Objective-C language, runtime, and iOS and OS X platforms. Why should any old projects that haven't already switched seriously consider doing so? Because the divergence between GCC and Clang is only going to increase with time, and code which doesn't make that transition now will face a much costlier transition down the road as new features become Clang-only and as it becomes increasingly impossible to run the old versions of Xcode which use GCC and for said old versions of GCC to build binaries which run on future versions of iOS and OS X.
- extension 15y agoOk, so it just needs to be done eventually, and there's no benefit per se to using Clang over GCC? I ask because I'm an iOS dev and I don't know anything about this issue. Why would the transition be much costlier later? More imperative I understand, but why more costly?
- msbarnett 15y agoIf you transition now, the incompatiblities for most apps are small to nonexistent. If, say, you transition 3 years from now when GCC can't build a working binary for a new iOS ABI version that the App Store rules require all new submissions support, and the syntax clang supports has diverged from what GCC was accepting, that's more time needed and dollars lost for every minute the porting takes you. But that's just a guess at the future. Clang/LLVM provides significant benefits today. Better error messages, better warnings, a seriously great static analyzer (given the constraints imposed by C's semantics), and Automated Reference Counting are just a few of them.
- nupark2 15y agoUnfortunately, clang (and the shared llvm backend) are still fairly buggy. For example: http://blog.clickablebliss.com/2011/11/07/xcode-4-2-llvm-built-armv6-floating-point-crashes-fixed/ http://blog.clickablebliss.com/2011/11/07/xcode-4-2-llvm-bui... There's a bug in Xcode 4.2 (the latest stable release) that results in broken armv6 thumb FPU-related codegen. It's not hard to hit, either. Since everything is based on LLVM now (including gcc-llvm), there's no way around this one (or other bugs) other than simply disabling thumb. I'd personally rather stick to gcc4 for at least the next few clang/llvm release cycles, since the bugs are known. Unfortunately, straight GCC is no longer supported in Xcode.
- pagekalisedown 15y agoHave you tried building Boost for iOS?
- eridius 15y agoFor iOS? No. But I thought that as of this year, Clang's C++ support was good enough for Boost. Am I missing something?