Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between LLVM, GCC 4.2 and Apple LLVM compiler 3.1

What are the major differences between LLVM GCC 4.2 and Apple LLVM compiler 3.1?

I'm fairly new to compilers so any help is appreciated. Also I'm especially interested in how the two compilers could affect game performance.

like image 611
SundayMonday Avatar asked Aug 18 '12 16:08

SundayMonday


People also ask

What is the difference between LLVM and GCC?

The difference is that GCC supports a number of programming languages while LLVM isn't a compiler for any given language. LLVM is a framework to generate object code from any kind of source code. While LLVM and GCC both support a wide variety languages and libraries, they are licensed and developed differently.

What is Apple LLVM?

The LLVM Core libraries provide a modern source- and target-independent optimizer, along with code generation support for many popular CPUs (as well as some less common ones!) These libraries are built around a well specified code representation known as the LLVM intermediate representation ("LLVM IR").

Does Apple use LLVM?

LLVM has been an integral part of Apple's Xcode development tools for macOS and iOS since Xcode 4. In 2006, Lattner started working on a new project called Clang. The combination of Clang front-end and LLVM back-end is called Clang/LLVM or simply Clang.

Which compiler does Apple use?

Apple Inc. All of Apple's operating systems, iOS, macOS, tvOS and watchOS, are built with LLVM technologies. And Xcode, Apple's integrated development environment, supports development in Swift, C, C++, and Objective-C, all of which use and are built with LLVM technologies.


2 Answers

The difference is a matter of both technology and speed.

CLANG was still young and buggy when Apple began the transition away from GCC's compiler and toolchain, so LLVM was built as a back-end to GCC to facilitate its eventual replacement. So, code went in and was compiled by GCC into some intermediate form, but was sent to LLVM to provide the final machine code and packaging.

Eventually, LLVM and especially CLANG were mature enough to replace GCC outright, which provided an amazing speed boost to compiling and a bump in the quality of the machine code output (though many argue that GCC still produces better quality code at the expense of speed).

But to address your concern about game performance: while CLANG may provide a "better" compile experience, performance is not the job of a compiler. While optimization and simplifications are a part of the compile process, the fact that people still write laggy games or produce infinite loops that lay waste to the stack show that performance is your job. The compiler can only do so much, the rest is up to you. The type or vendor of a compiler will also not make or break your game or affect frame rate or usability. You should read about lower-level optimizations for the ARM architecture. A few articles about NEON, and instruments would do you a lot more good than learning about "optimizing for the compiler".

like image 112
CodaFi Avatar answered Sep 24 '22 03:09

CodaFi


Another Difference: Clang supports most of C++11. GCC 4.2-Apple will not support C++11.

like image 40
justin Avatar answered Sep 20 '22 03:09

justin