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. 安卓请求服务器js文件下载到本地,版本号就下载

    <?phpreturn array('CJ_V' => 'v0.15',) <script src="/js/reserve.js?<?=C('CJ_V')?> ...

  2. Ambari中添加新服务

    官网: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=38571133 一.背景 栈的定义可以在源代码树中找到/am ...

  3. #if defined和#if !defined(c语言的宏定义)

    我们要检查a是否定义 #if defined a #undef a #define a 200 #endif 上述语句检验a是否被定义,如果被定义,则用#undef语句解除定义,并重新定义a为200 ...

  4. 可靠通信的保障 —— 使用ACK机制发送自定义信息——ESFramework 通信框架4.0 快速上手(12)

    使用ESPlus.Application.CustomizeInfo.Passive.ICustomizeInfoOutter接口的Send方法,我们已经可以给服务端或其它在线客户端发送自定义信息了, ...

  5. asp.net通过配置文件设置默认页

    <configuration> <system.webServer>  <defaultDocument>  <files>  <clear /& ...

  6. Excel教程(12) - 数学和三角函数

    ABS     用途:返回某一参数的绝对值.   语法:ABS(number) 参数:number 是需要计算其绝对值的一个实数. 实例:如果 A1=-16,则公式"=ABS(A1)&quo ...

  7. OC 截取字符串

    1.定义一个字符串a, 截取a 的某一个部分,复制给b, b必须是int型 NSString *a = @"1.2.30"; int  b= [[a substringWithRa ...

  8. css格式布局

    一.position:fixed 锁定位置(相对于浏览器的位置),例如有些网站的右下角的弹出窗口. 示例 : 二.position:absolute 1.外层没有position:absolute(或 ...

  9. 导hive表项目总结(未完待续)

    shell里面对日期的操作 #!/bin/bash THIS_FROM=$(date +%Y%m%d -d "-7 day") THIS_TO=$(date +%Y-%m-%d - ...

  10. JavaScript 操作符 变量

    一.操作符: 一元操作符 递增操作符 递减操作符 分为 前置型(--a    ++a) 和 后置型 (a--    a++) 区别如下: var a = 3,b=6; c = --a +b; //c= ...