zig-cross-compile.yml raw

   1  # This workflow uses Zig and its excellent cross-compilation support to test
   2  # compiling for multiple platforms. No tests are actually run since it would
   3  # require emulation.
   4  name: zig cross-compile
   5  
   6  on: [ push, pull_request ]
   7  
   8  jobs:
   9    build:
  10      name: ${{ matrix.ttriple }} cpp:${{ matrix.enable_cplusplus }} thr:${{ matrix.enable_threads }} dll:${{ matrix.shared_libs }}
  11      runs-on: ubuntu-latest
  12  
  13      strategy:
  14        fail-fast: false
  15        matrix:
  16          zig_version: [ "0.14.1" ]
  17          # Some of the triples are commented out just to speedup this workflow.
  18          ttriple: [
  19            aarch64-linux-gnu,
  20            #aarch64-linux-musl,
  21            aarch64-macos-none,
  22            aarch64-windows-gnu,
  23            #aarch64_be-linux-gnu,
  24            aarch64_be-linux-musl,
  25            #arc-linux-gnu, # FIXME: __linux__ macro is not predefined
  26            #arm-linux-gnueabi,
  27            arm-linux-gnueabihf,
  28            arm-linux-musleabi,
  29            #arm-linux-musleabihf,
  30            armeb-linux-gnueabi,
  31            #armeb-linux-gnueabihf,
  32            #armeb-linux-musleabi,
  33            armeb-linux-musleabihf,
  34            loongarch64-linux-gnu,
  35            #loongarch64-linux-gnusf, # FIXME: gnu/stubs-lp64s.h not found
  36            loongarch64-linux-musl,
  37            #m68k-linux-gnu, # FIXME: No available targets compatible with triple
  38            #m68k-linux-musl, # FIXME: No available targets compatible with triple
  39            #mips-linux-gnueabi,
  40            #mips-linux-gnueabihf,
  41            mips-linux-musleabi,
  42            mips-linux-musleabihf,
  43            mips64-linux-gnuabi64,
  44            #mips64-linux-gnuabin32,
  45            mips64-linux-muslabi64,
  46            mips64-linux-muslabin32,
  47            #mips64el-linux-gnuabi64,
  48            mips64el-linux-gnuabin32,
  49            mips64el-linux-muslabi64,
  50            mips64el-linux-muslabin32,
  51            mipsel-linux-gnueabi,
  52            #mipsel-linux-gnueabihf,
  53            mipsel-linux-musleabi,
  54            mipsel-linux-musleabihf,
  55            #powerpc-linux-gnueabi,
  56            powerpc-linux-gnueabihf,
  57            #powerpc-linux-musleabi,
  58            powerpc-linux-musleabihf,
  59            #powerpc64-linux-gnu, # FIXME: not implemented correctly in zig
  60            #powerpc64-linux-musl,
  61            #powerpc64le-linux-gnu,
  62            powerpc64le-linux-musl,
  63            riscv32-linux-gnu,
  64            riscv32-linux-musl,
  65            riscv64-linux-gnu,
  66            riscv64-linux-musl,
  67            s390x-linux-gnu,
  68            s390x-linux-musl,
  69            sparc-linux-gnu,
  70            sparc64-linux-gnu,
  71            thumb-linux-musleabi,
  72            #thumb-linux-musleabihf,
  73            thumb-windows-gnu,
  74            #thumbeb-linux-musleabi,
  75            thumbeb-linux-musleabihf,
  76            wasm32-wasi-musl,
  77            #x86-linux-gnu,
  78            x86-linux-musl,
  79            x86-windows-gnu,
  80            x86_64-linux-gnu.2.27, # with a glibc version
  81            x86_64-linux-gnux32,
  82            #x86_64-linux-musl,
  83            x86_64-linux-muslx32,
  84            x86_64-macos-none,
  85            x86_64-windows-gnu,
  86          ]
  87          enable_cplusplus: [ false, true ]
  88          enable_threads: [ false, true ]
  89          shared_libs: [ false, true ]
  90          exclude:
  91          - enable_threads: true
  92            ttriple: wasm32-wasi-musl
  93          - enable_cplusplus: false # excluded to speedup this workflow
  94            shared_libs: false
  95          - shared_libs: true # FIXME: SPARCv8 does not handle f128 in calls
  96            ttriple: sparc-linux-gnu
  97          - shared_libs: true # FIXME: recompile with -fPIC
  98            ttriple: sparc64-linux-gnu
  99          - shared_libs: true # FIXME: recompile with -fPIC
 100            ttriple: x86_64-linux-gnux32
 101          - shared_libs: true # FIXME: recompile with -fPIC
 102            ttriple: x86_64-linux-muslx32
 103          - shared_libs: true # FIXME: creating shared libs is not yet stable
 104            ttriple: wasm32-wasi-musl
 105          - enable_cplusplus: true # FIXME: ignoring -fno-PIC option
 106            ttriple: mips64-linux-muslabi64
 107          - enable_cplusplus: true # FIXME: ignoring -fno-PIC option
 108            ttriple: mips64el-linux-muslabi64
 109          # The following ones have some zig link issue.
 110          - enable_cplusplus: false
 111            ttriple: x86-linux-musl
 112          - enable_cplusplus: true
 113            shared_libs: true
 114            ttriple: x86-linux-musl
 115  
 116      steps:
 117      - uses: actions/checkout@v4
 118      - uses: korandoru/setup-zig@v1
 119        with:
 120          zig-version: ${{ matrix.zig_version }}
 121      - name: Build
 122        run: >
 123          zig build -Dtarget=${{ matrix.ttriple }}
 124          -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }}
 125          -DCFLAGS_EXTRA="${{ matrix.cflags_extra }}"
 126          -Denable_cplusplus=${{ matrix.enable_cplusplus }}
 127          -Denable_threads=${{ matrix.enable_threads }}
 128          -Denable_werror
 129