aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2021-05-07 11:52:05 -0400
committerBruce Ashfield <bruce.ashfield@gmail.com>2021-05-07 11:52:05 -0400
commit29de6c30b8ea8133c2fbb64083916617aa418861 (patch)
tree5e437f6e29f511bc816b44b034e1f6607b9ccce4
parente99974aa57ec9aa4f51817346ddc744bd9f61eca (diff)
downloadmeta-virtualization-29de6c30b8ea8133c2fbb64083916617aa418861.tar.gz
meta-virtualization-29de6c30b8ea8133c2fbb64083916617aa418861.tar.bz2
meta-virtualization-29de6c30b8ea8133c2fbb64083916617aa418861.zip
umoci: create -native do_compile and make it static
We need to use different build architecture and flags for the native variant, so add a specific do_compile for it. The settings are taken from the kubernetes recipes native go build. We also switch to the umoci.static for -native, since patchelf is breaking our executable if we leave it dynamic. Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r--recipes-containers/umoci/umoci_git.bb60
1 files changed, 45 insertions, 15 deletions
diff --git a/recipes-containers/umoci/umoci_git.bb b/recipes-containers/umoci/umoci_git.bb
index 5273a70..7cd147b 100644
--- a/recipes-containers/umoci/umoci_git.bb
+++ b/recipes-containers/umoci/umoci_git.bb
@@ -21,30 +21,60 @@ inherit go
# go package.
EXTRA_OEMAKE="BUILDTAGS=''"
+
+do_compile_class-native () {
+ export GOARCH="${BUILD_GOARCH}"
+
+ # Pass the needed cflags/ldflags so that cgo can find the needed headers files and libraries
+ export CGO_ENABLED="1"
+ export CFLAGS="${BUILD_CFLAGS}"
+ export LDFLAGS="${BUILD_LDFLAGS}"
+ export CGO_CFLAGS="${BUILD_CFLAGS}"
+
+ # as of go 1.15.5, there are some flags the CGO doesn't like. Rather than
+ # clearing them all, we sed away the ones we don't want.
+ # export CGO_LDFLAGS="$(echo ${BUILD_LDFLAGS} | sed 's/-Wl,-O1//g' | sed 's/-Wl,--dynamic-linker.*?( \|$\)//g')"
+ export CC="${BUILD_CC}"
+ export LD="${BUILD_LD}"
+
+ export GOPATH="${WORKDIR}/git/"
+ export GO111MODULE=off
+
+ cd ${S}
+
+ # why static ? patchelf will be run on dynamic binaries and it breaks
+ # the executable (coredump)
+ # https://forum.snapcraft.io/t/patchelf-broke-my-binary/4928
+ # https://github.com/NixOS/patchelf/issues/146
+ oe_runmake umoci.static
+
+ # so the common install can find our binary
+ cp umoci.static umoci
+}
+
do_compile() {
- export GOARCH="${TARGET_GOARCH}"
- export GOPATH="${WORKDIR}/git/"
+ export GOARCH="${TARGET_GOARCH}"
+ export GOPATH="${WORKDIR}/git/"
- # Pass the needed cflags/ldflags so that cgo
- # can find the needed headers files and libraries
- export CGO_ENABLED="1"
- export CFLAGS=""
- export LDFLAGS=""
- export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
- export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+ # Pass the needed cflags/ldflags so that cgo
+ # can find the needed headers files and libraries
+ export CGO_ENABLED="1"
+ export CFLAGS=""
+ export LDFLAGS=""
+ export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+ export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
- export GO111MODULE=off
+ export GO111MODULE=off
- cd ${S}
+ cd ${S}
- oe_runmake umoci
+ oe_runmake umoci
}
do_install() {
- install -d ${D}/${sbindir}
- install ${S}/umoci ${D}/${sbindir}
+ install -d ${D}/${sbindir}
+ install ${S}/umoci ${D}/${sbindir}
}
INSANE_SKIP_${PN} += "ldflags already-stripped"
-
BBCLASSEXTEND = "native"