diff options
| author | Changqing Li <changqing.li@windriver.com> | 2026-02-09 16:30:43 +0800 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-02-09 20:22:07 +0000 |
| commit | 9a28d5edadbec84e07e64dc7fbb67543becf22a9 (patch) | |
| tree | 4ba40efe168312289dfba1edb815d20cbfc2bffb | |
| parent | 914b5d23c40e2d1feae4c8a25bae0820fcfb3bd3 (diff) | |
| download | meta-virtualization-9a28d5edadbec84e07e64dc7fbb67543becf22a9.tar.gz | |
recipes/golang: improve reproducibility
Refer [1], cgo will embeded cgo_ldflags in the intermediary output,
which make content ID will be incfluenced by cgo_ldflags.
'--sysroot=xxx' includes build path, which will make the binary not
reproducible, these recipes can build successfully without --sysroot, so
remove it
[1] https://git.openembedded.org/openembedded-core/commit/?id=1797741aad02b8bf429fac4b81e30cdda64b5448
Signed-off-by: Changqing Li <changqing.li@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
| -rw-r--r-- | recipes-containers/containerd/containerd_git.bb | 4 | ||||
| -rw-r--r-- | recipes-containers/cri-tools/cri-tools_git.bb | 4 | ||||
| -rw-r--r-- | recipes-containers/docker-compose/docker-compose_git.bb | 6 | ||||
| -rw-r--r-- | recipes-containers/docker/docker.inc | 4 | ||||
| -rw-r--r-- | recipes-containers/kubernetes/kubernetes_git.bb | 7 | ||||
| -rw-r--r-- | recipes-containers/nerdctl/nerdctl_git.bb | 4 | ||||
| -rw-r--r-- | recipes-containers/podman/podman_git.bb | 4 | ||||
| -rw-r--r-- | recipes-containers/runc/runc.inc | 4 |
8 files changed, 20 insertions, 17 deletions
diff --git a/recipes-containers/containerd/containerd_git.bb b/recipes-containers/containerd/containerd_git.bb index 081cf354..4a6d26c3 100644 --- a/recipes-containers/containerd/containerd_git.bb +++ b/recipes-containers/containerd/containerd_git.bb | |||
| @@ -48,8 +48,8 @@ do_compile() { | |||
| 48 | # Pass the needed cflags/ldflags so that cgo | 48 | # Pass the needed cflags/ldflags so that cgo |
| 49 | # can find the needed headers files and libraries | 49 | # can find the needed headers files and libraries |
| 50 | export CGO_ENABLED="1" | 50 | export CGO_ENABLED="1" |
| 51 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 51 | export CGO_CFLAGS="${CFLAGS}" |
| 52 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 52 | export CGO_LDFLAGS="${LDFLAGS}" |
| 53 | export BUILDTAGS="no_btrfs static_build netgo" | 53 | export BUILDTAGS="no_btrfs static_build netgo" |
| 54 | export CFLAGS="${CFLAGS}" | 54 | export CFLAGS="${CFLAGS}" |
| 55 | export LDFLAGS="${LDFLAGS}" | 55 | export LDFLAGS="${LDFLAGS}" |
diff --git a/recipes-containers/cri-tools/cri-tools_git.bb b/recipes-containers/cri-tools/cri-tools_git.bb index dad675e8..398c9ab0 100644 --- a/recipes-containers/cri-tools/cri-tools_git.bb +++ b/recipes-containers/cri-tools/cri-tools_git.bb | |||
| @@ -50,8 +50,8 @@ do_compile() { | |||
| 50 | export GOARCH="${TARGET_GOARCH}" | 50 | export GOARCH="${TARGET_GOARCH}" |
| 51 | # Pass the needed cflags/ldflags so that cgo can find the needed headers files and libraries | 51 | # Pass the needed cflags/ldflags so that cgo can find the needed headers files and libraries |
| 52 | export CGO_ENABLED="1" | 52 | export CGO_ENABLED="1" |
| 53 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 53 | export CGO_CFLAGS="${CFLAGS}" |
| 54 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 54 | export CGO_LDFLAGS="${LDFLAGS}" |
| 55 | export CFLAGS="" | 55 | export CFLAGS="" |
| 56 | export LDFLAGS="" | 56 | export LDFLAGS="" |
| 57 | export CC="${CC}" | 57 | export CC="${CC}" |
diff --git a/recipes-containers/docker-compose/docker-compose_git.bb b/recipes-containers/docker-compose/docker-compose_git.bb index ccb36a16..1c39c862 100644 --- a/recipes-containers/docker-compose/docker-compose_git.bb +++ b/recipes-containers/docker-compose/docker-compose_git.bb | |||
| @@ -58,8 +58,8 @@ do_compile() { | |||
| 58 | # Pass the needed cflags/ldflags so that cgo | 58 | # Pass the needed cflags/ldflags so that cgo |
| 59 | # can find the needed headers files and libraries | 59 | # can find the needed headers files and libraries |
| 60 | export GOARCH=${TARGET_GOARCH} | 60 | export GOARCH=${TARGET_GOARCH} |
| 61 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 61 | export CGO_CFLAGS="${CFLAGS}" |
| 62 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 62 | export CGO_LDFLAGS="${LDFLAGS}" |
| 63 | 63 | ||
| 64 | GO_LDFLAGS="-s -w -X internal.Version=${PV} -X ${COMPOSE_PKG}/internal.Version=${PV}" | 64 | GO_LDFLAGS="-s -w -X internal.Version=${PV} -X ${COMPOSE_PKG}/internal.Version=${PV}" |
| 65 | GO_BUILDTAGS="" | 65 | GO_BUILDTAGS="" |
| @@ -85,4 +85,4 @@ INSANE_SKIP:${PN} += "ldflags already-stripped" | |||
| 85 | 85 | ||
| 86 | # the AWS dependency is 8GB, try and control the | 86 | # the AWS dependency is 8GB, try and control the |
| 87 | # size of the clones | 87 | # size of the clones |
| 88 | BB_GIT_SHALLOW = "1" \ No newline at end of file | 88 | BB_GIT_SHALLOW = "1" |
diff --git a/recipes-containers/docker/docker.inc b/recipes-containers/docker/docker.inc index 99535a77..717874b7 100644 --- a/recipes-containers/docker/docker.inc +++ b/recipes-containers/docker/docker.inc | |||
| @@ -82,8 +82,8 @@ do_compile() { | |||
| 82 | # can find the needed headers files and libraries | 82 | # can find the needed headers files and libraries |
| 83 | export GOARCH=${TARGET_GOARCH} | 83 | export GOARCH=${TARGET_GOARCH} |
| 84 | export CGO_ENABLED="1" | 84 | export CGO_ENABLED="1" |
| 85 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 85 | export CGO_CFLAGS="${CFLAGS}" |
| 86 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 86 | export CGO_LDFLAGS="${LDFLAGS}" |
| 87 | export DOCKER_BUILDTAGS='${BUILD_TAGS} ${PACKAGECONFIG_CONFARGS}' | 87 | export DOCKER_BUILDTAGS='${BUILD_TAGS} ${PACKAGECONFIG_CONFARGS}' |
| 88 | export GO111MODULE=off | 88 | export GO111MODULE=off |
| 89 | 89 | ||
diff --git a/recipes-containers/kubernetes/kubernetes_git.bb b/recipes-containers/kubernetes/kubernetes_git.bb index f7b6940a..092b2475 100644 --- a/recipes-containers/kubernetes/kubernetes_git.bb +++ b/recipes-containers/kubernetes/kubernetes_git.bb | |||
| @@ -54,6 +54,9 @@ inherit cni_networking | |||
| 54 | 54 | ||
| 55 | COMPATIBLE_HOST = '(x86_64.*|arm.*|aarch64.*)-linux' | 55 | COMPATIBLE_HOST = '(x86_64.*|arm.*|aarch64.*)-linux' |
| 56 | 56 | ||
| 57 | CGO_LDFLAGS ?= "${LDFLAGS}" | ||
| 58 | CGO_LDFLAGS:remove = "${DEBUG_PREFIX_MAP}" | ||
| 59 | |||
| 57 | do_compile() { | 60 | do_compile() { |
| 58 | export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go:${UNPACKDIR}/git/" | 61 | export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go:${UNPACKDIR}/git/" |
| 59 | cd ${S} | 62 | cd ${S} |
| @@ -85,8 +88,8 @@ do_compile() { | |||
| 85 | export GOARCH="${TARGET_GOARCH}" | 88 | export GOARCH="${TARGET_GOARCH}" |
| 86 | # Pass the needed cflags/ldflags so that cgo can find the needed headers files and libraries | 89 | # Pass the needed cflags/ldflags so that cgo can find the needed headers files and libraries |
| 87 | export CGO_ENABLED="1" | 90 | export CGO_ENABLED="1" |
| 88 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 91 | export CGO_CFLAGS="${CFLAGS}" |
| 89 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 92 | export CGO_LDFLAGS="${LDFLAGS}" |
| 90 | export CFLAGS="" | 93 | export CFLAGS="" |
| 91 | export LDFLAGS="" | 94 | export LDFLAGS="" |
| 92 | export CC="${CC}" | 95 | export CC="${CC}" |
diff --git a/recipes-containers/nerdctl/nerdctl_git.bb b/recipes-containers/nerdctl/nerdctl_git.bb index 295925d5..203e84e6 100644 --- a/recipes-containers/nerdctl/nerdctl_git.bb +++ b/recipes-containers/nerdctl/nerdctl_git.bb | |||
| @@ -74,8 +74,8 @@ do_compile() { | |||
| 74 | # Pass the needed cflags/ldflags so that cgo | 74 | # Pass the needed cflags/ldflags so that cgo |
| 75 | # can find the needed headers files and libraries | 75 | # can find the needed headers files and libraries |
| 76 | export GOARCH=${TARGET_GOARCH} | 76 | export GOARCH=${TARGET_GOARCH} |
| 77 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 77 | export CGO_CFLAGS="${CFLAGS}" |
| 78 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 78 | export CGO_LDFLAGS="${LDFLAGS}" |
| 79 | 79 | ||
| 80 | # -trimpath removes build paths from the binary (required for reproducible builds) | 80 | # -trimpath removes build paths from the binary (required for reproducible builds) |
| 81 | oe_runmake GO=${GO} BUILDTAGS="${BUILDTAGS}" GO_BUILD_FLAGS="-trimpath -buildmode=pie" binaries | 81 | oe_runmake GO=${GO} BUILDTAGS="${BUILDTAGS}" GO_BUILD_FLAGS="-trimpath -buildmode=pie" binaries |
diff --git a/recipes-containers/podman/podman_git.bb b/recipes-containers/podman/podman_git.bb index f09e01f8..87e694e5 100644 --- a/recipes-containers/podman/podman_git.bb +++ b/recipes-containers/podman/podman_git.bb | |||
| @@ -88,8 +88,8 @@ do_compile() { | |||
| 88 | # can find the needed headers files and libraries | 88 | # can find the needed headers files and libraries |
| 89 | export GOARCH=${TARGET_GOARCH} | 89 | export GOARCH=${TARGET_GOARCH} |
| 90 | export CGO_ENABLED="1" | 90 | export CGO_ENABLED="1" |
| 91 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 91 | export CGO_CFLAGS="${CFLAGS}" |
| 92 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 92 | export CGO_LDFLAGS="${LDFLAGS}" |
| 93 | 93 | ||
| 94 | # podman now builds go-md2man and requires the host/build details | 94 | # podman now builds go-md2man and requires the host/build details |
| 95 | export NATIVE_GOOS=${BUILD_GOOS} | 95 | export NATIVE_GOOS=${BUILD_GOOS} |
diff --git a/recipes-containers/runc/runc.inc b/recipes-containers/runc/runc.inc index b834ab14..b7e9d72e 100644 --- a/recipes-containers/runc/runc.inc +++ b/recipes-containers/runc/runc.inc | |||
| @@ -58,8 +58,8 @@ do_compile() { | |||
| 58 | # Pass the needed cflags/ldflags so that cgo | 58 | # Pass the needed cflags/ldflags so that cgo |
| 59 | # can find the needed headers files and libraries | 59 | # can find the needed headers files and libraries |
| 60 | export CGO_ENABLED="1" | 60 | export CGO_ENABLED="1" |
| 61 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 61 | export CGO_CFLAGS="${CFLAGS}" |
| 62 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | 62 | export CGO_LDFLAGS="${LDFLAGS}" |
| 63 | export GO=${GO} | 63 | export GO=${GO} |
| 64 | 64 | ||
| 65 | export CFLAGS="" | 65 | export CFLAGS="" |
