10

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.

2 Answers 2

9

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".

3
  • 2
    Actually it's the other way around - LLVM-GCC uses the GCC front-end but the LLVM code generators. When the LLVM project started it's goal was to provide only the backend code generators and other compiler infrastructure, but not a complete C compiler. Apple later initiated the clang project to build a full compiler on top of the LLVM infrastructure.
    – Sven
    Aug 18, 2012 at 20:03
  • 8
    I disagree with 'performance is not the job of a compiler.' Performance is a huge part of what makes a compiler good. Ideally a user should be able to just write readable, maintainable code and rely on the compiler to make it fast. Clang is not the most mature compiler and often shows performance shortcomings compared to other modern compilers. Occasionally it also compares very well, but more often not. Clang's great strength from a user's perspective is in high quality diagnostics and conformance. From a compiler developer's perspective Clang is very easy to work with and moves very rapidly.
    – bames53
    Aug 18, 2012 at 20:07
  • 1
    @Sven You are absolutely correct, and I have edited to reflect that. @barnes53: I only said that because while compilers do in fact "optimize", they often don't do anything intrinsic without explicit instructions to do so. A perfect example would be PPC's old fsel(), which allowed a function to forgo branching with floating-point returns. The compiler did not know how to fold branches to fsel, you had to tell it to do so. Also, he asked about compilers, not debuggers, so I felt a discussion of LLDB was inappropriate.
    – CodaFi
    Aug 18, 2012 at 20:50
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.