GCC, Clang and make, cmake List

GCC
GCC (GNU Compiler Collection, GNU Compiler Collection), is a programming language developed by the GNU compiler. It is a set of free software GPL and LGPL licenses issued, is also a key part of the GNU project, is also a free Unix-like and Apple's Mac OS X operating system standard compiler.
GCC formerly known as the GNU C compiler, because it can only deal with the original C language. GCC rapidly expanding, it becomes possible to deal with C ++. After becoming can handle Fortran, Pascal, Objective-C, Java, and Ada and other languages.

Clang
Clang is written in C ++, based on LLVM, LLVM BSD license issued under the C / C ++ / Objective C / Objective C ++ compiler, the goal (one) is beyond the GCC.

LLVM
LLVM is an abbreviation of Low Level Virtual Machine, the library provides support related to the compiler, the compiler of the programming language can be optimized, link optimization, online compiler optimization, code generation. In short, it can be used as a background in multiple languages compiler.

This is the three-stage, it can be divided into a front end, a rear end and a optimized. The front end is responsible for parsing the source code, check the syntax errors, and translated to an abstract syntax tree; the optimizer to optimize the intermediate code, the code attempts to make more efficient; rear end is responsible for converting the intermediate code optimized for the optimizer target machine code, back-end process will maximize the use of special instructions of the target machine to improve the performance of the code. Based on this knowledge, we can think LLVM includes two concepts: a broad and a narrow LLVM LLVM. LLVM broadly refers to a complete frame LLVM compiler system, including a front end, the optimizer, a rear end, many of the library functions as well as many of the modules; and narrow LLVM compiler is focused on the rear end of a series of functions modules and libraries, including code optimization, code generation, the JIT like.

Clang historical
purpose than Apple absorption Chris Lattner improved code optimization GCC is much more ambitious:

GCC system is large and bulky
and heavy use of Apple's Objective-C is very low priority in the GCC.
Further, as a pure GCC compiler system, and IDE in poorly.
Coupled with the licensing requirements, Apple can not use the LLVM GCC to continue to improve the quality of the code.
So, Apple decided to start from scratch to write C, C ++, front-end Clang Objective-C language, completely replace the lost GCC.
Just as, Clang only supports C, C ++ and Objective-C three kinds of C language family name written.

Development began in 2007, completed the first C compiler,
and because Objective-C is relatively simple, just a simple extension of the C language, and in many cases can even be equivalently rewritten as C language function calls to the Objective-C runtime libraries, so in 2009, it has been fully used in the production environment.
C ++ support is also in full swing manner.
Different points GCC, LLVM-GCC, LLVM Compiler three compilation options

Contrast
Clang characteristics

Fast: compiled by OS X contains almost all test carbon.h C header files comprising pretreatment (the Preprocess), grammar (Lex), parsing (the parse), semantic analysis (Semantic Analysis), generates abstract syntax tree ( abstract Syntax Tree) time, Clang is fast Apple GCC 2.5x 4.0. (2007-7-25)
memory footprint small: Clang memory footprint is the source of 130%, Apple GCC is more than 10x.
Diagnostic information readable: syntax error prompted not only the source code, there will be ~~~~~ ^ and tips beneath the wrong call and relevant context, compared to GCC tips are hieroglyphics.
GCC compatibility.
Design clear and simple, easy to understand, easy to extend enhanced. Compared with the old code base of the GCC, the learning curve is gentle.
The modular design of library-based, easy-to-IDE integration and reused for other purposes. For historical reasons, the GCC is a single executable program compiler, completed all its internal generated from the pretreatment process to the final code information among many other applications can not be reused. Clang the compilation process into separate stages from each other, AST information serializable. By supporting the library, the program can obtain the AST levels of information, will greatly enhance the ability to manipulate the code. For IDE, the code completion, refactoring is an important function, but without the support of the underlying, only use tags or regular expression match analysis is very difficult to achieve.
GCC advantage

Support JAVA / ADA / FORTRAN
GCC supports more platforms
GCC more popular, widely used to support the complete
GCC-based C, C ++ compiler does not need to compile
the make
the make intelligent tool equivalent to a batch tool itself is not compiled and linked function, but with a similar batch mode by calling compile and link the user-specified command in the makefile.
The makefile what is?

It recorded a series of commands which the user will be executed, make compile and link the corresponding source file according to the makefile command.

makefile may have a similar look command: gcc -o test.c.
the makefile is common in github source installation program, you download a source package, there is usually such a sentence in the readme:

Make all $
$ root required the make install #
make all that is compiling all, of course, this source package must have the makefile for the job, make makefile will be compiled according to the command execution make all this command. Of course, this is "someone's home," the source package, this usually gave you written, but if you want to compile many source files when, but also to write yourself?

cmake
reference
https://oldpan.me/archives/gcc-make-cmake-clang-tell
https://xuhehuan.com/2738.html
https://www.cnblogs.com/qoakzmxncb/archive/2013/04/ 18 is / 3029105.html
2 Like entering point
C ++

Author: linheimx
link: https://www.jianshu.com/p/990ee4b9c5d3
Source: Jane books
are copyrighted by the author. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.

Guess you like

Origin www.cnblogs.com/wnwin/p/12125710.html