Compile .NET Linux targets with Zig

This commit is contained in:
Frank Denis 2022-11-27 21:58:50 +01:00
parent 565bea3602
commit 5bb26cbb94
3 changed files with 105 additions and 103 deletions

View File

@ -26,146 +26,144 @@ jobs:
build-linux-glibc: build-linux-glibc:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: ubuntu:16.04
steps: steps:
- name: Set up build environment - name: Install Zig
run: | uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
apt-get update && apt-get install -y build-essential with:
version: master
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: configure - name: build
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build run: |
- name: make zig build -Drelease-fast -Dtarget=x86_64-linux-gnu.2.17
run: make - name: tests
- name: make check run: cd zig-out/bin && ./run.sh
run: make check
- name: make install
run: make install
- name: strip
run: strip --strip-all .libsodium-build/lib/libsodium.so
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: build-linux-x64 name: build-linux-x64
path: .libsodium-build/lib/libsodium.so path: zig-out/lib/libsodium.so
build-linux-glibc-arm64:
runs-on: ubuntu-latest
container:
image: ubuntu:16.04
options: --privileged
steps:
- name: Set up build environment
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get install -y build-essential qemu binfmt-support qemu-user-static qemu-system-arm gcc-aarch64-linux-gnu libc6-arm64-cross
dpkg --add-architecture arm64
update-binfmts --enable qemu-aarch64
update-binfmts --display
ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.* /lib
- uses: actions/checkout@v3
- name: configure
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build --host=aarch64-linux-gnu
- name: make
run: make -j $(nproc)
- name: make check
run: |
env LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib make check
- name: make install
run: make install
- name: strip
run: aarch64-linux-gnu-strip --strip-all .libsodium-build/lib/libsodium.so
- uses: actions/upload-artifact@v3
with:
name: build-linux-arm64
path: .libsodium-build/lib/libsodium.so
build-linux-glibc-arm: build-linux-glibc-arm:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: ubuntu:16.04
options: --privileged
steps: steps:
- name: Set up build environment - name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: master
- name: Fix ARM support
run: |
curl -L https://raw.githubusercontent.com/ziglang/zig/master/lib/libc/glibc/sysdeps/arm/arm-features.h | sudo tee /opt/hostedtoolcache/zig/zig-linux-x86_64-*/x64/lib/libc/glibc/sysdeps/arm/sysdep.h >/dev/null
- name: Set up emulation environment
run: | run: |
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get install -y build-essential qemu binfmt-support qemu-user-static qemu-system-arm gcc-arm-linux-gnueabihf libc6-armhf-cross sudo apt-get update
dpkg --add-architecture armhf sudo apt-get install -y build-essential qemu binfmt-support qemu-user-static qemu-system-arm gcc-arm-linux-gnueabihf libc6-armhf-cross
update-binfmts --enable qemu-arm sudo dpkg --add-architecture armhf
update-binfmts --display sudo update-binfmts --enable qemu-arm
ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.* /lib sudo update-binfmts --display
sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.* /lib
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: configure - name: build
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build --host=arm-linux-gnueabihf
- name: make
run: make -j $(nproc)
- name: make check
run: | run: |
env LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib make check zig build -Drelease-fast -Dtarget=arm-linux-gnueabihf.2.23
- name: make install - name: tests
run: make install run: |
- name: strip cd zig-out/bin && env LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib ./run.sh
run: arm-linux-gnueabihf-strip --strip-all .libsodium-build/lib/libsodium.so
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: build-linux-arm name: build-linux-arm
path: .libsodium-build/lib/libsodium.so path: zig-out/lib/libsodium.so
build-linux-glibc-arm64:
runs-on: ubuntu-latest
steps:
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: master
- name: Set up emulation environment
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y qemu binfmt-support qemu-user-static qemu-system-arm gcc-aarch64-linux-gnu libc6-arm64-cross
sudo dpkg --add-architecture arm64
sudo update-binfmts --enable qemu-aarch64
sudo update-binfmts --display
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.* /lib
- uses: actions/checkout@v3
- name: build
run: |
zig build -Drelease-fast -Dtarget=aarch64-linux-gnu.2.23
- name: tests
run: |
cd zig-out/bin && env LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib ./run.sh
- uses: actions/upload-artifact@v3
with:
name: build-linux-arm64
path: zig-out/lib/libsodium.so
build-linux-musl: build-linux-musl:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: alpine:latest image: alpine:3.13
steps: steps:
- name: Set up build environment - name: Set up build environment
run: | run: |
apk update apk update
apk add alpine-sdk ca-certificates apk add alpine-sdk ca-certificates xz
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: master
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: configure - name: build
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build run: |
- name: make zig build -Drelease-fast -Dtarget=x86_64-linux-musl
run: make - name: tests
- name: make check run: |
run: make check cd zig-out/bin && ./run.sh
- name: make install
run: make install
- name: strip
run: strip --strip-all .libsodium-build/lib/libsodium.so
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: build-linux-musl-x64 name: build-linux-musl-x64
path: .libsodium-build/lib/libsodium.so path: zig-out/lib/libsodium.so
build-linux-musl-arm:
runs-on: ubuntu-latest
steps:
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: master
- uses: actions/checkout@v3
- name: build
run: |
zig build -Drelease-fast -Dtarget=arm-linux-musleabihf
- uses: actions/upload-artifact@v3
with:
name: build-linux-musl-arm
path: zig-out/lib/libsodium.so
build-linux-musl-arm64: build-linux-musl-arm64:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: alpine:latest
steps: steps:
- name: Set up build environment - name: Install Zig
run: | uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
apk update with:
apk add alpine-sdk ca-certificates version: master
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: configure - name: build
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build --host=aarch64-linux-gnu run: |
- name: make zig build -Drelease-fast -Dtarget=aarch64-linux-musl
run: make
- name: make check
run: make check
- name: make install
run: make install
- name: strip
run: strip --strip-all .libsodium-build/lib/libsodium.so
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: build-linux-musl-arm64 name: build-linux-musl-arm64
path: .libsodium-build/lib/libsodium.so path: zig-out/lib/libsodium.so
build-macos-x64: build-macos-x64:
runs-on: macos-11 runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: configure - name: configure
run: env CFLAGS="-Ofast -arch x86_64 -mmacosx-version-min=10.10" LDFLAGS="-arch x86_64 -mmacosx-version-min=10.10" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build run: env CFLAGS="-Ofast -arch x86_64 -mmacosx-version-min=10.13" LDFLAGS="-arch x86_64 -mmacosx-version-min=10.13" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build
- name: make - name: make
run: make run: make
- name: make check - name: make check
@ -178,11 +176,11 @@ jobs:
path: .libsodium-build/lib/libsodium.dylib path: .libsodium-build/lib/libsodium.dylib
build-macos-arm64: build-macos-arm64:
runs-on: macos-11 runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: configure - name: configure
run: env CFLAGS="-Ofast -arch arm64 -mmacosx-version-min=10.10" LDFLAGS="-arch arm64 -mmacosx-version-min=10.10" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build run: env CFLAGS="-Ofast -arch arm64 -mmacosx-version-min=10.13" LDFLAGS="-arch arm64 -mmacosx-version-min=10.13" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build
- name: make - name: make
run: make run: make
- name: make install - name: make install
@ -200,6 +198,7 @@ jobs:
- build-linux-glibc-arm - build-linux-glibc-arm
- build-linux-glibc-arm64 - build-linux-glibc-arm64
- build-linux-musl - build-linux-musl
- build-linux-musl-arm
- build-linux-musl-arm64 - build-linux-musl-arm64
- build-macos-x64 - build-macos-x64
- build-macos-arm64 - build-macos-arm64
@ -235,6 +234,10 @@ jobs:
with: with:
name: build-linux-musl-x64 name: build-linux-musl-x64
path: .libsodium-pack/runtimes/linux-musl-x64/native/ path: .libsodium-pack/runtimes/linux-musl-x64/native/
- uses: actions/download-artifact@v3
with:
name: build-linux-musl-arm
path: .libsodium-pack/runtimes/linux-musl-arm/native/
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: build-linux-musl-arm64 name: build-linux-musl-arm64

