0

This follows on from
How do I strip and objcopy a built .so file in the Yocto bitbake compile step?
This leads back to considerable background information.

As mentioned in the previous question, I am seeking to build OCA, which I have as a non-Yocto makefile-based project, in Yocto. The project, which builds fine outside of Yocto, and even in Yocto, is quite complex. The issue is that it is not cross-compiling for my target, which is aarch64 armv8-a. It is building successfully, but for my host machine, which is x86-64. Then Yocto sensibly refuses to package it, saying "Unable to recognise the format of the input file".
I changed the compile flags in my makefile to -march=armv8-a, but got the error "cc1plus: error: bad value ('armv8-a') for '-march=' switch" which seems to mean that I can't use the host's installed gcc for cross-compiling, but rather a cross-compiler is needed. I previously custom-added two additional layers, a sample helloworld and mDNS (see previous questions for lots of background), and they all cross-compiled fine, so I know that Yocto is basically set up to do it. What is the method to get the cross-compilation to happen? Do I need to do a lot of pervasive changes to my project's makefile system? It may not ever have been designed with Yocto in mind.

I am looking into this: "cross-compile library recipe in yocto":
cross-compile library recipe in yocto
which seems to have some relevant information. Edit: it was only standard stuff that I had seen before; nothing about how cross-compilation gets invoked instead of the host machine's gcc.

Edit: My updated recipe, with the FILES_${PN} added and make changed to oe_runmake.

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"
oe_runmake -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
}

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

Edit: I found some info:
https://www.yoctoproject.org/docs/1.8.1/adt-manual/adt-manual.html
https://www.yoctoproject.org/docs/1.8.1/adt-manual/adt-manual.html#setting-up-the-cross-development-environment
I commented-out the setting of CC and LD in makeOCA.inc.

I did the cleaning actions of deleting the tmp folder from my build-wayland build dir, and did "bitbake -c cleansstate oca". Then I did "time bitbake oca".
Now it looks like it is using the cross compiler.
The first error I got now is:
~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/oca-1.2.7/Obj/linuxApp/Release/OcaAgentProxies.a
aarch64-poky-linux-ld: cannot find crus: No such file or directory

So this is the next question: Can you tell me what "crus" means in "LDFLAGS = crus $@"?

microajim
  • 17
  • 9
  • You need to write a recipe for the package. Yocto supports GNU Make - just `inherit autotools`. – Oleksandr Kravchuk Mar 18 '21 at 00:13
  • @Oleksandr Kravchuk: Of course I wrote a recipe; the original is in my previous question (which is linked at top; you helped answer an older question farther back in the chain) and I added my latest version to this question. Where is "inherit autotools" added? – microajim Mar 18 '21 at 14:35
  • @Oleksandr Kravchuk: I thought I'd try adding "inherit autotools" to my recipe. "What's the worst thing that can happen?" I thought. "Can it send hatemail to my boss and delete my hard drive?" It doesn't look like it's supposed to go in there, because I have a do_compile and do_install block, and I believe I have to keep them, because the OCA project file arrangement and settings are not standard. But I added it right before the "FILES_${PN}" line, deleted the tmp folder from my build-wayland build dir, and did "bitbake -c cleansstate oca". Then I did "time bitbake oca". – microajim Mar 18 '21 at 17:50
  • I ended up getting these errors: ERROR: oca-1.2.7-r0 do_compile: oe_runmake failed ERROR: oca-1.2.7-r0 do_compile: Execution of '~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/temp/run.do_compile.14548' failed with exit code 1: make: *** No targets specified and no makefile found. Stop. – microajim Mar 18 '21 at 17:52
  • The OCA project is quite complex, with 63 "make" files of various descriptions in different directory levels. They include a makeOCA.inc file that hard-sets CC := gcc and also LD := gcc for Linux builds. I wonder if maybe something like a Yocto variable should go on the right-hand sides of those assignments. As always, I would like to be pointed at good documentation that explains this. There's an example of a good tutorial in my first post back in the chain, the helloworld tutorial by George Calin. – microajim Mar 18 '21 at 18:03

0 Answers0