-
Notifications
You must be signed in to change notification settings - Fork 512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix i386 "softfloat" bug #360
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Diff:$ diff -u --ignore-all-space Dockerfile-debian.template Dockerfile-alpine.template
--- Dockerfile-debian.template 2021-02-24 08:44:02.632372033 -0800
+++ Dockerfile-alpine.template 2021-02-24 08:34:24.736383847 -0800
@@ -1,71 +1,64 @@
-FROM buildpack-deps:{{ env.variant }}-scm
+FROM alpine:{{ env.variant | ltrimstr("alpine") }}
-# gcc for cgo
-RUN apt-get update && apt-get install -y --no-install-recommends \
- g++ \
- gcc \
- libc6-dev \
- make \
- pkg-config \
- && rm -rf /var/lib/apt/lists/*
+RUN apk add --no-cache \
+ ca-certificates
+
+# set up nsswitch.conf for Go's "netgo" implementation
+# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
+# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
+RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
ENV PATH /usr/local/go/bin:$PATH
ENV GOLANG_VERSION {{ .version }}
RUN set -eux; \
- \
- dpkgArch="$(dpkg --print-architecture)"; \
- url=; \
- case "${dpkgArch##*-}" in \
+ apk add --no-cache --virtual .build-deps \
+ bash \
+ gcc \
+ gnupg \
+ go \
+ musl-dev \
+ openssl \
+ ; \
+ apkArch="$(apk --print-arch)"; \
+ case "$apkArch" in \
{{
[
.arches | to_entries[]
| .key as $bashbrewArch
| (
{
- amd64: "amd64",
- arm32v5: "armel",
- arm32v7: "armhf",
- arm64v8: "arm64",
- i386: "i386",
- mips64le: "mips64el",
- ppc64le: "ppc64el",
+ amd64: "x86_64",
+ arm32v6: "armhf",
+ arm32v7: "armv7",
+ arm64v8: "aarch64",
+ i386: "x86",
+ ppc64le: "ppc64le",
s390x: "s390x",
} | .[$bashbrewArch] // ""
- ) as $dpkgArch
- | select($dpkgArch != "")
+ ) as $apkArch
+ | select($apkArch != "")
| .value
| (
-}}
- {{ $dpkgArch | @sh }}) \
-{{ if .url then ( -}}
- url={{ .url | @sh }}; \
- sha256={{ .sha256 | @sh }}; \
-{{ ) else ( -}}
+ {{ $apkArch | @sh }}) \
export {{ .env | to_entries | map(.key + "=" + (.value | @sh)) | join(" ") }}; \
-{{ ) end -}}
;; \
{{
)
] | add
-}}
- *) echo >&2 "error: unsupported architecture '$dpkgArch' (likely packaging update needed)"; exit 1 ;; \
+ *) echo >&2 "error: unsupported architecture '$apkArch' (likely packaging update needed)"; exit 1 ;; \
esac; \
- build=; \
- if [ -z "$url" ]; then \
+ \
# https://github.com/golang/go/issues/38536#issuecomment-616897960
- build=1; \
url={{ .arches.src.url | @sh }}; \
sha256={{ .arches.src.sha256 | @sh }}; \
- echo >&2; \
- echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; \
- echo >&2; \
- fi; \
\
- wget -O go.tgz.asc "$url.asc" --progress=dot:giga; \
- wget -O go.tgz "$url" --progress=dot:giga; \
- echo "$sha256 *go.tgz" | sha256sum --strict --check -; \
+ wget -O go.tgz.asc "$url.asc"; \
+ wget -O go.tgz "$url"; \
+ echo "$sha256 *go.tgz" | sha256sum -c -; \
\
# https://github.com/golang/go/issues/14739#issuecomment-324767697
export GNUPGHOME="$(mktemp -d)"; \
@@ -78,22 +71,24 @@
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
\
- if [ -n "$build" ]; then \
- savedAptMark="$(apt-mark showmanual)"; \
- apt-get update; \
- apt-get install -y --no-install-recommends golang-go; \
- \
( \
cd /usr/local/go/src; \
# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully
export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
+ if [ "${GO386:-}" = 'softfloat' ]; then \
+# https://github.com/docker-library/golang/issues/359 -> https://github.com/golang/go/issues/44500
+# (once our Alpine base has Go 1.16, we can remove this hack)
+ GO386= ./bootstrap.bash; \
+ export GOROOT_BOOTSTRAP="/usr/local/go-$GOOS-$GOARCH-bootstrap"; \
+ "$GOROOT_BOOTSTRAP/bin/go" version; \
+ fi; \
./make.bash; \
+ if [ "${GO386:-}" = 'softfloat' ]; then \
+ rm -rf "$GOROOT_BOOTSTRAP"; \
+ fi; \
); \
\
- apt-mark auto '.*' > /dev/null; \
- apt-mark manual $savedAptMark > /dev/null; \
- apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
- rm -rf /var/lib/apt/lists/*; \
+ apk del --no-network .build-deps; \
\
# pre-compile the standard library, just like the official binary release tarballs do
go install std; \
@@ -109,7 +104,6 @@
/usr/local/go/pkg/tool/*/go_bootstrap \
/usr/local/go/src/cmd/dist/dist \
; \
- fi; \
\
go version
|
See https://golang.org/issues/44500 for details (tldr, Go 1.16 changes "GO386" from "387" to "softfloat" but the bootstrap compiler isn't 1.16 yet so balks at the changed value). This also makes our "compilation" much more explicit by explicitly noting the "env" needed to build each bashbrew architecture we support and embedding those directly. (I've also added "i386" to GitHub Actions, which will double our matrix size, but will hopefully help us catch issues like this in the future.)
tianon
force-pushed
the
i386-softfloat
branch
from
February 24, 2021 16:44
4364aa1
to
01c68e7
Compare
yosifkit
approved these changes
Feb 24, 2021
docker-library-bot
added a commit
to docker-library-bot/official-images
that referenced
this pull request
Feb 25, 2021
Changes: - docker-library/golang@a9533c8: Merge pull request docker-library/golang#360 from infosiftr/i386-softfloat - docker-library/golang@01c68e7: Fix i386 "softfloat" bug
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See golang/go#44500 for details (tldr, Go 1.16 changes "GO386" from "387" to "softfloat" but the bootstrap compiler isn't 1.16 yet so balks at the changed value).
This also makes our "compilation" much more explicit by explicitly noting the "env" needed to build each bashbrew architecture we support and embedding those directly.
(I've also added "i386" to GitHub Actions, which will double our matrix size, but will hopefully help us catch issues like this in the future.)
Fixes #359