当前位置:网站首页>gcc 编译选项
gcc 编译选项
2022-07-06 09:17:00 【csdndulala】
-fno-builtin 不使用内建函数
-ffunction-sections
-fdata-sections
需求:有些函数或变量没有使用时不需要编入程序
GCC链接操作是以section作为最小的处理单元,只要一个section中的某个符号被引用,该section就会被加入到可执行程序中去。因此,GCC在编译时可以使用 -ffunction-sections和 -fdata-sections 将每个函数或符号创建为一个sections,其中每个sections名与function或data名保持一致。而在链接阶段, -Wl,–gc-sections 指示链接器去掉不用的section(其中-Wl, 表示后面的参数 -gc-sections 传递给链接器),这样就能减少最终的可执行程序的大小了。
我们常常使用下面的配置启用这个功能:
CFLAGS += -ffunction-sections -fdata-sections
LDFLAGS += -Wl,–gc-sections-Wall 发现程序中一系列的常见错误警告
-D 定义宏
-DMACRO 以字符串“1”定义 MACRO 宏。
-DMACRO=DEFN 以字符串“DEFN”定义 MACRO 宏。-O 优化登记
O0 -->> O1 -->> O2 -->>Os–>> O3
-O0表示没有优化,-O1为缺省值,-O3优化级别最高
https://blog.csdn.net/zzhongcy/article/details/91445924mabi 指定数据模型和浮点参数传递规则
https://blog.csdn.net/zoomdy/article/details/79353313-nostartfiles 连接的时候不使用标准系统的启动文件
https://my.oschina.net/saly/blog/130920-T,–script=:使用scriptfile作为链接器脚本。此脚本将替换ld的默认链接器脚本(而不是添加到其中),因此脚本必须指定输出文件所需的所有内容。如果当前目录中不存在脚本文件,“ld”会在-L选项指定的目录中查找
[email protected] 目标文件,$^ 所有的依赖文件,$< 第一个依赖文件
举例 gcc -o main main.o
等价 gcc -o [email protected] $^-lm选项告诉编译器,我们程序中用到的数学函数要到libm.so库文件里找
(例如printf)位于libc.so库文件中,使用libc.so中的库函数在编译时不需要加-lc选项,因为这个选项是gcc的默认选项
边栏推荐
猜你喜欢
E-commerce data analysis -- User Behavior Analysis
IOT system framework learning
Word排版(小计)
5G工作原理详解(解释&图解)
[yarn] yarn container log cleaning
MP3mini播放模块arduino<DFRobotDFPlayerMini.h>函数详解
arduino JSON数据信息解析
STM32 how to locate the code segment that causes hard fault
Oppo vooc fast charging circuit and protocol
Mysql的索引实现之B树和B+树
随机推荐
Basic use of pytest
Variable star user module
sklearn之feature_extraction.text.CountVectorizer / TfidVectorizer
Dependency in dependencymanagement cannot be downloaded and red is reported
4、安装部署Spark(Spark on Yarn模式)
Nodejs connect mysql
OPPO VOOC快充电路和协议
[Flink] cdh/cdp Flink on Yan log configuration
ESP8266通过arduino IED连接巴法云(TCP创客云)
Pytorch four commonly used optimizer tests
Basic knowledge of lithium battery
Oppo vooc fast charging circuit and protocol
Yarn installation and use
5G工作原理详解(解释&图解)
MySQL数据库面试题
Wangeditor rich text component - copy available
互聯網協議詳解
Composition des mots (sous - total)
C语言函数之可变参数原理:va_start、va_arg及va_end
Matlab learning and actual combat notes