Skip to content

Commit

Permalink
Merge pull request #162 from gythialy/hotfix/issue-104
Browse files Browse the repository at this point in the history
feat: install the compiler rt libraries and support building images on M1 mac
  • Loading branch information
gythialy authored Sep 29, 2022
2 parents 4d12b28 + d3310fd commit 741da00
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ LABEL org.opencontainers.image.source https://github.com/gythialy/golang-cross
COPY entrypoint.sh /

# install cosign
COPY --from=gcr.io/projectsigstore/cosign:v1.11.1@sha256:f9fd5a287a67f4b955d08062a966df10f9a600b6b8583fd367bce3f1f000a429 /ko-app/cosign /usr/local/bin/cosign
COPY --from=gcr.io/projectsigstore/cosign:v1.21.1@sha256:ac8e08a2141e093f4fd7d1d0b05448804eb3771b66574b13ad73e31b460af64d /ko-app/cosign /usr/local/bin/cosign
# install syft
COPY --from=docker.io/anchore/syft:v0.55.0@sha256:42ede68d8a8762e42715692221a212cba262ce3a252ed962abf3d44ce3e68a52 /syft /usr/local/bin/syft
COPY --from=docker.io/anchore/syft:v0.57.0@sha256:00afd169a9060f099cf3dc6064b610b0f34f8fa57160bff42712415e81621ed4 /syft /usr/local/bin/syft

ARG GO_VERSION=1.19.1
ARG GOLANG_DIST_SHA=acc512fbab4f716a8f97a8b3fbaa9ddd39606a28be6c2515ef7c6c6311acffde
Expand All @@ -29,14 +29,14 @@ RUN \
wget https://github.com/goreleaser/goreleaser/releases/download/v$GORELEASER_VERSION/checksums.txt.pem && \
GORELEASER_DOWNLOAD_FILE=goreleaser_Linux_x86_64.tar.gz && \
GORELEASER_DOWNLOAD_URL=https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/${GORELEASER_DOWNLOAD_FILE} && \
COSIGN_EXPERIMENTAL=1 cosign verify-blob --cert checksums.txt.pem \
--signature https://github.com/goreleaser/goreleaser/releases/download/v$GORELEASER_VERSION/checksums.txt.sig \
https://github.com/goreleaser/goreleaser/releases/download/v$GORELEASER_VERSION/checksums.txt && \
# COSIGN_EXPERIMENTAL=1 cosign verify-blob --cert checksums.txt.pem \
# --signature https://github.com/goreleaser/goreleaser/releases/download/v$GORELEASER_VERSION/checksums.txt.sig \
# https://github.com/goreleaser/goreleaser/releases/download/v$GORELEASER_VERSION/checksums.txt && \
wget ${GORELEASER_DOWNLOAD_URL} && \
echo "$GORELEASER_SHA $GORELEASER_DOWNLOAD_FILE" | sha256sum -c - || exit 1 && \
tar -xzf $GORELEASER_DOWNLOAD_FILE -C /usr/bin/ goreleaser && \
rm $GORELEASER_DOWNLOAD_FILE && \
rm checksums.txt.pem && \
# rm checksums.txt.pem && \
goreleaser -v

# install ko
Expand Down
30 changes: 15 additions & 15 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ ARG GO_VERSION=1.19.1
ARG OSX_VERSION_MIN=10.12
ARG OSX_CROSS_COMMIT=50e86ebca7d14372febd0af8cd098705049161b9

FROM golang:${GO_VERSION}-bullseye AS base
FROM golang:${GO_VERSION:-1.19.1}-bullseye AS base

ARG APT_MIRROR
RUN sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \
&& sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list
ENV OSX_CROSS_PATH=/osxcross

FROM ghcr.io/gythialy/golang-cross/osx-sdk:macos-12.3 AS osx-sdk
ENV OSX_CROSS_PATH=/osxcross
FROM base AS osx-cross-base
ARG DEBIAN_FRONTEND=noninteractive
# Install deps
RUN set -x; echo "Starting image build for Debian " \
Expand Down Expand Up @@ -71,20 +69,22 @@ RUN set -x; echo "Starting image build for Debian " \
# FIXME: install gcc-multilib
# FIXME: add mips and powerpc architectures

FROM osx-cross-base AS osx-cross
ARG OSX_CROSS_COMMIT
WORKDIR "${OSX_CROSS_PATH}"
# install osxcross:
RUN git clone https://github.com/tpoechtrager/osxcross.git . \
&& git checkout -q "${OSX_CROSS_COMMIT}" \
&& rm -rf ./.git
COPY --from=osx-sdk "${OSX_CROSS_PATH}/." "${OSX_CROSS_PATH}/"
ARG OSX_VERSION_MIN
RUN UNATTENDED=yes OSX_VERSION_MIN=${OSX_VERSION_MIN} ./build.sh
&& git checkout -q "${OSX_CROSS_COMMIT:-50e86ebca7d14372febd0af8cd098705049161b9}"

FROM osx-cross-base AS final
LABEL maintainer="Goren G<[email protected]>"
ARG DEBIAN_FRONTEND=noninteractive
# install osx sdk
COPY --from=ghcr.io/gythialy/golang-cross/osx-sdk:macos-12.3@sha256:6fc96c49165b28ed79e4228bcf59a001232a8a8e6c1d942a592dfe6e33352640 "${OSX_CROSS_PATH}/." "${OSX_CROSS_PATH}/"

# https://github.com/tpoechtrager/osxcross/issues/313
COPY patch/osxcross-08-52-08.patch "${OSX_CROSS_PATH}/"
RUN patch -p1 < osxcross-08-52-08.patch

RUN \
UNATTENDED=yes OSX_VERSION_MIN=${OSX_VERSION_MIN:-10.12} ./build.sh \
&& ./build_compiler_rt.sh \
&& rm -rf *~ build *.tar.xz \
&& rm -rf ./.git

COPY --from=osx-cross "${OSX_CROSS_PATH}/." "${OSX_CROSS_PATH}/"
ENV PATH=${OSX_CROSS_PATH}/target/bin:$PATH
15 changes: 15 additions & 0 deletions patch/osxcross-08-52-08.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/wrapper/target.cpp b/wrapper/target.cpp
index 82bf65c404efed9b88da0fe3e74b5205df0b8534..acc6225ae968086c757e445742e5569ed33f4a47 100644
--- a/wrapper/target.cpp
+++ b/wrapper/target.cpp
@@ -743,6 +743,10 @@ bool Target::setup() {
fargs.push_back("-Qunused-arguments");
}

+ if ((SDKOSNum >= OSVersion(11, 1)) && (stdlib == StdLib::libcxx)) {
+ fargs.push_back("-lc++");
+ }
+
if (stdlib == StdLib::libstdcxx && usegcclibs && targetarch.size() < 2 &&
!isGCH()) {
// Use libs from './build_gcc' installation

0 comments on commit 741da00

Please sign in to comment.