当前位置:网站首页>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的默认选项
边栏推荐
- SQL time injection
- Variable parameter principle of C language function: VA_ start、va_ Arg and VA_ end
- Contiki source code + principle + function + programming + transplantation + drive + network (turn)
- 【CDH】CDH5.16 配置 yarn 任务集中分配设置不生效问题
- Reading notes of difficult career creation
- Détails du Protocole Internet
- 机器学习--线性回归(sklearn)
- Composition des mots (sous - total)
- 互联网协议详解
- STM32型号与Contex m对应关系
猜你喜欢

Apprentissage automatique - - régression linéaire (sklearn)

STM32 how to locate the code segment that causes hard fault

高通&MTK&麒麟 手機平臺USB3.0方案對比

Wangeditor rich text reference and table usage

C语言回调函数【C语言】

Stage 4 MySQL database

Oppo vooc fast charging circuit and protocol

Gallery's image browsing and component learning

Mysql database interview questions

Time slice polling scheduling of RT thread threads
随机推荐
STM32型号与Contex m对应关系
Common regular expression collation
Variable star user module
Pytoch implements simple linear regression demo
Selective sorting and bubble sorting [C language]
RT thread API reference manual
C语言函数之可变参数原理:va_start、va_arg及va_end
分布式節點免密登錄
Funny cartoon: Programmer's logic
Reno7 60W超级闪充充电架构
C语言,log打印文件名、函数名、行号、日期时间
PyTorch四种常用优化器测试
Those commonly used tool classes and methods in hutool
2020 WANGDING cup_ Rosefinch formation_ Web_ nmap
电商数据分析--用户行为分析
imgcat使用心得
Characteristics, task status and startup of UCOS III
There are three iPhone se 2022 models in the Eurasian Economic Commission database
选择法排序与冒泡法排序【C语言】
FTP file upload file implementation, regularly scan folders to upload files in the specified format to the server, C language to realize FTP file upload details and code case implementation