Skip to content

Commit

Permalink
fix: musl crash
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Jul 12, 2024
1 parent 6d5cb37 commit 84eff50
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
!build-static.sh
!app.tar
!app_checksum.txt
!*.patch
13 changes: 13 additions & 0 deletions 0001-fix-musl-crash.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/runtime/cgo/gcc_stack_unix.c b/src/runtime/cgo/gcc_stack_unix.c
index 884281dc15..d80e017b89 100644
--- a/src/runtime/cgo/gcc_stack_unix.c
+++ b/src/runtime/cgo/gcc_stack_unix.c
@@ -21,7 +21,7 @@ x_cgo_getstackbound(uintptr bounds[2])
// Needed before pthread_getattr_np, too, since before glibc 2.32
// it did not call pthread_attr_init in all cases (see #65625).
pthread_attr_init(&attr);
-#if defined(__GLIBC__) || (defined(__sun) && !defined(__illumos__))
+#if 1
// pthread_getattr_np is a GNU extension supported in glibc.
// Solaris is not glibc but does support pthread_getattr_np
// (and the fallback doesn't work...). Illumos does not.
8 changes: 3 additions & 5 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ RUN apk add --no-cache --virtual .build-deps \
WORKDIR /
RUN git clone https://go.googlesource.com/go goroot
WORKDIR /goroot
# Revert https://github.com/golang/go/commit/3560cf0afb3c29300a6c88ccd98256949ca7a6f6 to prevent the crash with musl
RUN git config --global user.email "build@example.com" && \
git config --global user.name "Build" && \
git checkout "$(go env GOVERSION)" && \
git revert 3560cf0afb3c29300a6c88ccd98256949ca7a6f6
COPY 0001-fix-musl-crash.patch .
RUN git checkout "$(go env GOVERSION)" && \
git apply 0001-fix-musl-crash.patch
WORKDIR /goroot/src
ENV GOHOSTARCH="$TARGETARCH"
RUN ./make.bash
Expand Down
8 changes: 3 additions & 5 deletions static-builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ RUN apk update; \
WORKDIR /
RUN git clone https://go.googlesource.com/go goroot
WORKDIR /goroot
# Revert https://github.com/golang/go/commit/3560cf0afb3c29300a6c88ccd98256949ca7a6f6 to prevent the crash with musl
RUN git config --global user.email "build@example.com" && \
git config --global user.name "Build" && \
git checkout "$(go env GOVERSION)" && \
git revert 3560cf0afb3c29300a6c88ccd98256949ca7a6f6
COPY 0001-fix-musl-crash.patch .
RUN git checkout "$(go env GOVERSION)" && \
git apply 0001-fix-musl-crash.patch
WORKDIR /goroot/src
ENV GOHOSTARCH="$TARGETARCH"
RUN ./make.bash
Expand Down

0 comments on commit 84eff50

Please sign in to comment.