目录recipe-sysroot-native占用200M+磁盘空间,我发现它存在于每个WORKDIR中,我认为它们都有保存内容。拥有这么多副本是一种磁盘空间的浪费,而且可能会减慢构建时间。能不能放在一个固定的地方,每个WORKDIR通过符号链接(symbolic link)访问它??
最佳答案
如 staging.bbclass 中所述, recipe-sysroot
和 recipe-sysroot-native
中的文件并不总是副本。 Yocto 尝试创建指向实际文件的硬链接(hard link)(即仅增加对文件的引用计数)。
所以 recipe-sysroot
和 recipe-sysroot-native
中的所有文件都是指向磁盘中一个源文件的硬链接(hard link)。所以您的磁盘上没有任何重复的空间占用。
Here您可以看到 staging.bbclass
的实际实现,它会尝试创建硬链接(hard link),如果不允许,则会创建一个副本。
您始终可以使用 ls -i
查看文件的引用计数。
以下文字转自yocto mega meanual,
The second stage addresses recipes that want to use something from another recipe and declare a dependency on that recipe through the DEPENDS variable. The recipe will have a do_prepare_recipe_sysroot task and when this task executes, it creates the recipe-sysroot and recipe-sysroot-native in the recipe work directory (i.e. WORKDIR). The OpenEmbedded build system creates hard links to copies of the relevant files from sysroots-components into the recipe work directory.
Note: If hard links are not possible, the build system uses actual copies.
关于yocto - 如何简化 recipe-sysroot-native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53331063/