diff options
author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2021-05-07 11:52:05 -0400 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2021-05-07 11:52:05 -0400 |
commit | 29de6c30b8ea8133c2fbb64083916617aa418861 (patch) | |
tree | 5e437f6e29f511bc816b44b034e1f6607b9ccce4 | |
parent | e99974aa57ec9aa4f51817346ddc744bd9f61eca (diff) | |
download | meta-virtualization-29de6c30b8ea8133c2fbb64083916617aa418861.tar.gz |
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.bb | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/recipes-containers/umoci/umoci_git.bb b/recipes-containers/umoci/umoci_git.bb index 5273a70e..7cd147b2 100644 --- a/recipes-containers/umoci/umoci_git.bb +++ b/recipes-containers/umoci/umoci_git.bb | |||
@@ -21,30 +21,60 @@ inherit go | |||
21 | # go package. | 21 | # go package. |
22 | EXTRA_OEMAKE="BUILDTAGS=''" | 22 | EXTRA_OEMAKE="BUILDTAGS=''" |
23 | 23 | ||
24 | |||
25 | do_compile_class-native () { | ||
26 | export GOARCH="${BUILD_GOARCH}" | ||
27 | |||
28 | # Pass the needed cflags/ldflags so that cgo can find the needed headers files and libraries | ||
29 | export CGO_ENABLED="1" | ||
30 | export CFLAGS="${BUILD_CFLAGS}" | ||
31 | export LDFLAGS="${BUILD_LDFLAGS}" | ||
32 | export CGO_CFLAGS="${BUILD_CFLAGS}" | ||
33 | |||
34 | # as of go 1.15.5, there are some flags the CGO doesn't like. Rather than | ||
35 | # clearing them all, we sed away the ones we don't want. | ||
36 | # export CGO_LDFLAGS="$(echo ${BUILD_LDFLAGS} | sed 's/-Wl,-O1//g' | sed 's/-Wl,--dynamic-linker.*?( \|$\)//g')" | ||
37 | export CC="${BUILD_CC}" | ||
38 | export LD="${BUILD_LD}" | ||
39 | |||
40 | export GOPATH="${WORKDIR}/git/" | ||
41 | export GO111MODULE=off | ||
42 | |||
43 | cd ${S} | ||
44 | |||
45 | # why static ? patchelf will be run on dynamic binaries and it breaks | ||
46 | # the executable (coredump) | ||
47 | # https://forum.snapcraft.io/t/patchelf-broke-my-binary/4928 | ||
48 | # https://github.com/NixOS/patchelf/issues/146 | ||
49 | oe_runmake umoci.static | ||
50 | |||
51 | # so the common install can find our binary | ||
52 | cp umoci.static umoci | ||
53 | } | ||
54 | |||
24 | do_compile() { | 55 | do_compile() { |
25 | export GOARCH="${TARGET_GOARCH}" | 56 | export GOARCH="${TARGET_GOARCH}" |
26 | export GOPATH="${WORKDIR}/git/" | 57 | export GOPATH="${WORKDIR}/git/" |
27 | 58 | ||
28 | # Pass the needed cflags/ldflags so that cgo | 59 | # Pass the needed cflags/ldflags so that cgo |
29 | # can find the needed headers files and libraries | 60 | # can find the needed headers files and libraries |
30 | export CGO_ENABLED="1" | 61 | export CGO_ENABLED="1" |
31 | export CFLAGS="" | 62 | export CFLAGS="" |
32 | export LDFLAGS="" | 63 | export LDFLAGS="" |
33 | export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 64 | export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}" |
34 | export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 65 | export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" |
35 | 66 | ||
36 | export GO111MODULE=off | 67 | export GO111MODULE=off |
37 | 68 | ||
38 | cd ${S} | 69 | cd ${S} |
39 | 70 | ||
40 | oe_runmake umoci | 71 | oe_runmake umoci |
41 | } | 72 | } |
42 | 73 | ||
43 | do_install() { | 74 | do_install() { |
44 | install -d ${D}/${sbindir} | 75 | install -d ${D}/${sbindir} |
45 | install ${S}/umoci ${D}/${sbindir} | 76 | install ${S}/umoci ${D}/${sbindir} |
46 | } | 77 | } |
47 | 78 | ||
48 | INSANE_SKIP_${PN} += "ldflags already-stripped" | 79 | INSANE_SKIP_${PN} += "ldflags already-stripped" |
49 | |||
50 | BBCLASSEXTEND = "native" | 80 | BBCLASSEXTEND = "native" |