mlua-rs/rlua

problem on building on windows

emuvi opened this issue · 6 comments

emuvi commented

After updating to the version 0.19 an CI building on windows reported the error:

error: failed to run custom build command for rlua-lua54-sys v0.1.0

Caused by:
process didn't exit successfully: D:\a\liz\liz\target\release\build\rlua-lua54-sys-b5bff5f28ee27264\build-script-build (exit code: 101)
--- stdout
TARGET = Some("x86_64-pc-windows-msvc")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-pc-windows-msvc")
CC_x86_64-pc-windows-msvc = None
CC_x86_64_pc_windows_msvc = None
HOST_CC = None
CC = None
CFLAGS_x86_64-pc-windows-msvc = None
CFLAGS_x86_64_pc_windows_msvc = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
DEBUG = Some("false")

--- stderr
thread 'main' panicked at 'Unable to find libclang: "the libclang shared library at C:\msys64\mingw64\bin\libclang.dll could not be opened: LoadLibraryExW failed"', C:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\bindgen-0.59.2\src/lib.rs:2144:31
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

Apparently now is needed libclang of msys to build on windows.

This looks weird.

Hi,
The reason libclang is needed is because bindgen is now used to generate the low level FFI bindings to Lua.

I think on balance it would be better to check in the generated bindings rather than generate them at build time (assuming they're portable enough), especially on platforms like Windows.

Thanks for the report!

emuvi commented

What is even more weird is that supposedly the GitHub windows-latest image has msys with clang installed.

So it should work. I guess.

The particular CI is this one:

https://github.com/emuvi/liz/blob/master/.github/workflows/release.yml

I've opened #245 to cover checking in the bindings so that bindgen isn't needed as a build dependency, and considering the bug here to be that we don't test Windows in CI.

As a work in progress, here's an experimental Windows CI build, which fails at the clang/libclang point:
https://app.circleci.com/pipelines/github/amethyst/rlua/171/workflows/61241911-2439-44de-a504-d30ea2fbb3ac/jobs/338

emuvi commented

I've been thinking about this issue. Is a good practice to regenerate all the bindings on each build? I really don't know.

I think there's some risk in general that the bindgen output might be different on different platforms, so it would in that sense be safer to run it at build time. However I think it should be fine in Lua's case, as it's a fairly portable library (and which expects to be ABI compatible across patch releases at least) - it's what we were doing before using bindgen to generate the files.

I've both added the Windows CI builder and moved to prebuilt bindgen bindings, and released v0.19.1. Let me know if there are further issues!