From 7395cf0d5360e78e511825b4b5a82b3cc50b4905 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Thu, 6 Apr 2023 11:16:14 +0200 Subject: [PATCH 1/2] fix: Disable 64bit GC --- build.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.rs b/build.rs index 11b3984..2f5fc48 100644 --- a/build.rs +++ b/build.rs @@ -90,6 +90,12 @@ fn build_gcc(src_dir: &str) { buildcmd.stderr(Stdio::inherit()); buildcmd.arg("--no-silent"); + // This became enabled by default in https://github.com/LuaJIT/LuaJIT/commit/bd00094c3b50e193fb32aad79b7ea8ea6b78ed25 + // but changes the generated bytecode. Bitsquid does not have it currently. + // The documentation changes in the commit mention that the bytecode change might be "rectified" + // in the future, though. + buildcmd.arg("XCFLAGS=-DLUAJIT_DISABLE_GC64"); + // We do need to cross-compile even here, so that `lj_vm.o` is created // for the correct architecture. if env::var("CARGO_CFG_WINDOWS").is_ok() { From 24da35e631099e914d6fc1bcc863228c48e540ec Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Sun, 9 Apr 2023 12:21:29 +0200 Subject: [PATCH 2/2] fix: Fix LuaJIT on Windows It turned out that with disabling GC64, LuaJIT would immediately overflow the stack when opening a Lua state. For now, this reverts to a version from 2019 that works, but I highly doubt that LuaJIT woould have been broken on Windows for years. I'll have to investigate, or rather trial-and-error further. --- build.rs | 12 +----------- luajit | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/build.rs b/build.rs index 2f5fc48..6e7e5a4 100644 --- a/build.rs +++ b/build.rs @@ -7,12 +7,11 @@ use std::process::{Command, Stdio}; const LIB_NAME: &str = "luajit"; const LUAJIT_HEADERS: [&str; 4] = ["lua.h", "lualib.h", "lauxlib.h", "luajit.h"]; -const LUAJIT_SRC: [&str; 69] = [ +const LUAJIT_SRC: [&str; 65] = [ // LJCORE_O // The MSVC toolchain cannot compile this assembler file, // as it contains GNU-specific directives // "lj_vm.S", - "lj_assert.c", "lj_gc.c", "lj_err.c", "lj_char.c", @@ -25,7 +24,6 @@ const LUAJIT_SRC: [&str; 69] = [ "lj_udata.c", "lj_meta.c", "lj_debug.c", - "lj_prng.c", "lj_state.c", "lj_dispatch.c", "lj_vmevent.c", @@ -33,7 +31,6 @@ const LUAJIT_SRC: [&str; 69] = [ "lj_strscan.c", "lj_strfmt.c", "lj_strfmt_num.c", - "lj_serialize.c", "lj_api.c", "lj_profile.c", "lj_lex.c", @@ -80,7 +77,6 @@ const LUAJIT_SRC: [&str; 69] = [ "lib_debug.c", "lib_jit.c", "lib_ffi.c", - "lib_buffer.c", "lib_init.c", ]; @@ -90,12 +86,6 @@ fn build_gcc(src_dir: &str) { buildcmd.stderr(Stdio::inherit()); buildcmd.arg("--no-silent"); - // This became enabled by default in https://github.com/LuaJIT/LuaJIT/commit/bd00094c3b50e193fb32aad79b7ea8ea6b78ed25 - // but changes the generated bytecode. Bitsquid does not have it currently. - // The documentation changes in the commit mention that the bytecode change might be "rectified" - // in the future, though. - buildcmd.arg("XCFLAGS=-DLUAJIT_DISABLE_GC64"); - // We do need to cross-compile even here, so that `lj_vm.o` is created // for the correct architecture. if env::var("CARGO_CFG_WINDOWS").is_ok() { diff --git a/luajit b/luajit index 505e2c0..70f4b15 160000 --- a/luajit +++ b/luajit @@ -1 +1 @@ -Subproject commit 505e2c03de35e2718eef0d2d3660712e06dadf1f +Subproject commit 70f4b15ee45a6137fe6b48b941faea79d72f7159