微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 Yocto bitbake 编译步骤中剥离和 objcopy 构建的 .so 文件?

如何解决如何在 Yocto bitbake 编译步骤中剥离和 objcopy 构建的 .so 文件?

这个问题来自:
Do I need to edit the .patch files needed for building mdns 878.200.35 in Yocto?
这将通过几个帖子追溯到相当大的背景。

由于“mDNS”似乎在我的目标中工作,并且配方将 libdns_sd.so 放入 “/usr/bin/”,我接着说下一个需要,就是构建OCA,它与 libdns_sd.so。我为它创建了另一个层并复制到我的源文件文件夹名为“Src”,到我层的文件文件夹下的 oca-1.2.7 文件夹。 我为它写了以下食谱。 CAP_HOME 环境变量必须是 设置为基本文件夹 oca-1.2.7,以便“makefileOCA”等工作。
将带下划线的文本放在引号中似乎有助于让 StackOverflow 接受我的问题格式。
我还把 // 注释标记放在我的代码输出块中的每一行前面。不确定这是否有帮助。

//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”或编译我的新层:

//~/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,现在我只需要通过指定的条带 和“objcopy”操作,或“do_populate_sysroot”和“do_package”,它们似乎 是各自的任务。

那么我该如何解决这个问题?此外,您能否向我指出最相关的 文档以便我可以理解基本流程?同时我 继续谷歌和阅读。

编辑:我有点希望得到一个可以避免以下可怕黑客攻击的答案。但不管怎样,我想。

我发现并尝试了这个: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 分钟:

//~/Yocto/imx-yocto-bsp/build-wayland$ time bitbake oca  
//Parsing recipes: 100% |############################################################################################| Time: 0:01:04  
//Parsing of 3212 .bb files complete (0 cached,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  

似乎不打包构建结果不是答案。

编辑:一个明显的蠕虫罐头已经打开,需要一个新问题;请参阅How do I get a complex non-Yocto makefile-based project to cross-compile in a Yocto layer?

解决方法

你问题的最后一个错误告诉你 do_install 任务安装文件,但它们没有分配给任何包。 将以下几行添加到您的食谱中

FILES_${PN} += "${libdir}/OcaProtoController.so"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。