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:
runs-on: ubuntu-latest
container:
image: ubuntu:16.04
steps:
- name: Set up build environment
run: |
apt-get update && apt-get install -y build-essential
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: master
- uses: actions/checkout@v3
- name: configure
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build
- name: make
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
- name: build
run: |
zig build -Drelease-fast -Dtarget=x86_64-linux-gnu.2.17
- name: tests
run: cd zig-out/bin && ./run.sh
- uses: actions/upload-artifact@v3
with:
name: build-linux-x64
path: .libsodium-build/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
path: zig-out/lib/libsodium.so
build-linux-glibc-arm:
runs-on: ubuntu-latest
container:
image: ubuntu:16.04
options: --privileged
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: |
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
dpkg --add-architecture armhf
update-binfmts --enable qemu-arm
update-binfmts --display
ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.* /lib
sudo apt-get update
sudo apt-get install -y build-essential qemu binfmt-support qemu-user-static qemu-system-arm gcc-arm-linux-gnueabihf libc6-armhf-cross
sudo dpkg --add-architecture armhf
sudo update-binfmts --enable qemu-arm
sudo update-binfmts --display
sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.* /lib
- uses: actions/checkout@v3
- name: configure
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build --host=arm-linux-gnueabihf
- name: make
run: make -j $(nproc)
- name: make check
- name: build
run: |
env LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib make check
- name: make install
run: make install
- name: strip
run: arm-linux-gnueabihf-strip --strip-all .libsodium-build/lib/libsodium.so
zig build -Drelease-fast -Dtarget=arm-linux-gnueabihf.2.23
- name: tests
run: |
cd zig-out/bin && env LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib ./run.sh
- uses: actions/upload-artifact@v3
with:
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:
runs-on: ubuntu-latest
container:
image: alpine:latest
image: alpine:3.13
steps:
- name: Set up build environment
run: |
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
- name: configure
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build
- name: make
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
- name: build
run: |
zig build -Drelease-fast -Dtarget=x86_64-linux-musl
- name: tests
run: |
cd zig-out/bin && ./run.sh
- uses: actions/upload-artifact@v3
with:
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:
runs-on: ubuntu-latest
container:
image: alpine:latest
steps:
- name: Set up build environment
run: |
apk update
apk add alpine-sdk ca-certificates
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: master
- uses: actions/checkout@v3
- name: configure
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build --host=aarch64-linux-gnu
- name: make
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
- name: build
run: |
zig build -Drelease-fast -Dtarget=aarch64-linux-musl
- uses: actions/upload-artifact@v3
with:
name: build-linux-musl-arm64
path: .libsodium-build/lib/libsodium.so
path: zig-out/lib/libsodium.so
build-macos-x64:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- 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
run: make
- name: make check
@ -178,11 +176,11 @@ jobs:
path: .libsodium-build/lib/libsodium.dylib
build-macos-arm64:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- 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
run: make
- name: make install
@ -200,6 +198,7 @@ jobs:
- build-linux-glibc-arm
- build-linux-glibc-arm64
- build-linux-musl
- build-linux-musl-arm
- build-linux-musl-arm64
- build-macos-x64
- build-macos-arm64
@ -235,6 +234,10 @@ jobs:
with:
name: build-linux-musl-x64
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
with:
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_SEGV", "1");
lib.defineCMacro("HAVE_GETENTROPY", "1");
lib.defineCMacro("HAVE_GETPID", "1");
lib.defineCMacro("HAVE_GETRANDOM", "1");
lib.defineCMacro("HAVE_INLINE_ASM", "1");
lib.defineCMacro("HAVE_MADVISE", "1");
lib.defineCMacro("HAVE_MLOCK", "1");

View File

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