diff --git a/docker-bake.hcl b/docker-bake.hcl index c71cc4f..b4e23db 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -175,20 +175,6 @@ target "_ld-base" { } } -target "ld64-tgz" { - inherits = ["_ld-base"] - target = "ld64-tgz" - output = ["./ld64-tgz"] - platforms = [ - "linux/386", - "linux/amd64", - "linux/arm64", - "linux/arm/v6", - "linux/arm/v7" - ] - cache-to = ["type=inline"] -} - variable "BINUTILS_VERSION_ONLY" { default = "" } @@ -312,6 +298,64 @@ target "binutils-windows-386-alpine" { cache-from = [join("", ["type=registry,ref=", binutilsTag(XX_REPO, BINUTILS_VERSION, BINUTILS_VERSION_ONLY, "windows-386")[0]])] } +group "ld64-static-tgz" { + targets = [for v in ["linux-386", "linux-amd64", "linux-arm64", "linux-armv6", "linux-armv7"]: "ld64-${v}-tgz"] +} + +target "ld64-tgz-base" { + inherits = ["_ld-base"] + target = "ld64-static-tgz" + platforms = [ + "linux/386", + "linux/amd64", + "linux/arm64", + "linux/arm/v6", + "linux/arm/v7" + ] + cache-to = ["type=inline"] + output = ["./ld64-tgz"] +} + +target "ld64-linux-amd64-tgz" { + inherits = ["ld64-tgz-base"] + args = { + LD_TARGET = "linux-amd64" + } + cache-from = [join("", ["type=registry,ref=", binutilsTag(XX_REPO, BINUTILS_VERSION, "1", "linux-amd64")[0]])] +} + +target "ld64-linux-arm64-tgz" { + inherits = ["ld64-tgz-base"] + args = { + LD_TARGET = "linux-arm64" + } + cache-from = [join("", ["type=registry,ref=", binutilsTag(XX_REPO, BINUTILS_VERSION, "1", "linux-arm64")[0]])] +} + +target "ld64-linux-armv7-tgz" { + inherits = ["ld64-tgz-base"] + args = { + LD_TARGET = "linux-armv7" + } + cache-from = [join("", ["type=registry,ref=", binutilsTag(XX_REPO, BINUTILS_VERSION, "1", "linux-armv7")[0]])] +} + +target "ld64-linux-armv6-tgz" { + inherits = ["ld64-tgz-base"] + args = { + LD_TARGET = "linux-armv6" + } + cache-from = [join("", ["type=registry,ref=", binutilsTag(XX_REPO, BINUTILS_VERSION, "1", "linux-armv6")[0]])] +} + +target "ld64-linux-386-tgz" { + inherits = ["ld64-tgz-base"] + args = { + LD_TARGET = "linux-386" + } + cache-from = [join("", ["type=registry,ref=", binutilsTag(XX_REPO, BINUTILS_VERSION, "1", "linux-arm64")[0]])] +} + group "ld-static-tgz" { targets = [for v in ["linux-arm64", "linux-amd64", "linux-riscv64", "linux-s390x", "linux-armv6", "linux-armv7", "linux-ppc64le", "linux-386", "windows-amd64", "windows-386"]: "ld-${v}-tgz"] } diff --git a/src/ld/Dockerfile b/src/ld/Dockerfile index 1b68c43..fcd4466 100644 --- a/src/ld/Dockerfile +++ b/src/ld/Dockerfile @@ -86,6 +86,19 @@ RUN --mount=from=libtapi-static,source=/opt/libtapi,target=/opt/libtapi \ make -j $(nproc) -C ld64 && \ xx-verify --static ld64/src/ld/ld +FROM scratch AS ld64-signed-static +COPY --from=ld64-static / / +COPY --from=sigtool / / +COPY ld64.signed / + +FROM --platform=$BUILDPLATFORM alpine AS ld64-tgz-build +WORKDIR /work +ARG TARGETOS TARGETARCH TARGETVARIANT +RUN --mount=from=ld64-signed-static \ + mkdir /out-tgz && tar cvzf /out-tgz/ld64-signed-$TARGETOS-$TARGETARCH$TARGETVARIANT.tar.gz * + +FROM scratch AS ld64-static-tgz +COPY --from=ld64-tgz-build /out-tgz/ / FROM scratch AS ld64-static COPY --from=ld64-static-base /work/cctools-port/cctools/ld64/src/ld/ld /ld64 @@ -136,20 +149,6 @@ FROM scratch AS sigtool COPY --from=codesign-static / / COPY --from=sigtool-base /work/sigtool/build/gensig /sigtool-gensig -FROM scratch AS ld64-signed-static -COPY --from=ld64-static / / -COPY --from=sigtool / / -COPY ld64.signed / - -FROM --platform=$BUILDPLATFORM alpine AS ld64-tgz-build -WORKDIR /work -ARG TARGETOS TARGETARCH TARGETVARIANT -RUN --mount=from=ld64-signed-static \ - mkdir /out-tgz && tar cvzf /out-tgz/ld64-signed-$TARGETOS-$TARGETARCH$TARGETVARIANT.tar.gz * - -FROM scratch AS ld64-tgz -COPY --from=ld64-tgz-build /out-tgz/ / - FROM --platform=$BUILDPLATFORM alpine AS binutils-base0 RUN apk add --no-cache git clang lld zlib-dev gcc patch make musl-dev WORKDIR /work