如何在 Yocto bitbake 编译步骤中剥离和 objcopy 构建的 .so 文件? [英] How do I strip and objcopy a built .so file in the Yocto bitbake compile step?
问题描述
这个问题来自:
我需要编辑在 Yocto 中构建 mdns 878.200.35 所需的 .patch 文件吗?
这将通过几个帖子追溯到相当大的背景.
This question follows on from:
Do I need to edit the .patch files needed for building mdns 878.200.35 in Yocto?
This chains back through several posts to considerable background.
由于mDNS"似乎在我的目标中工作,并且配方将 libdns_sd.so 放入/usr/bin/",我接着说下一个需要,就是构建OCA,它与libdns_sd.so.我为它创建了另一个层并复制到我的源文件中将名为Src"的文件夹复制到我图层中 files 文件夹下的 oca-1.2.7 文件夹.我为它写了以下食谱.CAP_HOME 环境变量必须是设置为基本文件夹 oca-1.2.7,以便makefileOCA"等工作.
将带下划线的文本放在引号中似乎有助于让 StackOverflow 接受我的问题格式.
我还把//注释标记放在我的代码或输出块中的每一行前面.不确定这是否有帮助.
Since "mDNS" seemed to be working in my target and the recipe puts libdns_sd.so in
"/usr/bin/", I went on to the next need, which is to build OCA, which links with
libdns_sd.so. I created another layer for it and copied in my source files, in a
folder called "Src", to an oca-1.2.7 folder under the files folder in my layer.
I wrote the following recipe for it. The CAP_HOME environment variable has to be
set to the base folder, oca-1.2.7, for "makefileOCA", etc., to work.
Putting underlined text in quotes seems to help get StackOverflow to accept my question formatting.
Also I put // comment markers in front of every line in my code or output blocks. Not sure if that helped.
//DESCRIPTION = "OCA"
//PRIORITY = "optional"
//SECTION = "protocols"
//LICENSE = "MIT"
//LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
//SRC_URI = "file://oca-1.2.7"
//S = "${WORKDIR}/oca-1.2.7/Src"
//# Need to override S because BitBake expects the source to be in a dir called
//# oca-1.2.7 in the work dir, but it's actually additionally under Src/.
//# Need a do_compile, since OCA has a makefile with a non-standard name,
//# makefileOCA. Also needs non-standard flags, -f and linuxRelease.
//do_compile() {
//export CAP_HOME="${WORKDIR}/oca-1.2.7"
//make -f makefileOCA linuxRelease
//}
//do_install() {
// install -d ${D}${libdir}
// cp ../Obj/linuxApp/Release/OcaProtoController.so ${D}${libdir}/OcaProtoController.so
// chmod 0755 ${D}${libdir}/OcaProtoController.so
//}
然后我bitbaked"或编译我的新层:
Then I "bitbaked" or compiled my new layer:
//~/Yocto/imx-yocto-bsp/build-wayland$ time bitbake oca
//[Text is in white starting with the preceeding "time bitbake oca"]
//Parsing recipes: 100% |############################################################################################| Time: 0:01:04
//Parsing of 3212 .bb files complete (0 cached, 3212 parsed). 4627 targets, 468 skipped, 1 masked, 0 errors.
//NOTE: Resolving any missing task queue dependencies
//Build Configuration:
//BB_VERSION = "1.44.0"
//BUILD_SYS = "x86_64-linux"
//NATIVELSBSTRING = "ubuntu-18.04"
//TARGET_SYS = "aarch64-poky-linux"
//MACHINE = "imx8mnddr4evk"
//DISTRO = "fsl-imx-wayland"
//DISTRO_VERSION = "5.4-zeus"
//TUNE_FEATURES = "aarch64 cortexa53 crc crypto"
//TARGET_FPU = ""
//(snip SHA IDs)
//Initialising tasks: 100% |#########################################################################################| Time: 0:00:01
//Sstate summary: Wanted 13 Found 7 Missed 6 Current 67 (53% match, 92% complete)
//NOTE: Executing Tasks
//NOTE: Setscene tasks completed
//[Following text is all in red]
//ERROR: oca-1.2.7-r0 do_populate_sysroot: Fatal errors occurred in subprocesses:
//Command '['aarch64-poky-linux-strip', '--remove-section=.comment', '--remove-section=.note', '--strip-unneeded', '~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/sysroot-destdir/usr/lib/OcaProtoController.so']' returned non-zero exit status 1.
//Subprocess output:aarch64-poky-linux-strip: Unable to recognise the format of the input file `~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/sysroot-destdir/usr/lib/OcaProtoController.so'
//ERROR: Logfile of failure stored in: ~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/temp/log.do_populate_sysroot.14772
//ERROR: Task (~/Yocto/imx-yocto-bsp/build-wayland/meta-oca-so/recipes-example/oca/oca_1.2.7.bb:do_populate_sysroot) failed with exit code '1'
//ERROR: oca-1.2.7-r0 do_package: Fatal errors occurred in subprocesses:
//Command '['aarch64-poky-linux-objcopy', '--only-keep-debug', '~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/package/usr/lib/OcaProtoController.so', '~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/package/usr/lib/.debug/OcaProtoController.so']' returned non-zero exit status 1.
//Subprocess output:aarch64-poky-linux-objcopy: Unable to recognise the format of the input file `~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/package/usr/lib/OcaProtoController.so'
//ERROR: Logfile of failure stored in: ~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/temp/log.do_package.14771
//ERROR: Task (~/Yocto/imx-yocto-bsp/build-wayland/meta-oca-so/recipes-example/oca/oca_1.2.7.bb:do_package) failed with exit code '1'
//[Above text is all in red; back to white text following]
//NOTE: Tasks Summary: Attempted 504 tasks of which 494 didn't need to be rerun and 2 failed.
//Summary: 2 tasks failed:
//~/Yocto/imx-yocto-bsp/build-wayland/meta-oca-so/recipes-example/oca/oca_1.2.7.bb:do_populate_sysroot
//~/Yocto/imx-yocto-bsp/build-wayland/meta-oca-so/recipes-example/oca/oca_1.2.7.bb:do_package
//Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
//real 5m36.431s
//user 0m0.344s
//sys 0m0.057s
我发现:
//~/Yocto/imx-yocto-bsp/build-wayland$ find -iname *OcaProtoController*
//./tmp/work/aarch64-poky-linux/oca/1.2.7-r0/oca-1.2.7/Obj/linuxApp/Release/OcaProtoController.so
//./tmp/work/aarch64-poky-linux/oca/1.2.7-r0/image/usr/lib/OcaProtoController.so
//./tmp/work/aarch64-poky-linux/oca/1.2.7-r0/sysroot-destdir/usr/lib/OcaProtoController.so
//./tmp/work/aarch64-poky-linux/oca/1.2.7-r0/package/usr/lib/OcaProtoController.so
这非常令人鼓舞.我得到了我的构建结果,OcaProtoController.so,现在我只需要通过指定的条带和对象副本"操作,或do_populate_sysroot"和do_package",它们似乎是各自的任务.
This is extremely encouraging. I am getting my build result, OcaProtoController.so, and now I just need to get it through the indicated strip and "objcopy" operations, or "do_populate_sysroot" and "do_package", which appear to be the respective tasks.
那么我该如何解决这个问题?此外,您能否向我指出最相关的文档以便我可以理解基本流程?同时我继续谷歌和阅读.
So how do I fix this? Additionally, can you point me to the best relevant documentation so that I can understand the fundamental processes? Meanwhile I continue to google and read.
我有点希望得到一个可以避免以下可怕黑客攻击的答案.但不管怎样,我想.
I'm kind of hoping for an answer that would obviate the following horrible hack. But whatever works, I guess.
我发现并尝试了这个:https://github.com/nefethael/meta-随机/问题/1 :
I found and tried this: https://github.com/nefethael/meta-random/issues/1 :
//It compiles if you do the most horrible hack ever.
//INHIBIT_SYSROOT_STRIP = "1"
//INHIBIT_PACKAGE_STRIP = "1"
//INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
//The file stats is an executable file hidden in the vendor reference.
我将这三行放在 ~/Yocto/imx-yocto-bsp/build-wayland/conf/local.conf 下 CONF_VERSION = 1".这显然产生了影响:
它似乎遍历了几乎所有其他包裹,大约需要 20 分钟:
I put those three lines in ~/Yocto/imx-yocto-bsp/build-wayland/conf/local.conf under CONF_VERSION = "1". That clearly had an effect:
It seemed to go over almost every other package, taking about 20 mins:
//~/Yocto/imx-yocto-bsp/build-wayland$ time bitbake oca
//Parsing recipes: 100% |############################################################################################| Time: 0:01:04
//Parsing of 3212 .bb files complete (0 cached, 3212 parsed). 4627 targets, 468 skipped, 1 masked, 0 errors.
//NOTE: Resolving any missing task queue dependencies
//Build Configuration:
//(snip)
//Initialising tasks: 100% |#########################################################################################| Time: 0:00:00
//Sstate summary: Wanted 80 Found 0 Missed 80 Current 0 (0% match, 0% complete)
//NOTE: Executing Tasks
//NOTE: Setscene tasks completed
//[Following text is all in red]
//ERROR: oca-1.2.7-r0 do_package: QA Issue: oca: Files/directories were installed but not shipped in any package:
// /usr
// /usr/lib
// /usr/lib/OcaProtoController.so
//Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
//oca: 3 installed and not shipped files. [installed-vs-shipped]
//ERROR: oca-1.2.7-r0 do_package: Fatal QA errors found, failing task.
//ERROR: Logfile of failure stored in: ~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/temp/log.do_package.6146
//ERROR: Task (~/Yocto/imx-yocto-bsp/build-wayland/meta-oca-so/recipes-example/oca/oca_1.2.7.bb:do_package) failed with exit code '1'
//[Above text is all in red; back to white text following]
//NOTE: Tasks Summary: Attempted 504 tasks of which 2 didn't need to be rerun and 1 failed.
//Summary: 1 task failed:
//~/Yocto/imx-yocto-bsp/build-wayland/meta-oca-so/recipes-example/oca/oca_1.2.7.bb:do_package
//Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
//real 19m43.796s
//user 0m1.270s
//sys 0m0.164s
似乎不打包构建结果不是答案.
It seems that not packaging the build result is not the answer.
一个明显的蠕虫罐头已经打开,需要一个新问题;请参阅 如何让一个复杂的非 Yocto 基于 makefile 的项目在 Yocto 层中交叉编译?
An apparent can of worms has opened, necessitating a new question; please see How do I get a complex non-Yocto makefile-based project to cross-compile in a Yocto layer?
推荐答案
你问题的最后一个错误告诉你 do_install 任务安装文件,但它们没有分配给任何包.将以下几行添加到您的食谱中
The last error of you question tells you that the do_install tasks installs files but they are not assigned to any package. Add following lines to your recipe
FILES_${PN} += "${libdir}/OcaProtoController.so"
这篇关于如何在 Yocto bitbake 编译步骤中剥离和 objcopy 构建的 .so 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!