Skip to content
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

add loongarch64 support for archutil #4392

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:

archutil-arm64:
runs-on: ubuntu-22.04
# TODO: enable when binutils-loongarch64-linux-gnu pkg is available for aarch64 arch
# https://github.com/moby/buildkit/pull/4392#issuecomment-1938223235
if: false
yzewei marked this conversation as resolved.
Show resolved Hide resolved
steps:
-
name: Checkout
Expand Down
11 changes: 9 additions & 2 deletions hack/dockerfiles/archutil.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ RUN apt-get update && apt-get --no-install-recommends install -y git binutils \
binutils-s390x-linux-gnu \
binutils-powerpc64le-linux-gnu \
binutils-mips64el-linux-gnuabi64 \
binutils-mips64-linux-gnuabi64
binutils-mips64-linux-gnuabi64 \
binutils-loongarch64-linux-gnu
WORKDIR /src

FROM base AS exit-amd64
Expand Down Expand Up @@ -58,6 +59,10 @@ FROM base AS exit-mips64
COPY util/archutil/fixtures/exit.mips64.s .
RUN mips64-linux-gnuabi64-as --noexecstack -o exit.o exit.mips64.s && mips64-linux-gnuabi64-ld -o exit -s exit.o && mips64-linux-gnuabi64-strip --strip-unneeded exit

FROM base AS exit-loong64
COPY util/archutil/fixtures/exit.loongarch64.s .
RUN loongarch64-linux-gnu-as --noexecstack -o exit.o exit.loongarch64.s && loongarch64-linux-gnu-ld -o exit -s exit.o && loongarch64-linux-gnu-strip --strip-unneeded exit

FROM scratch AS exits
COPY --from=exit-amd64 /src/exit amd64
COPY --from=exit-386 /src/exit 386
Expand All @@ -69,6 +74,7 @@ COPY --from=exit-ppc64 /src/exit ppc64
COPY --from=exit-ppc64le /src/exit ppc64le
COPY --from=exit-mips64le /src/exit mips64le
COPY --from=exit-mips64 /src/exit mips64
COPY --from=exit-loong64 /src/exit loong64

FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS generate
WORKDIR /go/src/github.com/moby/buildkit
Expand All @@ -86,7 +92,8 @@ RUN --mount=type=bind,target=.,rw \
bin/archutil/ppc64 \
bin/archutil/ppc64le \
bin/archutil/mips64le \
bin/archutil/mips64
bin/archutil/mips64 \
bin/archutil/loong64
tree -nh bin/archutil
cp bin/archutil/*_binary.go /out
EOT
Expand Down
10 changes: 10 additions & 0 deletions util/archutil/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func SupportedPlatforms(noCache bool) []ocispecs.Platform {
arr = append(arr, linux(p))
}
}
if p := "loong64"; def.Architecture != p {
if _, err := loong64Supported(); err == nil {
arr = append(arr, linux(p))
}
}
if p := "arm"; def.Architecture != p {
if _, err := armSupported(); err == nil {
p := linux("arm")
Expand Down Expand Up @@ -144,6 +149,11 @@ func WarnIfUnsupported(pfs []ocispecs.Platform) {
printPlatformWarning(p, err)
}
}
if p.Architecture == "loong64" {
if _, err := loong64Supported(); err != nil {
printPlatformWarning(p, err)
}
}
if p.Architecture == "arm" {
if _, err := armSupported(); err != nil {
printPlatformWarning(p, err)
Expand Down
6 changes: 6 additions & 0 deletions util/archutil/fixtures/exit.loongarch64.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.global _start
.text
_start:
li.w $a0,0
li.w $a7,93
syscall 0
9 changes: 9 additions & 0 deletions util/archutil/loong64_binary.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !loong64
// +build !loong64

package archutil

// This file is generated by running "make archutil".
// Do not edit manually.

const Binaryloong64 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x06\x08\x6f\x03\x03\x83\x02\x88\x76\x80\x8a\x5f\x80\xd2\xce\x60\x31\x0b\x06\x26\x06\x07\x06\x66\x06\x26\x06\x90\x1a\x56\x06\x14\xa0\xc0\x88\x44\xef\x81\x0a\xc2\x68\x98\x81\x81\x4f\x4b\x52\xd8\x18\x88\x07\x02\x50\x9a\x85\x41\x94\x81\xbb\xa4\x91\x99\x81\x41\x9b\x81\x41\xaf\x38\xa3\xb8\xa4\xa8\x24\x31\x89\x41\xaf\x24\xb5\xa2\x84\x81\x0a\x80\x9b\x81\x01\xec\x27\x98\xdb\x60\xe1\xb0\x01\xca\xe7\x41\x53\xcf\x88\x85\xcf\x8c\xc5\x5c\x98\xff\x05\x09\xe8\x07\x04\x00\x00\xff\xff\x5f\xc5\x9b\x9d\x90\x01\x00\x00"
8 changes: 8 additions & 0 deletions util/archutil/loong64_check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build !loong64
// +build !loong64

package archutil

func loong64Supported() (string, error) {
return check("loong64", Binaryloong64)
}
7 changes: 7 additions & 0 deletions util/archutil/loong64_check_loong64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build loong64

package archutil

func loong64Supported() (string, error) {
return "", nil
}