Clang

From Infogalactic: the planetary knowledge core
Jump to: navigation, search

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

Lua error in package.lua at line 80: module 'strict' not found.

Clang
225px
Original author(s) Chris Lattner and others
Developer(s) Apple Inc. and others
Initial release 26 Sep 2007 [1]
Stable release 3.8.0[2] / 8 March 2016; 9 years ago (2016-03-08)
Development status Active
Written in C++
Operating system Unix-like
Platform Cross-platform
Type Compiler
License University of Illinois/NCSA Open Source License[3]
Website clang.llvm.org

Clang /ˈklæŋ/[4] is a compiler front end for the programming languages C, C++, Objective-C, Objective-C++, OpenMP,[5] OpenCL, and CUDA. It uses LLVM as its back end and has been part of the LLVM release cycle since LLVM 2.6.

It is designed to be able to replace the full GNU Compiler Collection (GCC). Its contributors include Apple, Microsoft, Google, ARM, Sony, Intel and Advanced Micro Devices (AMD). It is open-source software,[6] with source code released under the University of Illinois/NCSA License, a permissive free software licence.

The Clang project includes the Clang front end and the Clang static analyzer and several code analysis tools.[7]

Background

Starting in 2005, Apple has made extensive use of LLVM in a number of commercial systems,[8] including the iPhone software development kit (SDK) and integrated development environment (IDE) Xcode 3.1.

One of the first uses of LLVM was an OpenGL code compiler for OS X that converts OpenGL calls into more fundamental calls for graphics processing units (GPU) that do not support certain features. This allowed Apple to support the entire OpenGL application programming interface (API) on computers using Intel Graphics Media Accelerator (GMA) chipsets, increasing performance on those machines.[9] For GPUs that support it, the code is compiled to exploit fully the underlying hardware, but on GMA machines, LLVM compiles the same OpenGL code into subroutines to ensure continued proper function.

LLVM was intended originally to use GCC's front end, but GCC turned out to cause some problems for developers of LLVM and at Apple. The GCC source code is a large and somewhat cumbersome system for developers to work with; as one long-time GCC developer put it, "Trying to make the hippo dance is not really a lot of fun".[10]

Apple software makes heavy use of Objective-C, but the Objective-C front-end in GCC is a low priority for GCC developers. Also, GCC does not fit smoothly into Apple's IDE.[11] Finally, GCC is licensed under GNU General Public License (GPL) version 3, which requires developers who distribute extensions for, or modified versions of, GCC to make their source code available, whereas LLVM has a BSD-like license[12] which permits including the source in proprietary software.

Apple chose to develop a new compiler front end from scratch, supporting C, Objective-C and C++.[11] This "clang" project was open-sourced in July 2007.[13]

Design

Clang is intended to work atop LLVM.[12] The combination of Clang and LLVM provides most of a toolchain, to allow replacing the full GCC stack. Because it is built with a library-based design, like the rest of LLVM, Clang is easy to embed into other applications. This is one reason why most OpenCL implementations are built with Clang and LLVM.[citation needed]

One of Clang's main goals is to provide a library-based architecture,[14] to allow the compiler to be more tightly tied to tools that interact with source code, such as an integrated development environment (IDE) graphical user interface (GUI). In contrast, GCC is designed to work in a classic compile-link-debug cycle, and integrating it with other tools is not always easy. For instance, GCC uses a step called fold that is key to the overall compile process, which has the side effect of translating the code tree into a form that looks unlike the original source code. If an error is found during or after the fold step, it can be difficult to translate that back into one location in the original source. Also, vendors using the GCC stack within IDEs use separate tools to index the code, to provide features like syntax highlighting and autocomplete.

Clang is designed to retain more information during the compiling process than GCC, and to preserve the overall form of the original code. The goal of this is to make it easier to map errors back into the original source. The error reports offered by Clang are also aimed to be more detailed and specific, as well as machine-readable, so IDEs can index the output of the compiler during compiling. Modular design of the compiler can offer source code indexing, syntax checking, and other features normally associated with rapid application development systems. The parse tree is also more suitable for supporting automated code refactoring, as it directly represents the original source code.

Clang is a compiler for only C-like languages, including C, C++, Objective-C, Objective-C++, OpenCL, and CUDA. For other languages, including Java, Fortran, and Ada, LLVM remains dependent on GCC or another compiler frontend. In many cases, Clang can be used or swapped out for GCC as needed, with no other effects on the toolchain as a whole.[citation needed] It supports most of the commonly used GCC options.

Performance and GCC compatibility

Clang is designed to be highly compatible with GCC.[15] Clang's command-line interface is similar to and shares many flags and options with GCC. Clang implements many GNU language extensions and enables them by default. Clang implements many GCC compiler intrinsics purely for compatibility. For example, even though Clang implements atomic intrinsics which correspond exactly with C11 atomics, it also implements GCC's __sync_* intrinsics for compatibility with GCC and libstdc++. Clang also maintains ABI compatibility with GCC-generated object code. In practice Clang can often be used as a drop-in replacement for GCC.[citation needed]

Clang's developers aim to reduce memory footprint and increase compilation speed compared to competing compilers, such as GCC. In October 2007, they report that Clang compiled the Carbon libraries well over twice as fast as GCC, while using about one-sixth GCC's memory and disk space.[16] However, as of 2011 this was not a typical result.[17][18] As of mid-2014, runtime performance had improved to the point where Clang won more than a third of the benchmarks, with GCC winning most.[19]

