Go error occurred by attempting to build mender master branch via cross compiling

that was ambiguous! shall i use native sysroot or target sysroot?

nevertheless i tried both. both threw different errors. it seems target sysroot threw more errors like it didn’t agree with gnu. and native sysroot seems only can not find stdlib.

so with command with target sysroot like this:

make CGO_CFLAGS="–sysroot=SDKTARGETSYSROOT -I{LIBLZMA_INSTALL_PATH}/include" CGO_LDFLAGS="–sysroot=SDKTARGETSYSROOT -L{LIBLZMA_INSTALL_PATH}/lib" CGO_ENABLED=1 GOOS=linux GOARCH=arm

it appears following error:

go build -ldflags “-X github.com/mendersoftware/mender/conf.Version=412268f

github.com/mendersoftware/mender/vendor/github.com/remyoudompheng/go-liblzma

In file included from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/gnu/stubs.h:55:0,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/features.h:447,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/inttypes.h:25,
from /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/include/lzma.h:124,
from vendor/github.com/remyoudompheng/go-liblzma/reader.go:9:
/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/gnu/stubs-32.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory

include <gnu/stubs-soft.h>

       ^~~~~~~~~~~~~~~~~~

compilation terminated.

os/user

In file included from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/gnu/stubs.h:55:0,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/features.h:447,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/unistd.h:25,
from /usr/local/go/src/os/user/cgo_lookup_unix.go:20:
/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/gnu/stubs-32.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory

include <gnu/stubs-soft.h>

       ^~~~~~~~~~~~~~~~~~

compilation terminated.

net

In file included from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/gnu/stubs.h:55:0,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/features.h:447,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/netdb.h:25,
from /usr/local/go/src/net/cgo_linux.go:10:
/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/gnu/stubs-32.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory

include <gnu/stubs-soft.h>

       ^~~~~~~~~~~~~~~~~~

compilation terminated.

github.com/mendersoftware/mender/vendor/github.com/bmatsuo/lmdb-go/lmdb

In file included from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/gnu/stubs.h:55:0,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/features.h:447,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/bits/libc-header-start.h:33,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/stdlib.h:25,
from vendor/github.com/bmatsuo/lmdb-go/lmdb/cursor.go:4:
/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/gnu/stubs-32.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory

include <gnu/stubs-soft.h>

       ^~~~~~~~~~~~~~~~~~

compilation terminated.
Makefile:75: recipe for target ‘mender’ failed
make: *** [mender] Error 2

but with command with native sysroot like this:

make CGO_CFLAGS="–sysroot=/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux -I${LIBLZMA_INSTALL_PATH}/include" CGO_LDFLAGS="–sysroot=/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux -L${LIBLZMA_INSTALL_PATH}/lib" CGO_ENABLED=1 GOOS=linux GOARCH=arm

it occurs less error report only this:

go build -ldflags “-X github.com/mendersoftware/mender/conf.Version=412268f

runtime/cgo

_cgo_export.c:3:10: fatal error: stdlib.h: No such file or directory
#include <stdlib.h>
^~~~~~~~~~
compilation terminated.
Makefile:75: recipe for target ‘mender’ failed
make: *** [mender] Error 2

You are cross-compiling for target, so target sysroot.

well! Native seems that it only has problem with finding stdlib and target sysroot has problem to find <gnu/stubs-soft.h>.

both of them give me the feeling that some of environment parameters are still missing.

Yes, but this is not interesting if you want to compile something that runs on the target. If you want to compile to run native the arguments would look very different.

target sysroot has problem to find <gnu/stubs-soft.h>.

This looks like a issue related to soft vs hard float flags to the compiler. You might need to add GOARM=5 if your target does not support hard floating

no! adding GOARM=5 doesn’t work. same error! and i tried GOARM=7 also. it doesn’t help either,
i believe it may has something to do with -mfloat-abi=hard but i already run that with CC in env file.

i have tried command with this:

make CGO_CFLAGS=“–sysroot=$SDKTARGETSYSROOT -mfloat-abi=hard -I${LIBLZMA_INSTALL_PATH}/include” CGO_LDFLAGS=“–sysroot=$SDKTARGETSYSROOT -mfloat-abi=hard -L${LIBLZMA_INSTALL_PATH}/lib” CGO_ENABLED=1 GOOS=linux GOARCH=arm

the gnu errors have then gone away!! but it appears another error which i believe it has occurred earlier with similar error.

go build -ldflags “-X github.com/mendersoftware/mender/conf.Version=412268f

github.com/mendersoftware/mender/vendor/github.com/bmatsuo/lmdb-go/lmdb

mdb.c: In function ‘mdb_cursor_put’:
mdb.c:6535:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (SIZELEFT(fp) < offset) {
^
mdb.c:6540:5: note: here
case MDB_CURRENT:
^~~~

GitHub - mendersoftware/mender: Mender over-the-air software updater client.

/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so while searching for lzma
go build github.com/mendersoftware/mender: copying /tmp/go-build463102029/b001/exe/a.out: open mender: permission denied
Makefile:75: recipe for target ‘mender’ failed
make: *** [mender] Error 1

this error seems a recurring error. it must also already have occurred to you.

according to you like following:

can we bypass that problem (gnu/stub-soft etc) with different approach?

also it seems my replies are limited i can not reply so fast i always have to wait almost a hour.

this error seems a recurring error. it must also already have occurred to you.

I have not see this. I think that you did not successfully cross-compile the liblzma.so. You can check by running:

file /home/rui/go/src/github.com/mendersoftware/mender/xz-5.2.4/install/lib/liblzma.so

can we bypass that problem (gnu/stub-soft etc) with different approach?

Not that I am aware of.

also it seems my replies are limited i can not reply so fast i always have to wait almost a hour.

It is probably limiting you, because you are not wrapping your logs in proper formatting and count this as text which probably triggers some anti-spam.

This forum supports markdown syntax, so you can use that you enclose your code blocks

that was answer to