Compare commits

...

9 Commits

Author SHA1 Message Date
CrazyMax
3945eb11d8 Merge pull request #229 from crazy-max/update-github-builder
ci: update docker github builder to latest
2025-12-19 09:04:31 +01:00
CrazyMax
f169abbe02 ci: update docker github builder to latest
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-12-18 17:05:15 +01:00
Tõnis Tiigi
a5592eab7a Merge pull request #214 from crazy-max/zig
xx-go: zig support
2025-12-03 23:23:51 -08:00
CrazyMax
9fb3908307 xx-go: zig support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-12-03 11:54:48 +01:00
CrazyMax
f074957406 Merge pull request #217 from crazy-max/ci-docker-github-builder
ci: use docker github builder to build the image
2025-12-02 10:16:37 +01:00
CrazyMax
c5d6b48146 ci: use docker github builder to build the image
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-12-01 12:13:57 +01:00
Tõnis Tiigi
64748543e9 Merge pull request #188 from crazy-max/loong64
loong64 arch support
2025-10-12 21:06:13 -07:00
CrazyMax
3f4719d83c loong64 arch support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-10-07 10:27:20 +02:00
CrazyMax
9fa96b5606 test: update rust to 1.81.0 for loongarch64 support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-10-07 10:27:20 +02:00
18 changed files with 473 additions and 56 deletions

View File

@@ -4,6 +4,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
on:
workflow_dispatch:
push:
@@ -134,42 +138,28 @@ jobs:
allow-failure: ${{ matrix.allow-failure }}
build:
runs-on: ubuntu-latest
uses: docker/github-builder-experimental/.github/workflows/bake.yml@af87571fd3347a8a760e6053efba57325c00b74b
permissions:
contents: read # same as global permission
id-token: write # for signing attestation(s) with GitHub OIDC Token
needs:
- validate
- test
steps:
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
with:
runner: amd64
target: xx-all
output: image
push: ${{ github.event_name != 'pull_request' }}
set-meta-labels: true
meta-images: |
tonistiigi/xx
meta-tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
meta-bake-target: meta-helper
secrets:
registry-auths: |
- registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
tonistiigi/xx
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
bake-target: meta-helper
-
name: Build
uses: docker/bake-action@v6
with:
files: |
./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file }}
targets: xx-all
push: ${{ github.event_name != 'pull_request' }}

View File

