【问题标题】:How do I strip and objcopy a built .so file in the Yocto bitbake compile step?如何在 Yocto bitbake 编译步骤中剥离和 objcopy 构建的 .so 文件?
【发布时间】:2021-03-12 21:09:36
【问题描述】:

此问题来自:
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.  

我将这三行放在 CONF_VERSION = "1" 下的 ~/Yocto/imx-yocto-bsp/build-wayland/conf/local.conf 中。这显然有效果:
它似乎遍历了几乎所有其他包,大约需要 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, 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  

看来不打包构建结果不是答案。

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

【问题讨论】:

  • 在 do_compile 任务中使用普通 make 似乎是错误的。你介意尝试使用 oe_runmake 吗?
  • @Florian Berndl:感谢您的意见。我马上试试。我得到的下一个错误是:“cc1plus: error: bad value ('armv8-a') for '-march=' switch” 这让我发现我不能使用主机安装的 gcc 进行交叉-编译,我试图弄清楚如何设置在我的其他添加层中发生的交叉编译。更改为 oe_runmake 会这样做还是需要进行其他更改?
  • 将 do_compile 中的 make 更改为 oe_runmake 对执行“bitbake oca”没有任何明显的影响;我仍然收到“cc1plus: error: bad value ('armv8-a') for '-march=' switch” 我总是删除 tmp 文件夹并首先执行“bitbake -c cleansstate oca”。
  • 一罐明显的蠕虫已经打开,需要一个新问题;请看stackoverflow.com/questions/66680355/…

标签: yocto stackexchange-api nxp-microcontroller


【解决方案1】:

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

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

【讨论】:

  • 谢谢;这有帮助。它现在正在发生其他错误。我有点希望得到一个可以避免可怕的黑客攻击的答案;请参阅我的帖子中的编辑添加内容,我将很快添加。我赞成你的回答。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-06-15
  • 2018-01-09
  • 1970-01-01
  • 2014-01-06
  • 2020-06-20
  • 2021-07-08
  • 2018-05-05
相关资源
最近更新 更多