Mender-artifact with nativesdk bbclass

I’m trying to extend the mender-artifact recipe with nativesdk so I can include it in our SDK. We would like to use it for manipulating the artifact to inject applications build with the SDK. I found a post on the old mailing list, but there was no response: https://groups.google.com/a/lists.mender.io/forum/#!msg/mender/6_A7TVA_H18/EfxRApwBCAAJ

I’m very familiar with Yocto, but not so much with golang, so I’m a bit stumped on where to even start.

I’m hitting the following error:

    GOARCH="amd64"
    GOBIN=""
    GOCACHE="off"
    GOEXE=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
    GOPATH="/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/build:/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/recipe-sysroot/opt/modus/tonos-r1/2.1.0/sysroots/x86_64-modussdk-linux/usr/lib/x86_64-modussdk-linux/go"
    GOPROXY=""
    GORACE=""
    GOROOT="/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/recipe-sysroot-native/usr/lib/go"
    GOTMPDIR="/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/go-tmp"
    GOTOOLDIR="/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/recipe-sysroot-native/usr/lib/x86_64-modussdk-linux/go/pkg/tool/linux_amd64"
    GCCGO="gccgo"
    CC="x86_64-modussdk-linux-gcc --sysroot=/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/recipe-sysroot"
    CXX="x86_64-modussdk-linux-g++ --sysroot=/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/recipe-sysroot"
    CGO_ENABLED="1"
    GOMOD=""
    CGO_CFLAGS="-O2 -pipe"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-O2 -pipe"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-Wl,-O1"
    PKG_CONFIG="pkg-config"
    GOGCCFLAGS="--sysroot=/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/recipe-sysroot -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/go-tmp/go-build653512947=/tmp/go-build -gno-record-gcc-switches"
    NOTE: make -j 8 GOPATH=/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/build:/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/recipe-sysroot/opt/modus/tonos-r1/2.1.0/sysroots/x86_64-modussdk-linux/usr/lib/x86_64-modussdk-linux/go -C /home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/build/src/github.com/mendersoftware/mender-artifact V=1 install
    make: Entering directory '/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/git/src/github.com/mendersoftware/mender-artifact'
    cd cli/mender-artifact && x86_64-modussdk-linux-go install -ldflags "-X main.Version=2.4.1" -v 
    NOTE: .com is removed below as the forum wont let me post links
    github./mendersoftware/mender-artifact/vendor/golang.org/x/sys/unix
    github./mendersoftware/mender-artifact/vendor/github.com/pkg/errors
    github./mendersoftware/mender-artifact/vendor/github.com/urfave/cli
    github./mendersoftware/mender-artifact/artifact
    github./mendersoftware/mender-artifact/handlers
    github./mendersoftware/mender-artifact/awriter
    github./mendersoftware/mender-artifact/areader
    github./mendersoftware/mender-artifact/vendor/golang.org/x/crypto/ssh/terminal
    github./mendersoftware/mender-artifact/vendor/github.com/sirupsen/logrus
    github./mendersoftware/mender-artifact/cli/mender-artifact
    # github.com/mendersoftware/mender-artifact/cli/mender-artifact
    /home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/recipe-sysroot-native/usr/lib/x86_64-modussdk-linux/go/pkg/tool/linux_amd64/link: seeking to -12042 in $WORK/b001/exe/a.out: seek $WORK/b001/exe/a.out: invalid argument
    Makefile:45: recipe for target 'install' failed
    make: *** [install] Error 2
    make: Leaving directory '/home/mcampbell/work/izo-yocto/build-tonos-r1/tmp/work/x86_64-nativesdk-modussdk-linux/nativesdk-mender-artifact/2.4.1-r0/git/src/github.com/mendersoftware/mender-artifact'
    ERROR: oe_runmake failed
    WARNING: exit code 1 from a shell command.

Edit: @mirzak: Formatting

1 Like

I tried to reproduce using the warrior branch together with poky, but it worked for me. At least the following sequence,

I updated the recipe with:

BBCLASSEXTEND = "native nativesdk"

and then ran:

bitbake nativesdk-mender-artifact

Which Yocto version are you using?

1 Like

Thanks for the super quick reply! We are currently on Thud, so this is a good clue. I’ll take a look at what’s changed in go.bbclass between the two versions of Poky. I bet the answer is in there.

That gives me something to dig into but if you have any other thoughts they would be appreciated.

Sorry, I spaced. We’re actually on Poky Thud, not Rocko. (I edited the original post to be correct).

I tried just copying in go.bbclass from the master of Poky into my Thud version of Poky locally. Unfortunately, the error still persists.

Can at least confirm that I can reproduce this on thud as well. Though no idea why it is happening yet :slight_smile:

Thanks for giving me some sanity there. FYI, I’ve decided to take the binary built by the mender-artifact-native recipe and create a nativesdk recipe that just copied that prebuilt binary in. That will get us going for now. We plan up on updating to Warrior in the future so we will be able to go back tot he more proper method of building from source at that time. Thank you very much for the help!

1 Like

@mirzak
I noticed above that GOCACHE is “off”. I’ve come across this a couple times on xilinx-zynq, and now again on xilinx-zynqmp. Xilinx currently supports “thud”.

I’ve found that for mender, mender-artifact, and any other golang recipes, I’ve had to add the following to those recipes as a workaround:

do_compile_prepend () {
export GOCACHE="${B}/.cache"
}

This is probably fixed somewhere after thud branch. Hope that helps someone else.

Thanks for reporting @wkswain.

I have never experienced any problems with this. Looking at go.bbclass, this was only fixed on zeus branch and later. But I guess it depends on the host environment if it allows it or not.

The upstream fix:

I think it would be ok to fix this in the Mender recipes, but if the problem exists for all go recipes I do not know if it is helpful.