diff options
author | Martin Jansa <Martin.Jansa@gmail.com> | 2023-02-17 19:30:10 +0100 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2023-02-21 10:11:32 -0500 |
commit | 9a78db8a9174f811baae36a82370f2827c0bc889 (patch) | |
tree | 2c22f51aa01e5d84c2be5ac93028f466fb3352ba | |
parent | e43d530e992c2b4880262d86dda9390c1b2649ee (diff) | |
download | meta-virtualization-9a78db8a9174f811baae36a82370f2827c0bc889.tar.gz |
docker-*: prevent -march being exported in arm builds
* don't export CGO_CFLAGS/CGO_CXXFLAGS like the previous version
didn't before:
https://git.yoctoproject.org/meta-virtualization/commit/?id=aceed7bf95cc8a42c8f470d8edf3c6f03d49da00
* both docker-moby and docker-ce have the same issue as shown with
qemuarm build:
docker-moby: http://errors.yoctoproject.org/Errors/Details/690021/
docker-ce: http://errors.yoctoproject.org/Errors/Details/690020/
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r-- | recipes-containers/docker/docker-ce_git.bb | 2 | ||||
-rw-r--r-- | recipes-containers/docker/docker-moby_git.bb | 2 | ||||
-rw-r--r-- | recipes-containers/docker/files/0001-dynbinary-use-go-cross-compiler.patch | 104 |
3 files changed, 97 insertions, 11 deletions
diff --git a/recipes-containers/docker/docker-ce_git.bb b/recipes-containers/docker/docker-ce_git.bb index 0f43da69..b9888d27 100644 --- a/recipes-containers/docker/docker-ce_git.bb +++ b/recipes-containers/docker/docker-ce_git.bb | |||
@@ -41,7 +41,7 @@ SRC_URI = "\ | |||
41 | git://github.com/docker/cli;branch=23.0;name=cli;destsuffix=git/cli;protocol=https \ | 41 | git://github.com/docker/cli;branch=23.0;name=cli;destsuffix=git/cli;protocol=https \ |
42 | file://0001-libnetwork-use-GO-instead-of-go.patch \ | 42 | file://0001-libnetwork-use-GO-instead-of-go.patch \ |
43 | file://docker.init \ | 43 | file://docker.init \ |
44 | file://0001-dynbinary-use-go-cross-compiler.patch \ | 44 | file://0001-dynbinary-use-go-cross-compiler.patch;patchdir=src/import \ |
45 | file://0001-cli-use-external-GO111MODULE-and-cross-compiler.patch \ | 45 | file://0001-cli-use-external-GO111MODULE-and-cross-compiler.patch \ |
46 | " | 46 | " |
47 | 47 | ||
diff --git a/recipes-containers/docker/docker-moby_git.bb b/recipes-containers/docker/docker-moby_git.bb index 19f4763b..17cd3166 100644 --- a/recipes-containers/docker/docker-moby_git.bb +++ b/recipes-containers/docker/docker-moby_git.bb | |||
@@ -45,7 +45,7 @@ SRC_URI = "\ | |||
45 | file://docker.init \ | 45 | file://docker.init \ |
46 | file://0001-libnetwork-use-GO-instead-of-go.patch \ | 46 | file://0001-libnetwork-use-GO-instead-of-go.patch \ |
47 | file://0001-cli-use-external-GO111MODULE-and-cross-compiler.patch \ | 47 | file://0001-cli-use-external-GO111MODULE-and-cross-compiler.patch \ |
48 | file://0001-dynbinary-use-go-cross-compiler.patch \ | 48 | file://0001-dynbinary-use-go-cross-compiler.patch;patchdir=src/import \ |
49 | " | 49 | " |
50 | 50 | ||
51 | DOCKER_COMMIT = "${SRCREV_moby}" | 51 | DOCKER_COMMIT = "${SRCREV_moby}" |
diff --git a/recipes-containers/docker/files/0001-dynbinary-use-go-cross-compiler.patch b/recipes-containers/docker/files/0001-dynbinary-use-go-cross-compiler.patch index c10e69d3..ea8f4c5e 100644 --- a/recipes-containers/docker/files/0001-dynbinary-use-go-cross-compiler.patch +++ b/recipes-containers/docker/files/0001-dynbinary-use-go-cross-compiler.patch | |||
@@ -1,20 +1,106 @@ | |||
1 | From bbf600cc4d46c3f7ec0c1b486790a2402d41f550 Mon Sep 17 00:00:00 2001 | 1 | From 3ce6089417b8c6c4e8279e6ef60213436ebf8793 Mon Sep 17 00:00:00 2001 |
2 | From: Bruce Ashfield <bruce.ashfield@gmail.com> | 2 | From: Bruce Ashfield <bruce.ashfield@gmail.com> |
3 | Date: Tue, 30 Jun 2020 22:23:33 -0400 | 3 | Date: Tue, 30 Jun 2020 22:23:33 -0400 |
4 | Subject: [PATCH] dynbinary: use go cross compiler | 4 | Subject: [PATCH] dynbinary: use go cross compiler |
5 | 5 | ||
6 | MJ: use ${GO} also in "go env" calls, because native go: | ||
7 | $ go env GOARM | ||
8 | 5 | ||
9 | while go cross compiler for my target: | ||
10 | $ ${GO} env GOARM | ||
11 | 7 | ||
12 | this can lead to: | ||
13 | error: switch '-mcpu=cortex-a9' conflicts with switch '-march=armv5t' [-Werror] | ||
14 | |||
15 | but even after fixing it to use "better" -march it still doesn't match with -mcpu | ||
16 | set in our GOBUILDFLAGS, causing e.g.: | ||
17 | error: switch '-mcpu=cortex-a9' conflicts with switch '-march=armv7-a+simd' [-Werror] | ||
18 | |||
19 | so drop CGO_CFLAGS/CGO_CXXFLAGS as in OE builds we don't need them | ||
20 | as long as ${GO} and GOBUILDFLAGS are respected | ||
21 | |||
22 | it was added in: | ||
23 | https://github.com/moby/moby/commit/12558c8d6ea9f388b54eb94ba6b9eb4a9fc5c9f2 | ||
24 | |||
25 | and it wasn't an issue before: | ||
26 | https://github.com/moby/moby/commit/8c12a6648b368cc2acaea0339d6c57c920ed265c | ||
27 | |||
28 | because it was using 'case "${GOARM}" in' and ${GOARM} was empty in our builds | ||
29 | |||
6 | Upstream-Status: Inappropriate [embedded specific] | 30 | Upstream-Status: Inappropriate [embedded specific] |
7 | 31 | ||
32 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
8 | Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> | 33 | Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> |
9 | --- | 34 | --- |
10 | hack/make/.binary | 2 +- | 35 | hack/make/.binary | 37 ++++++++----------------------------- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 36 | 1 file changed, 8 insertions(+), 29 deletions(-) |
12 | 37 | ||
13 | Index: git/src/import/hack/make/.binary | 38 | diff --git a/hack/make/.binary b/hack/make/.binary |
14 | =================================================================== | 39 | index 39c00cd50c..de32ad1cc7 100644 |
15 | --- git.orig/src/import/hack/make/.binary | 40 | --- a/hack/make/.binary |
16 | +++ git/src/import/hack/make/.binary | 41 | +++ b/hack/make/.binary |
17 | @@ -66,7 +66,7 @@ | 42 | @@ -3,7 +3,7 @@ set -e |
43 | |||
44 | # a helper to provide ".exe" when it's appropriate | ||
45 | binary_extension() { | ||
46 | - if [ "$(go env GOOS)" = 'windows' ]; then | ||
47 | + if [ "$(${GO} env GOOS)" = 'windows' ]; then | ||
48 | echo -n '.exe' | ||
49 | fi | ||
50 | } | ||
51 | @@ -16,33 +16,12 @@ source "${MAKEDIR}/.go-autogen" | ||
52 | ( | ||
53 | export GOGC=${DOCKER_BUILD_GOGC:-1000} | ||
54 | |||
55 | - if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then | ||
56 | - # must be cross-compiling! | ||
57 | - if [ "$(go env GOOS)/$(go env GOARCH)" = "linux/arm" ]; then | ||
58 | - # specify name of the target ARM architecture | ||
59 | - case "$(go env GOARM)" in | ||
60 | - 5) | ||
61 | - export CGO_CFLAGS="-march=armv5t" | ||
62 | - export CGO_CXXFLAGS="-march=armv5t" | ||
63 | - ;; | ||
64 | - 6) | ||
65 | - export CGO_CFLAGS="-march=armv6" | ||
66 | - export CGO_CXXFLAGS="-march=armv6" | ||
67 | - ;; | ||
68 | - 7) | ||
69 | - export CGO_CFLAGS="-march=armv7-a" | ||
70 | - export CGO_CXXFLAGS="-march=armv7-a" | ||
71 | - ;; | ||
72 | - esac | ||
73 | - fi | ||
74 | - fi | ||
75 | - | ||
76 | # -buildmode=pie is not supported on Windows arm64 and Linux mips*, ppc64be | ||
77 | # https://github.com/golang/go/blob/go1.19.4/src/cmd/internal/sys/supported.go#L125-L132 | ||
78 | if ! [ "$DOCKER_STATIC" = "1" ]; then | ||
79 | # -buildmode=pie not supported when -race is enabled | ||
80 | if [[ " $BUILDFLAGS " != *" -race "* ]]; then | ||
81 | - case "$(go env GOOS)/$(go env GOARCH)" in | ||
82 | + case "$(${GO} env GOOS)/$(${GO} env GOARCH)" in | ||
83 | windows/arm64 | linux/mips* | linux/ppc64) ;; | ||
84 | *) | ||
85 | BUILDFLAGS+=("-buildmode=pie") | ||
86 | @@ -54,11 +33,11 @@ source "${MAKEDIR}/.go-autogen" | ||
87 | # only necessary for non-sandboxed invocation where TARGETPLATFORM is empty | ||
88 | PLATFORM_NAME=$TARGETPLATFORM | ||
89 | if [ -z "$PLATFORM_NAME" ]; then | ||
90 | - PLATFORM_NAME="$(go env GOOS)/$(go env GOARCH)" | ||
91 | - if [ -n "$(go env GOARM)" ]; then | ||
92 | - PLATFORM_NAME+="/v$(go env GOARM)" | ||
93 | - elif [ -n "$(go env GOAMD64)" ] && [ "$(go env GOAMD64)" != "v1" ]; then | ||
94 | - PLATFORM_NAME+="/$(go env GOAMD64)" | ||
95 | + PLATFORM_NAME="$(${GO} env GOOS)/$(${GO} env GOARCH)" | ||
96 | + if [ -n "$(${GO} env GOARM)" ]; then | ||
97 | + PLATFORM_NAME+="/v$(${GO} env GOARM)" | ||
98 | + elif [ -n "$(${GO} env GOAMD64)" ] && [ "$(${GO} env GOAMD64)" != "v1" ]; then | ||
99 | + PLATFORM_NAME+="/$(${GO} env GOAMD64)" | ||
100 | fi | ||
101 | fi | ||
102 | |||
103 | @@ -66,7 +45,7 @@ source "${MAKEDIR}/.go-autogen" | ||
18 | if [ -n "$DOCKER_DEBUG" ]; then | 104 | if [ -n "$DOCKER_DEBUG" ]; then |
19 | set -x | 105 | set -x |
20 | fi | 106 | fi |