mlua
mlua copied to clipboard
Can't cross-compile from Linux to i686-pc-windows-gnu
c85616137a367a72367a7d3f6019a5816ee5aa7b, Fedora 35
┌ (master) ~/s/r/mlua
└─ env CFLAGS=-m32 LDFLAGS=-m32 cargo build --features=vendored,luajit --target=i686-pc-windows-gnu
Compiling proc-macro2 v1.0.36
Compiling unicode-xid v0.2.2
Compiling syn v1.0.89
Compiling serde_derive v1.0.136
Compiling cc v1.0.73
Compiling memchr v2.4.1
Compiling autocfg v1.1.0
Compiling serde v1.0.136
Compiling pkg-config v0.3.24
Compiling regex-automata v0.1.10
Compiling lazy_static v1.4.0
Compiling once_cell v1.10.0
Compiling rustc-hash v1.1.0
Compiling num-traits v0.2.14
Compiling luajit-src v210.3.3+resty673aaad
Compiling lua-src v544.0.0
Compiling quote v1.0.15
Compiling mlua v0.7.4 (/var/home/yalter/source/rs/mlua)
error: failed to run custom build command for `mlua v0.7.4 (/var/home/yalter/source/rs/mlua)`
Caused by:
process didn't exit successfully: `/var/home/yalter/source/rs/mlua/target/debug/build/mlua-1be8cf42852d931a/build-script-main` (exit status: 101)
--- stdout
CC_i686-pc-windows-gnu = None
CC_i686_pc_windows_gnu = None
TARGET_CC = None
CC = None
CROSS_COMPILE = None
CFLAGS_i686-pc-windows-gnu = None
CFLAGS_i686_pc_windows_gnu = None
TARGET_CFLAGS = None
CFLAGS = Some("-m32")
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
running "make" "-e"
CC lj_init.o
HOSTCC host/minilua.o
HOSTLINK host/minilua
DYNASM host/buildvm_arch.h
HOSTCC host/buildvm.o
HOSTCC host/buildvm_asm.o
HOSTCC host/buildvm_peobj.o
HOSTCC host/buildvm_lib.o
HOSTCC host/buildvm_fold.o
HOSTLINK host/buildvm
BUILDVM lj_vm.S
ASM lj_vm.o
--- stderr
buildvm_x86.dasc: Assembler messages:
buildvm_x86.dasc:6: Error: unknown pseudo-op: `.hidden'
buildvm_x86.dasc:7: Warning: .type pseudo-op used outside of .def/.endef: ignored.
buildvm_x86.dasc:7: Error: junk at end of line, first unrecognized character is `l'
buildvm_x86.dasc:8: Warning: .size pseudo-op used outside of .def/.endef: ignored.
buildvm_x86.dasc:8: Error: junk at end of line, first unrecognized character is `l'
buildvm_x86.dasc:13: Error: unknown pseudo-op: `.hidden'
buildvm_x86.dasc:14: Warning: .type pseudo-op used outside of .def/.endef: ignored.
buildvm_x86.dasc:14: Error: junk at end of line, first unrecognized character is `l'
buildvm_x86.dasc:15: Warning: .size pseudo-op used outside of .def/.endef: ignored.
buildvm_x86.dasc:15: Error: junk at end of line, first unrecognized character is `l'
buildvm_x86.dasc:24: Error: unknown pseudo-op: `.hidden'
buildvm_x86.dasc:25: Warning: .type pseudo-op used outside of .def/.endef: ignored.
buildvm_x86.dasc:25: Error: junk at end of line, first unrecognized character is `l'
buildvm_x86.dasc:26: Warning: .size pseudo-op used outside of .def/.endef: ignored.
buildvm_x86.dasc:26: Error: junk at end of line, first unrecognized character is `l'
(and so on)
buildvm_x86.dasc:2628: Warning: .size pseudo-op used outside of .def/.endef: ignored.
buildvm_x86.dasc:2628: Error: junk at end of line, first unrecognized character is `l'
buildvm_x86.dasc:2636: Error: junk at end of line, first unrecognized character is `-'
buildvm_x86.dasc:2639: Error: junk at end of line, first unrecognized character is `,'
buildvm_x86.dasc:2693: Error: junk at end of line, first unrecognized character is `,'
make: *** [Makefile:713: lj_vm.o] Error 1
thread 'main' panicked at '
Error building LuaJIT:
Command: "make" "-e"
Exit status: exit status: 2
', /var/home/yalter/.cargo/registry/src/github.com-1ecc6299db9ec823/luajit-src-210.3.3+resty673aaad/src/lib.rs:200:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
Without -m32
is fails even earlier for some reason.
mlua uses LuaJIT build system. Can you reproduce this issue when compiling https://github.com/LuaJIT/LuaJIT v2.1 branch ? If yes, could you submit a bug report to LuaJIT please.
According to LuaJIT's cross-compiling docs for this configuration you need to set TARGET_SYS=Windows
. Compiling on my system using make HOST_CC="gcc -m32" CROSS=i686-w64-mingw32- TARGET_SYS=Windows
worked fine, while compiling without TARGET_SYS=Windows
resulted in the same errors as in this issue. I'm guessing luajit-src-rs needs to add TARGET_SYS=Windows
when cross-compiling to Windows.
FYI, even cross-compiling to 32-bit Linux doesn't work automatically in luajit-src-rs at the moment: you need to specify -m32
in CFLAGS
and LDFLAGS
manually. Would be nice if that worked out of the box too.
I seem to have fixed the TARGET_OS=Windows
problem in the above PR; the 32-bit problem seems to run a bit deeper.
-
cc
returnsi686-linux-gnu-gcc
as the compiler, which is valid on Ubuntu but not on Fedora, so that needs to be figured out somehow - LuaJIT's docs recommend setting
-m32
onCC
and/orHOST_CC
directly, which requires knowing a valid compiler, see 1.
I guess I'll just keep manually setting those variables for now, works well enough.
Thanks, I'll try fix it (check your PR) before releasing 0.8.0 (non-beta)
Can confirm this helps. Though, I'm compiling to x86_64
. Currently just setting it through an environment variable as a workaround (together with TARGET_CC
, TARGET_AR
and TARGET_LD
).
It should be fixed in the new luajit-src 210.4.6+resty2cf5186