Skip to content

Fails to build with MinGW / MinGW-w64 toolchain on Windows #73

@luau-project

Description

@luau-project

Description

At the current state, lua-zlib fails to build with MinGW / MinGW-w64 toolchain on Windows.

Reproduction

For the reproduction, I used the same GitHub workflow employed on my PR (#72). As explained in the PR, on Windows, luajit and luajit-openresty are built with MinGW-w64 provided by GitHub.

It can be seen in the screenshot that, without the rockspec changes on PR, lua-zlib fails to build with MinGW / MinGW-w64 toolchain on Windows:

Image

Login on GitHub and browse the runs on a branch that I created for the issue reproduction https://github.com/luau-project/lua-zlib/actions/runs/14017735719.

If you are interested to run the workflow yourself, just create a new branch on your fork, paste the workflow in the expandable section below on .github/workflows/test.yml and push it to GitHub.

Expand here to see the workflow
name: Test

on: [ push, pull_request ]

jobs:

  test:
    strategy:
      fail-fast: false
      matrix:
        os: [ "ubuntu-20.04", "macos-14", "windows-2025" ]
        luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit", "luajit-openresty" ]
    runs-on: ${{ matrix.os }}
    env:
      LUAROCKS_WINDOWS_DEPS_DIR: C:\external
      WINDOWS_ZLIB_VERSION: 1.3.1
    steps:
    - name: Checkout
      uses: actions/checkout@v4
    - name: Setup MSVC command prompt
      if: ${{ runner.os == 'Windows' && !startsWith(matrix.luaVersion, 'luajit') }}
      uses: ilammy/msvc-dev-cmd@v1
    - name: Setup ‘lua’
      uses: luarocks/gh-actions-lua@v10
      with:
        luaVersion: ${{ matrix.luaVersion }}
    - name: Setup ‘luarocks’
      uses: luarocks/gh-actions-luarocks@v5
    - name: Restore zlib tarball on Windows
      if: ${{ runner.os == 'Windows' }}
      id: restore-zlib-tarball
      uses: actions/cache/restore@v4
      with:
        path: "zlib-${{ env.WINDOWS_ZLIB_VERSION }}.tar.gz"
        key: "zlib-${{ env.WINDOWS_ZLIB_VERSION }}"
    - name: Download zlib
      if: ${{ runner.os == 'Windows' && steps.restore-zlib-tarball.outputs.cache-hit != 'true' }}
      run: curl -L -O "https://zlib.net/fossils/zlib-${{ env.WINDOWS_ZLIB_VERSION }}.tar.gz"
    - name: Save zlib tarball
      if: ${{ runner.os == 'Windows' && steps.restore-zlib-tarball.outputs.cache-hit != 'true' }}
      uses: actions/cache/save@v4
      with:
        path: "zlib-${{ env.WINDOWS_ZLIB_VERSION }}.tar.gz"
        key: "zlib-${{ env.WINDOWS_ZLIB_VERSION }}"
    - name: Extract, configure, build and install zlib on Windows
      shell: cmd
      if: ${{ runner.os == 'Windows' }}
      run: |
        tar -xf "zlib-${{ env.WINDOWS_ZLIB_VERSION }}.tar.gz"
        IF "${{ matrix.luaVersion }}"=="luajit" (
          SET CMAKE_GENERATOR=MinGW Makefiles
        ) ELSE IF "${{ matrix.luaVersion }}"=="luajit-openresty" (
          SET CMAKE_GENERATOR=MinGW Makefiles
        ) ELSE (
          SET CMAKE_GENERATOR=NMake Makefiles
        )
        cmake ^
          -G "%CMAKE_GENERATOR%" ^
          -DCMAKE_BUILD_TYPE=Release ^
          -DBUILD_SHARED_LIBS=ON ^
          --install-prefix "${{ env.LUAROCKS_WINDOWS_DEPS_DIR }}" ^
          -S "zlib-${{ env.WINDOWS_ZLIB_VERSION }}" ^
          -B build-zlib && ^
        cmake --build build-zlib --config Release && ^
        cmake --install build-zlib --config Release
        echo ${{ env.LUAROCKS_WINDOWS_DEPS_DIR }}\bin>>${{ github.path }}
    - name: Lint rockspec
      run: luarocks lint lua-zlib-scm-0.rockspec
    - name: Build & install
      run: luarocks make lua-zlib-scm-0.rockspec
    - name: Run tests
      run: lua test.lua

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions