From e853683917118d16d11b398466ff18afd1b93225 Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Mon, 10 Mar 2025 13:46:03 +0000 Subject: [PATCH 1/3] add linux/musl-riscv64 build --- .github/workflows/ci.yml | 8 ++++++-- README.md | 4 ++-- UpdateLibgit2ToSha.ps1 | 1 + docker/musl | 6 ++++-- dockerbuild.sh | 9 +++++++-- nuget.package/libgit2/LibGit2Sharp.dll.config | 1 + 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16c2c540..98b2badc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,12 +33,16 @@ jobs: name: linux-arm64 - os: ubuntu-24.04 name: linux-ppc64le + - os: ubuntu-24.04 + name: linux-riscv64 - os: ubuntu-24.04 name: linux-musl-x64 - os: ubuntu-24.04 name: linux-musl-arm - os: ubuntu-24.04 name: linux-musl-arm64 + - os: ubuntu-24.04 + name: linux-musl-riscv64 - os: macos-14 name: osx-x64 - os: macos-14 @@ -56,8 +60,8 @@ jobs: if: runner.os == 'macOS' run: ./build.libgit2.sh - name: Setup QEMU - if: matrix.name == 'linux-musl-arm' || matrix.name == 'linux-musl-arm64' - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset + if: runner.os == 'Linux' + run: docker run --privileged --rm tonistiigi/binfmt --install all - name: Build Linux if: runner.os == 'Linux' run: ./dockerbuild.sh diff --git a/README.md b/README.md index a6f68879..2b0e1131 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ the following platforms: - Windows (x86, x64, arm64) - macOS (x64, arm64) - Linux - - glibc: (x64, arm, arm64, ppc64le) - - musl: (x64, arm, arm64) + - glibc: (x64, arm, arm64, ppc64le, riscv64) + - musl: (x64, arm, arm64, riscv64) [lg2s-nb]: https://www.nuget.org/packages/LibGit2Sharp.NativeBinaries [lg2]: https://libgit2.github.com/ diff --git a/UpdateLibgit2ToSha.ps1 b/UpdateLibgit2ToSha.ps1 index a3111d3d..00ca2ace 100644 --- a/UpdateLibgit2ToSha.ps1 +++ b/UpdateLibgit2ToSha.ps1 @@ -124,6 +124,7 @@ Push-Location $libgit2Directory + diff --git a/docker/musl b/docker/musl index 1cfa1e4e..4d02bb82 100644 --- a/docker/musl +++ b/docker/musl @@ -1,8 +1,10 @@ ARG ARCH='amd64' -FROM multiarch/alpine:${ARCH}-v3.13 +ARG ALPINE_VERSION='3.13' + +FROM alpine:${ALPINE_VERSION} RUN apk add --no-cache bash build-base cmake WORKDIR /nativebinaries COPY . /nativebinaries/ -CMD ["/bin/bash", "-c", "./build.libgit2.sh"] \ No newline at end of file +CMD ["/bin/bash", "-c", "./build.libgit2.sh"] diff --git a/dockerbuild.sh b/dockerbuild.sh index c42fa150..afc98f20 100755 --- a/dockerbuild.sh +++ b/dockerbuild.sh @@ -3,12 +3,17 @@ set -e echo "building for $RID" +alpineVersion=3.13 + if [[ $RID =~ arm64 ]]; then arch="arm64" elif [[ $RID =~ arm ]]; then arch="armhf" elif [[ $RID =~ ppc64le ]]; then arch="powerpc64le" +elif [[ $RID =~ riscv64 ]]; then + arch="riscv64" + alpineVersion=3.20 # alpine 3.20 is the first version with official riscv64 support else arch="amd64" fi @@ -19,9 +24,9 @@ else dockerfile="docker/linux" fi -docker buildx build -t $RID -f $dockerfile --build-arg ARCH=$arch . +docker build --no-cache --platform linux/$arch -t $RID -f $dockerfile --build-arg ALPINE_VERSION=$alpineVersion . -docker run -t -e RID=$RID --name=$RID $RID +docker run -t --platform linux/$arch -e RID=$RID --name=$RID $RID docker cp $RID:/nativebinaries/nuget.package/runtimes nuget.package diff --git a/nuget.package/libgit2/LibGit2Sharp.dll.config b/nuget.package/libgit2/LibGit2Sharp.dll.config index 95f4b0bc..25074a9a 100644 --- a/nuget.package/libgit2/LibGit2Sharp.dll.config +++ b/nuget.package/libgit2/LibGit2Sharp.dll.config @@ -3,6 +3,7 @@ + From b4bb01fbe65ac99e4a8e8e5d3f297b063857ad32 Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Mon, 20 Jul 2026 22:13:36 +0300 Subject: [PATCH 2/3] Apply suggestion from @kasperk81 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98b2badc..aada206c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: if: runner.os == 'macOS' run: ./build.libgit2.sh - name: Setup QEMU - if: runner.os == 'Linux' + if: startsWith(matrix.name, 'linux-musl-') run: docker run --privileged --rm tonistiigi/binfmt --install all - name: Build Linux if: runner.os == 'Linux' From d56f6dafa84047357f38caa6ca5b3de9bead8259 Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Mon, 20 Jul 2026 23:05:02 +0300 Subject: [PATCH 3/3] . --- dockerbuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerbuild.sh b/dockerbuild.sh index afc98f20..efe31181 100755 --- a/dockerbuild.sh +++ b/dockerbuild.sh @@ -24,7 +24,7 @@ else dockerfile="docker/linux" fi -docker build --no-cache --platform linux/$arch -t $RID -f $dockerfile --build-arg ALPINE_VERSION=$alpineVersion . +docker build --no-cache --platform linux/$arch -t $RID -f $dockerfile --build-arg ARCH=$arch --build-arg ALPINE_VERSION=$alpineVersion . docker run -t --platform linux/$arch -e RID=$RID --name=$RID $RID