GCC: compilation process..
gcc -Iproj/src myfile.c -o myfile
gcc -c myfile.c "compile without linking
gcc -D DEBUG myfile.c -o myfile
gcc -glevel "level=0,1,3,null
"gcc -l links with a library file.
"gcc -L looks in directory for library files. "Link -l with library name without the lib prefix and the .a or .so extensions
gcc myfile.c -o myfile
gcc -Wall "enable all warnings..
gcc
-I -L -l -D -g -O -o -Wall
about the -0 option.. ref to the following table..
Set the compiler's optimization level.
| option | optimization level | execution time | code size | memory usage | compile time |
|---|---|---|---|---|---|
| -O0 | optimization for compilation time (default) | + | + | - | - |
| -O1 or -O | optimization for code size and execution time | - | - | + | + |
| -O2 | optimization more for code size and execution time | -- | + | ++ | |
| -O3 | optimization more for code size and execution time | --- | + | +++ | |
| -Os | optimization for code size | -- | ++ | ||
| -Ofast | O3 with fast none accurate math calculations | --- | + | +++ |
+increase ++increase more +++increase even more -reduce --reduce more ---reduce even more
some environmental variables used in gcc: for more, see here
LANG 1
LC_CTYPE 1
LC_MESSAGES 1
LC_ALL 1
TMPDIR 1
GCC_COMPARE_DEBUG 1
GCC_EXEC_PREFIX 1
COMPILER_PATH 1
LIBRARY_PATH 1
CPATH 1
C_INCLUDE_PATH 1
CPLUS_INCLUDE_PATH 1
OBJC_INCLUDE_PATH 1
DEPENDENCIES_OUTPUT 1
SUNPRO_DEPENDENCIES 1
SOURCE_DATE_EPOCH 1
-----to ensure how a lib is generated, by:
objdump --debugging *.a/*.so
part 2:------original file ends, adding more gcc options-----
from here:
-v, -save-temps, -S, -c, -E, -Werror, -fPIC, -ansi, -funsigned-char, -pg. -Wextra, -Wfloat-equal, -pipe, -funroll-loops (code size up), -flto (e.g. inline opt)
@filename to specify options in file.
Note, from here and here, -march/-mtune is very powerful, specify different arch/tune mighe influence final code. And march is stronger than mtune, it enables generating code that may not be run other than the specified cpu.
gprof usage: -pg option used while compile & linking, then ./a.out then a file named gmon.out is generated. Then use gprof a.out gmon.out > gprof.txt generate a profile for human readable format of gprof.
valgrind tutorial is here.
GCC: compilation process..的更多相关文章
- GCC编译连接c++代码的四个阶段(Four stages of GCC compilation of C++ code)
There are four stages for GCC to compile c/c++ applications: Preprocessing, Compilation proper, Asse ...
- Cannot find name 'AsyncIterator' error in Typescript compilation process 问题解决
解决方法: tsconfig.json: 添加lib 编译选项 { "compilerOptions": { "lib":[ "esnext.asyn ...
- C/C++笔记 #035# Makefile
相关资料: Understanding roles of CMake, make and GCC GCC and Make ( A simple tutorial, teaches u how to ...
- gcc -M -MM -MQ -MF -MT -MD
静态模式规则对一个较大工程的管理非常有用.它可以对整个工程的同一类文件的重建规则进行一次定义,而实现对整个工程中此类文件指定相同的重建规则.比如,可以用来描述整个工程中所有的.o 文件的依赖规则和编译 ...
- Raspberry Pi Kernel Compilation 内核编译官方文档
elinux.org/Raspberry_Pi_Kernel_Compilation#Use_the_provided_compiler Software & Distributions: S ...
- RPi Kernel Compilation
Overview This page explains how to rebuild the kernel image for the RPi. There are two possible rout ...
- Installing GCC 简单方法
Installing GCC This page is intended to offer guidance to avoid some common problems when installing ...
- magento性能优化
magento性能优化 14个快速加载web页面的技巧: 减少HTTP请求数使用CDN增加过期头信息gzip压缩传输内容将css样式表放在页首将js文件放在页尾不使用css表达式尽量少用内联式的css ...
- php script 的生命周期
原文地址:https://support.cloud.engineyard.com/hc/en-us/articles/205411888-PHP-Performance-I-Everything-Y ...
随机推荐
- 浙大pat1042题解
1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...
- hdu 1022 Train Problem I(栈)
#include<iostream> #include<vector> #include<cstring> #include<string> #incl ...
- 如何安全退出已调用多个Activity的Application?
如何退出Activity?如何安全退出已调用多个Activity的Application? 退出Activity直接调用finish()方法 //用户点击back键就是退出一个Activity 退出 ...
- servlet规范核心类图
作为新手在写servlet时很多时候忘记类与类之间的关系,找到这张图就瞬间清晰了,这比看API要舒服很多.
- NOIP2014-普及组复赛-第四题-子矩阵
题目描述 Description 给出如下定义: 1. 子矩阵:从一个矩阵当中选取某些行和某些列交叉位置所组成的新矩阵(保持行与列的相对顺序)被称为原矩阵的一个子矩阵. 例如,下面左图中选取第2.4行 ...
- incallui中如何查询联系人数据
联系人信息显示在CallCard中,提示当前正在通话的联系人号码.姓名.头像.号码类型等信息: 代码中在两个地方发起对当前联系人的查询, Init():startContactInfoSearch(c ...
- 2015 ACM/ICPC Asia Regional Shenyang Online
1001 Traversal 1002 Best Solver 1003 Minimum Cut 类似于POJ 3417的做法. 考虑每条新边对树边的覆盖次数. 每条树边被覆盖的次数其实就是断裂这条树 ...
- 2015 Multi-University Training Contest 7
1001 Game On the Tree 1002 Tree Maker 1003 Hotaru's problem Manacher处理好p数组. 暴力举一下公共串即可. # include &l ...
- javascript中onSubmit="return xxx()"的问题
javascript中onSubmit="return xxx()"刚开始我是想不通为什么要加return在里面呢,后来想想onSubmit="flase"就不 ...
- FreeMarker 实例
1.jar包:freemarker-2.3.19.jar,将jar拷贝到lib目录下: 2.新建Web项目:TestFreeMarker 在web目录下新建ftl文件夹: 在ftl下新建模版文件ftl ...