1. gcc -Iproj/src myfile.c -o myfile
  2. gcc -c myfile.c "compile without linking
  3. gcc -D DEBUG myfile.c -o myfile
  4. gcc -glevel "level=0,1,3,null
  5. "gcc -l links with a library file.
  6. "gcc -L looks in directory for library files. "Link -l with library name without the lib prefix and the .a or .so extensions
  7. gcc myfile.c -o myfile
  8. 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:

  1. 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_2328_Corporate Identity(暴力枚举子串+KMP)

    题目链接:hdu_2328_Corporate Identity 题意: 给你n个串,让你找这n个串的最大公共子串 题解: 串比较小,暴力枚举第一个的子串,然后KMP判断是否可行 #include&l ...

  2. IOS 类似网易新闻客户端内容滚动菜单跟随居中组件

    需求分析: 1.类似网易新闻客户端页面滚动组件.菜单栏对应菜单项一直居中 2.点击菜单栏可以切换到对应的page 3.滑动页面可以自动切换相应的菜单.并且对应的菜单栏居中显示 4.初始化时可以自定义菜 ...

  3. jQuery 学习小结

    1,jQuery是一个简单的JavaScript库,提供了一系列辅助函数:以下简称jq; 使用jq时,通常将jq代码放到head部分的事件处理方法中,也可以将其单独写出 .js 文件,引入:但无论哪种 ...

  4. UISwitch 开关控件

    UISwitch iOS中的开关控件,只有两种状态,打开或关闭. aSwitch.tintColor = [UIColor redColor]; //关闭状态下的渲染颜色 aSwitch.onTint ...

  5. PHP CURL 代理发送数据

    $session = curl_init($request); curl_setopt ($session, CURLOPT_PROXY, $proxy); curl_setopt ($session ...

  6. display flex 和a标签不行

    父元素display: flex;  display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap; 配合子元素 fl ...

  7. yii2.0图片上传

    在根目录下夹uploads文件夹 控制器 UploadController.php <?php namespace frontend\controllers; use Yii; use fron ...

  8. ios NSComparator 三种枚举类型

    NSComparator有3种枚举类型 NSOrderedDescending 降序,但是用他可以实现升序或者降序都没问题. NSOrderedAscending 升序,但是目前没有使用出任何效果.. ...

  9. mongoDB5--mongoDB增删改查

    之前我们探讨了mongodb的"增删改查",要知道,我们的增删改其实都离不开查询表达式,所以查询表达式在mongodb是非常重要的.关于查询其实我们只是介绍了以小部分.关于mong ...

  10. 监控gc

    前几篇篇文章介绍了介绍了JVM的参数设置并给出了一些生产环境的JVM参数配置参考方案.正如之前文章中提到的JVM参数的设置需要根据应用的特性来进行设置,每个参数的设置都需要对JVM进行长时间的监测,并 ...