Recently looking at "Linux Kernel source code scenario analysis", author Queen Maud. At the beginning of the book, I introduced the assembler assembly with GCC and the linked list of Linux kernel data structures. Unfortunately, the book is not comprehensive enough to introduce. Because we recommend reading the following two articles. Very good.At -T assembly and GCC
-o0
-o1
-o2
-o3
4 levels of compiler optimization options,-o0 means no optimizations,-o1 defaults,-O3 optimization level most (here is Capital letter O)
Optimization Options (Source: http://blog.csdn.net/Sodier/article/details/452566)
This part of the content can be divided into two parts, part of this is to have the compiler analyze the code, and the other part is that we can make some information about
Common gcc/g ++ commands and gcc Command Options
Common options for gcc/g ++ commands (option description)
-O FILE specifies the output FILE name. This option is not required during compilation of the target code. If FILE is not specified, the default FILE name is a. out.
-C
unexpected place, loop statements may become everywhere because of loop expansion. All these are a nightmare for debugging. It is recommended that you do not use any optimization options during debugging. optimization is considered only when the program is finally released.
Acceleration
The process of converting source code into executable files involves many intermediate steps, including preprocessing, compilation, compilation, and connection. These
the level of debug information: Add a level after the specified debug format:such as:-GGDB2, etc., 0 means no debug information. When using-gdwarf-2, because the earliest format is-GDWARF2, it causes confusion, so you need to use a-glevel to specify the level of debug information, and other formatting options can also be assigned a different level.GCC can use the-P option to specify the build information for Porf use.
-compilation command to insert the included files to the pre-compilation command. This process is performed recursively, And the included files may contain other files.
4. Delete all comments // and /**/;
5. Add the row number and file ID, for example, #2 "hello. C "2, so that the compiler can generate the line number information for debugging during compilation and display the line number information during compilation errors or warnings;
6. Keep all # pragma compiler instructions because the c
command is not executed.
-EOnly for preprocessing, without compilation, compilation, and linking. As shown in.
-SOnly compiled to the assembly language, without assembly and link. As shown in.
-CCompile and assemble the code to the target without link. As shown in.
-PipeUse MPs queues instead of temporary files.
-CombineMultiple source files are passed to the assembler at a time.
3. Other GCC
gcc,g++ common compilation options in Linux-X language filenameSet the language used by the file, so that the suffix name is invalid for later multiple valid. That is, according to the Convention, the C language suffix name is. c, and the C + + suffix name is. C or. cpp, if you are very personality, decide the suffix name of your C code file is. Pig Haha, then you have to use this parameter, this parameter
with-E. Sometimes, the analysis program is very convenient to use.-MGenerate the information associated with the document. You can use gcc-M hello. c to test any source code that contains the target document.-MMIt is the same as the one above, but it will ignore the dependency caused by # include -MDIt is the same as-M, but the output will be imported into the. d document.-MMDIt is the same as-MM, but the output will be imported into the. d document.
GCC Preprocessor options
Source:Author:Release date:Font:[LargeMediumSmall]
Preprocessor Option)The following options are for the c Preprocessor, which is used to process the C source file before official compila
GccG ++ common compilation options
GCC and G ++ common compilation options in Linux-X language filename Set the language used by the file to make the suffix invalid and valid for later versions. that is, according to the Conventions, the C language suffix is. c, and C ++'s suffix is. C or. CPP. If you have a personality, the suffix of your C code file is
information about the file association. Contains all the original code that the target file depends on you can use Gcc-m hello.cTo test it, it's very simple. -mmThe same as the one above, but he will ignore the dependency caused by #i nclude. -mdSame as-M, but the output will be imported into the. d file -mmdSame as-mm, but the output will be imported into the. d file. -wa,optionThis option passes option to the
Uncommon but useful GCC command line options (2)GuideThe gcc compiler provides a list of almost countless command line options. Of course, no one has ever used or mastered all of its command line options, but there are some command line
Many may be very concerned about how to optimize and compile their own programs. Although I do not agree with the "Ashes" method, I have to admit that this is an excellent way to master GCC;
Therefore, we offer this post for your reference. It is absolutely original.
======================================
The default optimization level for most programs and libraries during compilation is "2" (with the GCC
The GCC compiler is usually followed by some options and file names. The basic usage of the GCC command is as follows:
GCC [Options] [filenames]
Option specifies how the compiler is compiled.
GCC
Article title: GCC compiler options and optimization tips. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The default optimization level for most programs and libraries during compilation is "2" (with the gcc option: "-O2") a
directory
-print-sysroot-headers-suffix Display the sysroot suffix used to find headers
-wa,-wp,-wl,-xassembler -xpreprocessor -xlinker -combine pass multiple source files to compiler at once
-save-temps do not delete intermediate files
-pipe use pipes rather than intermediate files
-time time the execution of each subprocess
-specs=-std=--sysroot=and libraries
-B -B -V -V Display The programs invoked by the compiler
-### like-v but options quoted an
GCC Optimization Research
One: GCC optimization introduction
GCC provides nearly hundred optimization options to meet the user's varying degrees of optimization needs to make a different trade-off and balance between {compile time, target file length, execution efficiency}. Optimization methods, the overall will have
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.