简体   繁体   English

Yocto Dunfell 如何在全局范围内将编译器标志设置为“-Os”

[英]Yocto Dunfell how to set Compiler Flags to '-Os' Globally

I have a working Linux system image being produced for my ARM board with Yocto ( Dunfell branch ).我使用 Yocto(Dunfell 分支)为我的 ARM 板生成了一个可用的 Linux 系统映像。

Space occupied by the rootfs is a premium and I am working on shrinking the image. rootfs 占用的空间非常重要,我正在努力缩小图像。

I want to experiment with the GCC '-Os' flag, to optimize for space.我想尝试使用 GCC '-Os' 标志来优化空间。 I would like to set this globally for my experiment.我想为我的实验全局设置它。 I found the following information in a presentation ( https://pretalx.com/yocto-project-summit-2020/talk/AY37HF/ ):我在演示文稿中找到了以下信息( https://pretalx.com/yocto-project-summit-2020/talk/AY37HF/ ):

在此处输入图片说明

I added the following to my image_0.1.bb file.我将以下内容添加到我的image_0.1.bb文件中。 However, I do not see the '-Os' optimization flag being used in any package.但是,我没有看到任何包中使用了“-Os”优化标志。

# Disabled until the option works properly -feliminate-dwarf2-dups
FULL_OPTIMIZATION = "-Os -pipe ${DEBUG_FLAGS}"
DEBUG_OPTIMIZATION = "-Og ${DEBUG_FLAGS} -pipe"
SELECTED_OPTIMIZATION = "${@d.getVar(oe.utils.vartrue('DEBUG_BUILD', 'DEBUG_OPTIMIZATION', 'FULL_OPTIMIZATION', d))}"

Is the code correct and, if so, where should I put this code?代码是否正确,如果正确,我应该把这个代码放在哪里? If not correct, how can I globally add the '-Os' compiler optimization flag to my project?如果不正确,如何将“-Os”编译器优化标志全局添加到我的项目中? Thanks.谢谢。

Global options must be added to one of the global configuration files.全局选项必须添加到全局配置文件之一。
For testing things this would typically be conf/local.conf.对于测试,这通常是 conf/local.conf。 You only need to add the variables you actually change as bitbake uses lazy evaluation of variables values.您只需要添加您实际更改的变量,因为 bitbake 使用变量值的惰性求值。

Variables in recipe files only affect the tasks for that recipe.配方文件中的变量仅影响该配方的任务。 This means that nothing you do in the image recipe can affect how tasks in other recipes are done.这意味着您在图像配方中所做的任何事情都不会影响其他配方中任务的完成方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM