当前位置:网站首页>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的默认选项
边栏推荐
- Comparison of solutions of Qualcomm & MTK & Kirin mobile platform USB3.0
- Linux yum安装MySQL
- ESP8266使用arduino连接阿里云物联网
- Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries(XGBoost)
- Vert. x: A simple TCP client and server demo
- FreeRTOS 任务函数里面的死循环
- Basic knowledge of lithium battery
- Pytorch-温度预测
- RT-Thread 线程的时间片轮询调度
- Nodejs connect mysql
猜你喜欢
Implementation scheme of distributed transaction
MySQL数据库面试题
Stage 4 MySQL database
RT-Thread 线程的时间片轮询调度
E-commerce data analysis -- User Behavior Analysis
sklearn之feature_extraction.text.CountVectorizer / TfidVectorizer
Detailed explanation of 5g working principle (explanation & illustration)
STM32 how to locate the code segment that causes hard fault
Linux yum安装MySQL
R & D thinking 01 ----- classic of embedded intelligent product development process
随机推荐
[yarn] yarn container log cleaning
[template] KMP string matching
Some concepts often asked in database interview
[CDH] cdh5.16 configuring the setting of yarn task centralized allocation does not take effect
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
几个关于指针的声明【C语言】
分布式事务的实现方案
Several declarations about pointers [C language]
4. Install and deploy spark (spark on Yan mode)
Comparaison des solutions pour la plate - forme mobile Qualcomm & MTK & Kirin USB 3.0
Pytorch four commonly used optimizer tests
2019 Tencent summer intern formal written examination
JS object and event learning notes
优先级反转与死锁
Variable star user module
RT-Thread 线程的时间片轮询调度
XML file explanation: what is XML, XML configuration file, XML data file, XML file parsing tutorial
MATLAB学习和实战 随手记
Togglebutton realizes the effect of switching lights
Yarn installation and use