当前位置:网站首页>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的默认选项
边栏推荐
- There are three iPhone se 2022 models in the Eurasian Economic Commission database
- Unit test - unittest framework
- open-mmlab labelImg mmdetection
- 电商数据分析--用户行为分析
- Selective sorting and bubble sorting [C language]
- Fashion-Gen: The Generative Fashion Dataset and Challenge 论文解读&数据集介绍
- Comparaison des solutions pour la plate - forme mobile Qualcomm & MTK & Kirin USB 3.0
- Oppo vooc fast charging circuit and protocol
- Comparison of solutions of Qualcomm & MTK & Kirin mobile platform USB3.0
- STM32 如何定位导致发生 hard fault 的代码段
猜你喜欢

MySQL realizes read-write separation

RT-Thread的main线程“卡死”的一种可能原因及解决方案

sklearn之feature_extraction.text.CountVectorizer / TfidVectorizer

MP3mini播放模块arduino<DFRobotDFPlayerMini.h>函数详解

JS object and event learning notes

I2C bus timing explanation

Gallery之图片浏览、组件学习

I2C总线时序详解

Time slice polling scheduling of RT thread threads

FTP文件上传文件实现,定时扫描文件夹上传指定格式文件文件到服务器,C语言实现FTP文件上传详解及代码案例实现
随机推荐
MySQL数据库面试题
Those commonly used tool classes and methods in hutool
Machine learning -- linear regression (sklearn)
Togglebutton realizes the effect of switching lights
I2C总线时序详解
Reading notes of difficult career creation
2020 WANGDING cup_ Rosefinch formation_ Web_ nmap
分布式節點免密登錄
【CDH】CDH5.16 配置 yarn 任务集中分配设置不生效问题
Connexion sans mot de passe du noeud distribué
C语言函数之可变参数原理:va_start、va_arg及va_end
[CDH] cdh5.16 configuring the setting of yarn task centralized allocation does not take effect
Contiki source code + principle + function + programming + transplantation + drive + network (turn)
Priority inversion and deadlock
C language callback function [C language]
Word typesetting (subtotal)
MongoDB
电商数据分析--用户行为分析
冒泡排序【C语言】
互联网协议详解