While there are still a few tests where performance of a Clang-compiled program lags behind performance of the GCC-compiled program, by large factors (up to 5.5x),[19] it has been reported that Clang "continues to be under very active development," and a hope was expressed for further improvement.[17]

Status history

This table presents only significant steps and releases in Clang history.

Date Highlights
11 July 2007 Clang frontend released under open-source license
25 February 2009 Clang/LLVM can compile a working FreeBSD kernel.[20][21]
16 March 2009 Clang/LLVM can compile a working DragonFly BSD kernel.[22][23]
23 October 2009 Clang 1.0 released, with LLVM 2.6 for the first time.
December 2009 Code generation for C and Objective-C reach production quality. Support for C++ and Objective-C++ still incomplete. Clang C++ can parse GCC 4.2 libstdc++ and generate working code for non-trivial programs,[12] and can compile itself.[24]
2 February 2010 Clang self-hosting.[25]
20 February 2010 HelenOS source code is modified to compile with Clang successfully, and passes all kernel and user space regression tests on IA-32 processors.[26]
20 May 2010 Clang latest version built the Boost C++ libraries successfully, and passed nearly all tests.[27]
10 June 2010 Clang/LLVM becomes integral part of FreeBSD, but default compiler is still GCC.[28]
25 October 2010 Clang/LLVM can compile a working modified Linux kernel.[29]
January 2011 Preliminary work completed to support the draft C++0x standard, with a few of the draft's new features supported in Clang development version.[30][31]
10 February 2011 Clang can compile a working HotSpot Java virtual machine.[17]
19 January 2012 Clang becomes an optional component in NetBSD cross-platform build system, but GCC is still default.[32]
29 February 2012 Clang 3.0 can rebuild 91.2% of the Debian archive.[33]
29 February 2012 Clang becomes default compiler in MINIX 3[34]
12 May 2012 Clang/LLVM announced to replace GCC in FreeBSD.[35]
5 November 2012 Clang becomes default compiler in FreeBSD 10.x.[36]
18 February 2013 Clang/LLVM can compile a working modified Android Linux Kernel for Nexus 7.[37][38]
19 April 2013 Clang is C++11 feature complete.[39]
6 November 2013 Clang is C++14 feature complete.[40]
11 September 2014 Clang 3.5 can rebuild 94.3% of the Debian archive. The percentage of failures has dropped by 1.2% per release since January 2013, mainy due to increased compatibility with GCC flags.[41]

See also

References

<templatestyles src="Reflist/styles.css" />

Cite error: Invalid <references> tag; parameter "group" is allowed only.

Use <references />, or <references group="..." />

External links

  1. http://www.llvm.org/releases/2.1/docs/ReleaseNotes.html
  2. http://llvm.org/releases/
  3. Lua error in package.lua at line 80: module 'strict' not found.
  4. Lua error in package.lua at line 80: module 'strict' not found.
  5. Lua error in package.lua at line 80: module 'strict' not found.
  6. Lua error in package.lua at line 80: module 'strict' not found.
  7. Lua error in package.lua at line 80: module 'strict' not found.
  8. Lua error in package.lua at line 80: module 'strict' not found.
  9. Lua error in package.lua at line 80: module 'strict' not found.
  10. Lua error in package.lua at line 80: module 'strict' not found.
  11. 11.0 11.1 Lua error in package.lua at line 80: module 'strict' not found.
  12. 12.0 12.1 12.2 Clang team, clang: a C language family frontend for LLVM
  13. Lua error in package.lua at line 80: module 'strict' not found.
  14. Clang: Utility and Applications: Library Based Architecture
  15. Lua error in package.lua at line 80: module 'strict' not found.
  16. Lua error in package.lua at line 80: module 'strict' not found.
  17. 17.0 17.1 17.2 Lua error in package.lua at line 80: module 'strict' not found.
  18. Lua error in package.lua at line 80: module 'strict' not found.
  19. 19.0 19.1 Lua error in package.lua at line 80: module 'strict' not found.
  20. Lua error in package.lua at line 80: module 'strict' not found.
  21. Lua error in package.lua at line 80: module 'strict' not found.
  22. Lua error in package.lua at line 80: module 'strict' not found.
  23. Lua error in package.lua at line 80: module 'strict' not found.
  24. Lua error in package.lua at line 80: module 'strict' not found.
  25. Lua error in package.lua at line 80: module 'strict' not found.
  26. Lua error in package.lua at line 80: module 'strict' not found.
  27. Lua error in package.lua at line 80: module 'strict' not found.
  28. Lua error in package.lua at line 80: module 'strict' not found.
  29. Lua error in package.lua at line 80: module 'strict' not found.
  30. Lua error in package.lua at line 80: module 'strict' not found.
  31. Lua error in package.lua at line 80: module 'strict' not found.
  32. Lua error in package.lua at line 80: module 'strict' not found.
  33. Lua error in package.lua at line 80: module 'strict' not found.
  34. Lua error in package.lua at line 80: module 'strict' not found.
  35. Lua error in package.lua at line 80: module 'strict' not found.
  36. Lua error in package.lua at line 80: module 'strict' not found.
  37. Lua error in package.lua at line 80: module 'strict' not found.
  38. Lua error in package.lua at line 80: module 'strict' not found.
  39. Lua error in package.lua at line 80: module 'strict' not found.
  40. Lua error in package.lua at line 80: module 'strict' not found.
  41. Lua error in package.lua at line 80: module 'strict' not found.