View File

@ -63,9 +63,7 @@ pub fn build(b: *std.build.Builder) !void {
lib.defineCMacro("HAVE_CATCHABLE_ABRT", "1"); lib.defineCMacro("HAVE_CATCHABLE_ABRT", "1");
lib.defineCMacro("HAVE_CATCHABLE_SEGV", "1"); lib.defineCMacro("HAVE_CATCHABLE_SEGV", "1");
lib.defineCMacro("HAVE_GETENTROPY", "1");
lib.defineCMacro("HAVE_GETPID", "1"); lib.defineCMacro("HAVE_GETPID", "1");
lib.defineCMacro("HAVE_GETRANDOM", "1");
lib.defineCMacro("HAVE_INLINE_ASM", "1"); lib.defineCMacro("HAVE_INLINE_ASM", "1");
lib.defineCMacro("HAVE_MADVISE", "1"); lib.defineCMacro("HAVE_MADVISE", "1");
lib.defineCMacro("HAVE_MLOCK", "1"); lib.defineCMacro("HAVE_MLOCK", "1");

View File

@ -901,6 +901,7 @@ top_srcdir = @top_srcdir@
valgrind_enabled_tools = @valgrind_enabled_tools@ valgrind_enabled_tools = @valgrind_enabled_tools@
valgrind_tools = @valgrind_tools@ valgrind_tools = @valgrind_tools@
EXTRA_DIST = \ EXTRA_DIST = \
run.sh \
cmptest.h \ cmptest.h \
wasi-test-wrapper.sh \ wasi-test-wrapper.sh \
wintest.bat \ wintest.bat \