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..的更多相关文章

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

  2. Cannot find name 'AsyncIterator' error in Typescript compilation process 问题解决

    解决方法: tsconfig.json: 添加lib 编译选项 { "compilerOptions": { "lib":[ "esnext.asyn ...

  3. C/C++笔记 #035# Makefile

    相关资料: Understanding roles of CMake, make and GCC GCC and Make ( A simple tutorial, teaches u how to ...

  4. gcc -M -MM -MQ -MF -MT -MD

    静态模式规则对一个较大工程的管理非常有用.它可以对整个工程的同一类文件的重建规则进行一次定义,而实现对整个工程中此类文件指定相同的重建规则.比如,可以用来描述整个工程中所有的.o 文件的依赖规则和编译 ...

  5. Raspberry Pi Kernel Compilation 内核编译官方文档

    elinux.org/Raspberry_Pi_Kernel_Compilation#Use_the_provided_compiler Software & Distributions: S ...

  6. RPi Kernel Compilation

    Overview This page explains how to rebuild the kernel image for the RPi. There are two possible rout ...

  7. Installing GCC 简单方法

    Installing GCC This page is intended to offer guidance to avoid some common problems when installing ...

  8. magento性能优化

    magento性能优化 14个快速加载web页面的技巧: 减少HTTP请求数使用CDN增加过期头信息gzip压缩传输内容将css样式表放在页首将js文件放在页尾不使用css表达式尽量少用内联式的css ...

  9. php script 的生命周期

    原文地址:https://support.cloud.engineyard.com/hc/en-us/articles/205411888-PHP-Performance-I-Everything-Y ...

随机推荐

  1. hdu_5862_Counting Intersections(扫描线)

    题目链接:hdu_5862_Counting Intersections 题意: 给你与坐标轴平行的线段,问你交点数 题解: 实质就是扫描线,这里我用树状数组来记录,所有线段按X坐标排序,遇到横线段的 ...

  2. WebService 调用三种方法

    //来源:http://www.cnblogs.com/eagle1986/archive/2012/09/03/2669699.html 最近做一个项目,由于是在别人框架里开发app,导致了很多限制 ...

  3. erlang四种监控策略

    转自:http://jasionq.blog.163.com/blog/static/10970577920133883158424/ Supervisor Behaviour是一个用来实现一个sup ...

  4. CCleaner(著名清理软件) 5.21.5700 中文免费版(著名清理软件) 5.21.5700 中文免费版

    软件名称: CCleaner(著名清理软件) 5.21.5700 中文免费版著名清理软件(CCleaner)软件语言: 多国语言授权方式: 免费软件运行环境: Win 32位/64位软件大小: 5.6 ...

  5. Day06 杂乱与4个对象

    1.杂乱 -- 数据库的分页操作 -- 分页使用的是rownum 例1: select rownum,empno,ename from emp ; 结果: 例2: select r,empno,ena ...

  6. Canvas基础讲义

    今天先花点简单的篇幅和大家介绍下canvas. 1. 基本篇 1.1. 什么是 Canvas canvas 是 HTML5 提供的一个用于展示绘图效果的标签. canvas 原意画布, 帆布. 在 H ...

  7. json处理三部曲之第三曲:利用Gson处理json

    需要导入gson-xxx.jar包 <dependency> <groupId>com.google.code.gson</groupId> <artifac ...

  8. .NET技术+25台服务器怎样支撑世界第54大网站

    摘要:同时使用Linux和Windows平台产品,大量使用静态的方法和类,Stack Overflow是个重度性能控.同时,取代横向扩展,他们坚持着纵向扩展思路,因为“硬件永远比程序员便宜”. Sta ...

  9. HDU 5813 Elegant Construction

    构造.从a[i]最小的开始放置,例如放置了a[p],那么还未放置的,还需要建边的那个点 需求量-1,然后把边连起来. #pragma comment(linker, "/STACK:1024 ...

  10. JDK1.5与1.6在Override上的区别

    @Override是JDK5 就已经有了,但有个小小的Bug,就是不支持对接口的实现,认为这不是Override 而JDK6 修正了这个Bug,无论是对父类的方法覆盖还是对接口的实现都可以加上@Ove ...