[yocto] go-runtime ABI issues when executing a Go lang project compiled with yocto
Iván Castell
icastell at nayarsystems.com
Fri Feb 16 07:25:29 PST 2018
Hi forum.
I'm having ABI issues trying to compile a Go lang related project.
In order to resolve my project dependencies, I use dep tool. To be able to
dep, I had to modify meta/recipes-devtools/go/go-dep_0.3.0.bb, adding this
at the end:
BBCLASSEXTEND = "native nativesdk"
After that, this .bb builds my project fine:
GO_IMPORT = "bitbucket.org/project"
SRC_URI = "git://${GO_IMPORT}/protocol=http;user=${GIT_USER}:${GIT_PAS
S};destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRCREV = "90323909..."
inherit go
CGO_ENABLED = "1"
GO_DYNLINK = ""
do_compile_prepend() {
rm -f ${WORKDIR}/build/src/${GO_IMPORT}/Gopkg.toml
rm -f ${WORKDIR}/build/src/${GO_IMPORT}/Gopkg.lock
cd ${WORKDIR}/build/src/${GO_IMPORT}
dep init
dep ensure
}
deltask do_compile_ptest_base
deltask do_compile_ptest
DEPENDS = "go-dep-native mercurial-native"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
INHIBIT_PACKAGE_STRIP = "1"
FILES_${PN}_append = " /opt/bin"
RDEPENDS_${PN}-staticdev += "bash"
RDEPENDS_${PN}-dev += "bash"
However, when executing the generated binary, it has ABI issues:
$ /usr/bin/mybin
abi mismatch detected between the executable and libstd.so
fatal error: abi mismatch
runtime: panic before malloc heap initialized
Here I provide more information related with the compiled binary:
$ ldd /usr/bin/mybin
linux-vdso.so.1 (0x00007ffe321d9000)
libstd.so => /usr/lib/go/pkg/linux_amd64_dynlink/libstd.so
(0x00007f95463d7000)
libc.so.6 => /lib/libc.so.6 (0x0000003436200000)
libdl.so.2 => /lib/libdl.so.2 (0x0000003436a00000)
libpthread.so.0 => /lib/libpthread.so.0 (0x0000003436600000)
/lib/ld-linux-x86-64.so.2 (0x0000003435e00000)
$ file /usr/bin/mybin
/usr/bin/mybin: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib/ld-linux-x86-64.so.2, for GNU/Linux
3.2.0, BuildID[sha1]=0103acf63634df77e600eb114bf59977462ca51d, with
debug_info, not stripped
$ file /usr/lib/go/pkg/linux_amd64_dynlink/libstd.so
/usr/lib/go/pkg/linux_amd64_dynlink/libstd.so: ELF 64-bit LSB shared
object, x86-64, version 1 (SYSV), dynamically linked,
BuildID[sha1]=2d2f135b2f9eab19a7ceff1923820bf635e10eb1, with debug_info,
not stripped
As the missage error says, the problem seems related with the generation of
the libstd.so dynamic library. Dynamic generation is controlled by
GO_DYNLINK environ variable (see meta/recipes-devtools/go/go-runtime.inc).
I could fix my issue with this nasty hack:
# if [ -n "${GO_DYNLINK}" ]; then
# cp ${B}/go_bootstrap ${B}/pkg/tool/${BUILD_GOTUPLE}
# GO_FLAGS="-buildmode=shared" GO_LDFLAGS="-extldflags
\"${LDFLAGS}\"" ./make.bash --target-only
# fi
After commenting that condicion and rebuilding all my go yocto-related
environment, the binary is compiled as static and it works as expected.
This is not a nice way to solve this issue.
What should be the proper way to manage this issue?
Thank you in advance! :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20180216/786c8d99/attachment.html>
More information about the yocto
mailing list