@@ -342,6 +342,28 @@ RUN go build -o hello hello.go && \
xx-verify hello
```
`xx-go` can also drive [Zig](https://ziglang.org/) as the underlying C
toolchain for CGo builds. This can be useful when you want a single
cross-compiling toolchain that works across multiple platforms, or when you
already rely on Zig in your build pipeline.
Zig support is **opt-in** and is enabled by setting the `XX_GO_PREFER_C_COMPILER`
environment variable to `zig`. When this variable is set and the `zig` binary
is available in `PATH`, `xx-go` will configure CGo to use Zig as the C compiler
for the current target.
```dockerfile
FROM --platform=$BUILDPLATFORM golang:alpine
RUN apk add zig
# ...
ARG TARGETPLATFORM
RUN xx-apk add musl-dev
ENV CGO_ENABLED=1
ENV XX_GO_PREFER_C_COMPILER=zig
RUN xx-go build -o hello ./hello.go && \
xx-verify hello
```
## Rust
Building Rust can be achieved with the `xx-cargo` wrapper that automatically

View File

@@ -136,7 +136,8 @@ target "_all-platforms" {
"linux/mips64le",
"linux/ppc64le",
"linux/s390x",
"linux/riscv64"
"linux/riscv64",
"linux/loong64"
]
}
@@ -171,6 +172,7 @@ target "sdk-extras" {
"linux/ppc64le",
"linux/riscv64",
"linux/s390x",
"linux/loong64",
"windows/386",
"windows/amd64",
"windows/arm",

View File

@@ -47,7 +47,8 @@ testHelloCargoRustup() {
@test "install-rustup" {
add clang lld curl ca-certificates
assert_success
run sh -c "curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.69.0 --no-modify-path --profile=minimal"
# https://releases.rs/docs/1.81.0/ adds support for loongarch64 on musl: https://doc.rust-lang.org/rustc/platform-support/loongarch-linux.html#building-rust-programs
run sh -c "curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.81.0 --no-modify-path --profile=minimal"
assert_success
export "PATH=/root/.cargo/bin:$PATH"
run rustup --version 2>/dev/null
@@ -75,6 +76,14 @@ testHelloCargoRustup() {
testHelloCargoRustup
}
@test "loong64-hellocargo-rustup" {
if ! supportLoong64Go; then
skip "LOONGARCH64 not supported"
fi
export TARGETARCH=loong64
testHelloCargoRustup
}
@test "ppc64le-hellocargo-rustup" {
if [ -f /etc/alpine-release ]; then
skip "rust stdlib not yet available for powerpc64le-unknown-linux-musl"
@@ -129,6 +138,14 @@ testHelloCargoRustup() {
testHelloCargo
}
@test "loong64-hellocargo-rustpkg" {
if ! supportLoong64Go; then
skip "LOONGARCH64 not supported" # rust stdlib package not available
fi
export TARGETARCH=loong64
testHelloCargo
}
@test "ppc64le-hellocargo-rustpkg" {
export TARGETARCH=ppc64le
testHelloCargo

View File

@@ -259,6 +259,28 @@ testBuildHello() {
testHelloCLLD
}
@test "loong64-c-ld" {
if ! supportLoongArch; then
skip "LOONGARCH64 not supported"
fi
if [ -f /etc/alpine-release ]; then
# FIXME: loong64-c-lld issue on alpine < 3.21
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0x0): unknown relocation (102) against symbol
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0x3c): unknown relocation (102) against symbol
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0x64): unknown relocation (102) against symbol
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0xb4): unknown relocation (102) against symbol
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0xdc): unknown relocation (102) against symbol
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0x154): unknown relocation (102) against symbol
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0x198): unknown relocation (102) against symbol
alpineRelease=$(cat /etc/alpine-release)
if ! grep PRETTY_NAME /etc/os-release | cut -d '=' -f 2 | tr -d '"' | grep -q "edge$" || [ "$(semver compare "$alpineRelease" "3.21.0")" -lt 0 ]; then
skip
fi
fi
export TARGETARCH=loong64
testHelloCLLD
}
@test "386-c-lld" {
export TARGETARCH=386
testHelloCPPLLD
@@ -300,6 +322,24 @@ testBuildHello() {
testHelloCPPLLD # actually runs with ld
}
@test "loong64-c++-lld" {
if ! supportLoongArch; then
skip "LOONGARCH64 not supported"
fi
if [ -f /etc/alpine-release ]; then
# FIXME: loong64-c++-lld issue on alpine < 3.21
# ld.lld: error: unknown emulation: elf64loongarch
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0x0): unknown relocation (102) against symbol
# error: unknown target triple 'loongarch64-alpine-linux-musl', please use -triple or -arch
alpineRelease=$(cat /etc/alpine-release)
if ! grep PRETTY_NAME /etc/os-release | cut -d '=' -f 2 | tr -d '"' | grep -q "edge$" || [ "$(semver compare "$alpineRelease" "3.21.0")" -lt 0 ]; then
skip
fi
fi
export TARGETARCH=loong64
testHelloCPPLLD
}
@test "386-c++-lld" {
export TARGETARCH=386
testHelloCPPLLD

View File

@@ -17,7 +17,7 @@ setup_file() {
}
teardown_file() {
for p in linux/amd64 linux/arm64 linux/ppc64le linux/s390x linux/386 linux/arm/v7 linux/arm/v6 linux/riscv64; do
for p in linux/amd64 linux/arm64 linux/ppc64le linux/s390x linux/386 linux/arm/v7 linux/arm/v6 linux/riscv64 linux/loong64; do
TARGETPLATFORM=$p xxdel xx-c-essentials
root=/$(TARGETPLATFORM=$p xx-info triple)
if [ -d "$root" ] && [ "$root" != "/" ]; then
@@ -173,6 +173,14 @@ testEnv() {
testEnv
}
@test "loong64-env" {
if ! supportLoong64Go; then
skip "LOONGARCH64 not supported"
fi
export TARGETARCH=loong64
testEnv
}
@test "mips-env" {
export TARGETARCH=mips
expMips=hardfloat
@@ -333,6 +341,14 @@ testHelloGO() {
testHelloGO
}
@test "loong64-hellogo" {
if ! supportLoong64Go; then
skip "LOONGARCH64 not supported"
fi
export TARGETARCH=loong64
testHelloGO
}
@test "386-hellogo" {
export TARGETARCH=386
testHelloGO
@@ -452,6 +468,24 @@ testHelloCGO() {
testHelloCGO
}
@test "loong64-hellocgo" {
if ! supportLoong64CGo; then
skip "LOONGARCH64 not supported"
fi
if [ -f /etc/alpine-release ]; then
# FIXME: loong64-hellocgo issue on alpine < 3.21
# ld.lld: error: unknown emulation: elf64loongarch
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0x0): unknown relocation (102) against symbol
# error: unknown target triple 'loongarch64-alpine-linux-musl', please use -triple or -arch
alpineRelease=$(cat /etc/alpine-release)
if ! grep PRETTY_NAME /etc/os-release | cut -d '=' -f 2 | tr -d '"' | grep -q "edge$" || [ "$(semver compare "$alpineRelease" "3.21.0")" -lt 0 ]; then
skip
fi
fi
export TARGETARCH=loong64
testHelloCGO
}
@test "386-hellocgo" {
export TARGETARCH=386
testHelloCGO
@@ -477,6 +511,96 @@ testHelloCGO() {
assert_output --partial "PKG_CONFIG=$(xx-info triple)-pkg-config"
}
testHelloCGOZig() {
if ! supportZig; then
skip "Zig not supported"
fi
export CGO_ENABLED=1
export XX_GO_PREFER_C_COMPILER=zig
add zig
run xx-go build -x -o /tmp/a.out ./fixtures/hello_cgo.go
assert_success
run xx-verify /tmp/a.out
assert_success
if ! xx-info is-cross; then
run /tmp/a.out
assert_success
assert_output "hello cgo"
fi
}
@test "native-hellocgo-zig" {
unset TARGETARCH
testHelloCGOZig
}
@test "amd64-hellocgo-zig" {
export TARGETARCH=amd64
testHelloCGOZig
}
@test "arm64-hellocgo-zig" {
export TARGETARCH=arm64
testHelloCGOZig
}
@test "arm-hellocgo-zig" {
export TARGETARCH=arm
testHelloCGOZig
}
@test "ppc64le-hellocgo-zig" {
export TARGETARCH=ppc64le
testHelloCGOZig
}
@test "riscv64-hellocgo-zig" {
if ! supportRiscVCGo; then
skip "RISC-V CGO not supported"
fi
export TARGETARCH=riscv64
testHelloCGOZig
}
@test "loong64-hellocgo-zig" {
if ! supportLoong64CGo; then
skip "LOONGARCH64 not supported"
fi
if [ -f /etc/alpine-release ]; then
# FIXME: loong64-hellocgo issue on alpine < 3.21
# ld.lld: error: unknown emulation: elf64loongarch
# ld.lld: error: /loongarch64-alpine-linux-musl/usr/lib/gcc/loongarch64-alpine-linux-musl/14.2.0/crtbeginS.o:(.text+0x0): unknown relocation (102) against symbol
# error: unknown target triple 'loongarch64-alpine-linux-musl', please use -triple or -arch
alpineRelease=$(cat /etc/alpine-release)
if ! grep PRETTY_NAME /etc/os-release | cut -d '=' -f 2 | tr -d '"' | grep -q "edge$" || [ "$(semver compare "$alpineRelease" "3.21.0")" -lt 0 ]; then
skip
fi
fi
export TARGETARCH=loong64
testHelloCGOZig
}
@test "386-hellocgo-zig" {
export TARGETARCH=386
testHelloCGOZig
}
@test "arm64-cgoenv-zig" {
if ! supportZig; then
skip "Zig not supported"
fi
export TARGETARCH=arm64
export XX_GO_PREFER_C_COMPILER=zig
export CGO_ENABLED=1
add zig
# single/double quotes changed in between go versions
run sh -c "xx-go env | sed 's/[\"'\'']//g'"
assert_success
assert_output --partial "CC=zig cc -target"
assert_output --partial "CXX=zig c++ -target"
}
@test "wrap-unwrap" {
target="arm64"
if [ "$(xx-info arch)" = "arm64" ]; then target="amd64"; fi
@@ -501,3 +625,10 @@ testHelloCGO() {
assert_success
assert_output "$nativeArch"
}
@test "clean-packages" {
if ! supportZig; then
skip "Zig not supported"
fi
del zig
}

View File

@@ -92,10 +92,15 @@ load 'assert'
assert_equal "riscv64" "$(TARGETPLATFORM=linux/riscv64 RISCV64_TARGET_ARCH=riscv64gc xx-info pkg-arch)" # does not change
}
@test "custom-vendor" {
@test "riscv64-custom-vendor" {
assert_equal "riscv64-unknown-linux-musl" "$(TARGETPLATFORM=linux/riscv64 XX_VENDOR=unknown xx-info triple)"
}
@test "loong64" {
assert_equal "loongarch64-alpine-linux-musl" "$(TARGETPLATFORM=linux/loong64 xx-info triple)"
assert_equal "loongarch64" "$(TARGETPLATFORM=linux/loong64 xx-info pkg-arch)"
}
@test "mips" {
assert_equal "mips-alpine-linux-musl" "$(TARGETPLATFORM=linux/mips xx-info triple)"
assert_equal "mips" "$(TARGETPLATFORM=linux/mips xx-info pkg-arch)"

View File

@@ -85,6 +85,10 @@ load 'assert'
assert_equal "ppc64le" "$(TARGETPLATFORM=linux/ppc64le xx-info march)"
}
@test "loong64" {
assert_equal "loong64" "$(TARGETPLATFORM=linux/loong64 xx-info march)"
}
@test "mips" {
assert_equal "mips" "$(TARGETPLATFORM=linux/mips xx-info march)"
}
@@ -134,6 +138,10 @@ load 'assert'
assert_success
assert_output "$(TARGETPLATFORM=linux/riscv64 xx-info)"
TARGETPAIR=linux-loong64 run xx-info
assert_success
assert_output "$(TARGETPLATFORM=linux/loong64 xx-info)"
TARGETPAIR=linux-mips run xx-info
assert_success
assert_output "$(TARGETPLATFORM=linux/mips xx-info)"

View File

@@ -77,6 +77,11 @@ fi
assert_equal "riscv64gc-unknown-linux-gnu" "$(TARGETPLATFORM=linux/riscv64 RISCV64_TARGET_ARCH=riscv64gc XX_VENDOR=unknown xx-info triple)"
}
@test "loong64" {
assert_equal "loongarch64-linux-gnu" "$(TARGETPLATFORM=linux/loong64 xx-info triple)"
assert_equal "loong64" "$(TARGETPLATFORM=linux/loong64 xx-info pkg-arch)"
}
@test "mips" {
assert_equal "mips-linux-gnu" "$(TARGETPLATFORM=linux/mips xx-info triple)"
assert_equal "mips" "$(TARGETPLATFORM=linux/mips xx-info pkg-arch)"

View File

@@ -60,6 +60,10 @@ fi
assert_equal "riscv64" "$(TARGETPLATFORM=linux/riscv64 xx-info pkg-arch)"
}
@test "loong64" {
assert_equal "loong64" "$(TARGETPLATFORM=linux/loong64 xx-info pkg-arch)"
}
@test "mips" {
assert_equal "mips-linux-gnu" "$(TARGETPLATFORM=linux/mips xx-info triple)"
assert_equal "mips" "$(TARGETPLATFORM=linux/mips xx-info pkg-arch)"

View File

@@ -250,6 +250,15 @@ load 'assert'
run xx-verify /idontexist
assert_failure
export XX_VERIFY_FILE_CMD_OUTPUT=": ELF 64-bit LSB executable, LoongArch, version 1 (SYSV), statically linked, BuildID[sha1]=4d126b33c220ba2efd23ed68a46ef0db96c31f76, not stripped"
export TARGETPLATFORM=linux/loong64
run xx-verify /idontexist
assert_success
export TARGETPLATFORM=linux/amd64
run xx-verify /idontexist
assert_failure
unset XX_VERIFY_FILE_CMD_OUTPUT
unset TARGETPLATFORM
}

View File

@@ -45,7 +45,7 @@ xxrun() {
wasclang=1
fi
if [ "$p" = "golang" ]; then
p="golang-1.15"
p="golang-1.19"
wasgolang=1
fi
set -- "$@" "$p"
@@ -63,7 +63,7 @@ xxrun() {
fi
fi
if [ -n "$wasgolang" ] && ! command -v go 2>/dev/null >/dev/null; then
ln -s /usr/lib/go-1.15/bin/go /usr/bin/go
ln -s /usr/lib/go-1.19/bin/go /usr/bin/go
fi
}
@@ -87,6 +87,17 @@ supportRiscV() {
return 0
}
supportLoongArch() {
if [ -f /etc/debian_version ]; then
if grep "sid main" /etc/apt/sources.list 2>/dev/null >/dev/null; then
return 0
else
return 1
fi
fi
return 0
}
versionGTE() { test "$(printf '%s\n' "$@" | sort -V | tail -n 1)" = "$1"; }
supportRiscVGo() {
@@ -114,6 +125,24 @@ supportWindowsArm64Go() {
versionGTE "$(go version | awk '{print $3}' | sed 's/^go//')" "1.17"
}
supportLoong64Go() {
versionGTE "$(go version | awk '{print $3}' | sed 's/^go//')" "1.19"
}
supportLoong64CGo() {
if ! supportLoongArch; then
return 1
fi
if ! supportLoong64Go; then
return 1
fi
return 0
}
supportRC() {
command -v llvm-rc >/dev/null 2>&1
}
supportZig() {
[ -f /etc/alpine-release ] && versionGTE "$(xx-info os-version | cut -d'.' -f1-2)" "3.20"
}

View File

@@ -59,6 +59,11 @@ setup() {
echo "https://dl-cdn.alpinelinux.org/alpine/v3.20/main" >"$apk_dir/repositories"
echo "https://dl-cdn.alpinelinux.org/alpine/v3.20/community" >>"$apk_dir/repositories"
fi
# loong64 supported since alpine 3.21
if [ "$TARGETARCH" = "loong64" ] && ! supportLoong64; then
echo "https://dl-cdn.alpinelinux.org/alpine/v3.21/main" >"$apk_dir/repositories"
echo "https://dl-cdn.alpinelinux.org/alpine/v3.21/community" >>"$apk_dir/repositories"
fi
mkdir -p "$apk_dir/keys"
mkdir -p "$apk_dir/protected_paths.d"
echo "$XX_PKG_ARCH" >"$apk_dir/arch"
@@ -146,6 +151,10 @@ supportRiscV() {
versionGTE "$(xx-info os-version | cut -d'.' -f1-2)" "3.20"
}
supportLoong64() {
versionGTE "$(xx-info os-version | cut -d'.' -f1-2)" "3.21"
}
case "$1" in
"setup")
setup

View File

@@ -175,6 +175,8 @@ detectTargetOSArch() {
targetarch="s390x"
elif [ "$arch" = "powerpc64le" ]; then
targetarch="ppc64le"
elif [ "$arch" = "loong64" ]; then
targetarch="loong64"
fi
if [ -z "$targetarch" ]; then
@@ -342,6 +344,10 @@ setup() {
if [ "${target#riscv64}" != "${target}" ]; then
prefer_lld=
fi
# lld has no support for loong64
if [ "${target#loong64}" != "${target}" ]; then
prefer_lld=
fi
if [ -n "${XX_CC_PREFER_STATIC_LINKER}" ] && { [ "${target#386}" != "${target}" ] || [ "${target#powerpc64le}" != "${target}" ]; }; then
prefer_lld=
@@ -410,6 +416,9 @@ setup() {
if [ "$exp" = "riscv64" ]; then
exp="riscv"
fi
if [ "$exp" = "loong64" ]; then
exp="loongarch64"
fi
if ld -V 2>/dev/null | grep "$exp" >/dev/null; then
ln -s "$(command -v ld)" "/usr/bin/${target}-ld"
linker="/usr/bin/${target}-ld"

150
src/xx-go
View File

@@ -6,6 +6,9 @@ for l in $(xx-info env); do
export "${l?}"
done
: "${XX_GO_PREFER_C_COMPILER=clang}"
: "${XX_ZIG_TRIPLE=unknown-unknown-none}"
export GOOS="${TARGETOS}"
export GOARCH="${TARGETARCH}"
@@ -24,6 +27,28 @@ case "$TARGETARCH" in
;;
esac
fi
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="x86_64-linux-musl"
else
XX_ZIG_TRIPLE="x86_64-linux-gnu"
fi
if [ "$TARGETOS" = "darwin" ]; then
XX_ZIG_TRIPLE="x86_64-macos-none"
elif [ "$TARGETOS" = "windows" ]; then
XX_ZIG_TRIPLE="x86_64-windows-gnu"
fi
;;
"arm64")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="aarch64-linux-musl"
else
XX_ZIG_TRIPLE="aarch64-linux-gnu"
fi
if [ "$TARGETOS" = "darwin" ]; then
XX_ZIG_TRIPLE="aarch64-macos-none"
elif [ "$TARGETOS" = "windows" ]; then
XX_ZIG_TRIPLE="aarch64-windows-gnu"
fi
;;
"arm")
if [ -z "$GOARM" ]; then
@@ -39,6 +64,94 @@ case "$TARGETARCH" in
;;
esac
fi
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="arm-linux-musleabihf"
else
XX_ZIG_TRIPLE="arm-linux-gnueabihf"
fi
if [ "$TARGETVARIANT" = "v6" ]; then
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="arm-linux-musleabi"
else
XX_ZIG_TRIPLE="arm-linux-gnueabi"
fi
fi
if [ "$TARGETVARIANT" = "v5" ]; then
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="arm-linux-musleabi"
else
XX_ZIG_TRIPLE="arm-linux-gnueabi"
fi
fi
if [ "$TARGETOS" = "windows" ]; then
XX_ZIG_TRIPLE="arm-windows-gnu"
fi
;;
"riscv64")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="riscv64-linux-musl"
else
XX_ZIG_TRIPLE="riscv64-linux-gnu"
fi
;;
"ppc64le")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="powerpc64le-linux-musl"
else
XX_ZIG_TRIPLE="powerpc64le-linux-gnu"
fi
;;
"s390x")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="s390x-linux-musl"
else
XX_ZIG_TRIPLE="s390x-linux-gnu"
fi
;;
"loong64")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="loongarch64-linux-musl"
else
XX_ZIG_TRIPLE="loongarch64-linux-gnu"
fi
;;
"386")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="x86-linux-musl"
else
XX_ZIG_TRIPLE="x86-linux-gnu"
fi
if [ "$TARGETOS" = "windows" ]; then
XX_ZIG_TRIPLE="x86-windows-gnu"
fi
;;
"mips")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="mips-linux-musl"
else
XX_ZIG_TRIPLE="mips-linux-gnueabi"
fi
;;
"mipsle")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="mipsel-linux-musl"
else
XX_ZIG_TRIPLE="mipsel-linux-gnueabi"
fi
;;
"mips64")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="mips64-linux-musl"
else
XX_ZIG_TRIPLE="mips64-linux-gnuabi64"
fi
;;
"mips64le")
if [ "$XX_LIBC" = "musl" ]; then
XX_ZIG_TRIPLE="mips64el-linux-musl"
else
XX_ZIG_TRIPLE="mips64el-linux-gnuabi64"
fi
;;
esac
@@ -76,26 +189,33 @@ if command -v "$XX_TRIPLE-g++" >/dev/null 2>/dev/null; then
cxx_set=1
fi
if command -v clang >/dev/null 2>/dev/null; then
triple=$(xx-clang --print-target-triple || true)
if [ -n "$triple" ]; then
export CC="$triple-clang"
export CXX="$triple-clang++"
if [ "$XX_GO_PREFER_C_COMPILER" = "clang" ]; then
if command -v clang >/dev/null 2>/dev/null; then
triple=$(xx-clang --print-target-triple || true)
if [ -n "$triple" ]; then
export CC="$triple-clang"
export CXX="$triple-clang++"
c_set=1
cxx_set=1
fi
fi
if command -v "$XX_TRIPLE-ar" >/dev/null 2>/dev/null; then
export AR="$XX_TRIPLE-ar"
ar_set=1
fi
if command -v "$XX_TRIPLE-pkg-config" >/dev/null 2>/dev/null; then
export PKG_CONFIG="$XX_TRIPLE-pkg-config"
pkgconfig_set=1
fi
elif [ "$XX_GO_PREFER_C_COMPILER" = "zig" ]; then
if command -v "zig" >/dev/null 2>/dev/null; then
export CC="zig cc -target $XX_ZIG_TRIPLE"
c_set=1
export CXX="zig c++ -target $XX_ZIG_TRIPLE"
cxx_set=1
fi
fi
if command -v "$XX_TRIPLE-ar" >/dev/null 2>/dev/null; then
export AR="$XX_TRIPLE-ar"
ar_set=1
fi
if command -v "$XX_TRIPLE-pkg-config" >/dev/null 2>/dev/null; then
export PKG_CONFIG="$XX_TRIPLE-pkg-config"
pkgconfig_set=1
fi
if [ -z "$GOBIN" ] && [ -n "$GOPATH" ] && [ -n "$GOARCH" ] && [ -n "$GOOS" ]; then
export PATH="${GOPATH}/bin/${GOOS}_${GOARCH}:${PATH}"
fi

View File

@@ -190,6 +190,9 @@ if [ -z "$TARGETARCH" ]; then
"s390x")
TARGETARCH="s390x"
;;
"loong64")
TARGETARCH="loong64"
;;
"mips")
TARGETARCH="mips"
;;
@@ -221,6 +224,8 @@ if [ "$TARGETOS" = "darwin" ] && [ -z "$MACOSX_VERSION_MIN" ]; then
fi
fi
# debian: https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/data/cputable
# alpine: https://gitlab.alpinelinux.org/alpine/apk-tools/-/blob/master/src/apk_arch.h?ref_type=heads
case "$TARGETARCH" in
"amd64")
XX_MARCH="x86_64"
@@ -309,6 +314,13 @@ case "$TARGETARCH" in
XX_RHEL_ARCH="s390x"
XX_TRIPLE="s390x${vendor}-linux-${XX_LIBC}"
;;
"loong64")
XX_MARCH="loong64"
XX_DEBIAN_ARCH="loong64"
XX_ALPINE_ARCH="loongarch64"
XX_RHEL_ARCH="loong64"
XX_TRIPLE="loongarch64${vendor}-linux-${XX_LIBC}"
;;
"386")
XX_MARCH="i386"
XX_DEBIAN_ARCH="i386"

View File

@@ -214,6 +214,10 @@ for f in "$@"; do
expArch="IBM S/390"
expArch2="64-bit MSB"
;;
"loong64")
expArch="LoongArch"
expArch2="64-bit LSB"
;;
"mips")
expArch="MIPS"
expArch2="32-bit MSB"

View File

@@ -19,7 +19,8 @@ target "all" {
"linux/386",
"linux/riscv64",
"linux/s390x",
"linux/ppc64le"
"linux/ppc64le",
"linux/loong64"
]
}