Skip to content

Commit

Permalink
Switch to vanilla LuaJIT 2.1 (Mike Pall's)
Browse files Browse the repository at this point in the history
  • Loading branch information
khvzak committed Sep 26, 2023
1 parent c86fb00 commit 03387ca
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "luajit2"]
path = luajit2
url = https://github.com/openresty/luajit2
url = https://github.com/LuaJIT/LuaJIT.git
branch = v2.1
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ keywords = ["lua", "luajit"]
readme = "README.md"
license = "MIT"
description = """
Sources of LuaJIT 2.1 (OpenResty's branch) and logic to build it.
Sources of LuaJIT 2.1 and logic to build it.
"""
exclude = ["/luajit2/doc", "/luajit2/etc", "/luajit2/t"]
exclude = ["/luajit2/doc", "/luajit2/etc"]

[dependencies]
cc = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
[Build Status]: https://github.com/khvzak/luajit-src-rs/workflows/CI/badge.svg
[github-actions]: https://github.com/khvzak/luajit-src-rs/actions

This crate contains the sources of LuaJIT 2.1 (OpenResty's [branch]) and logic to build it.
This crate contains the sources of [LuaJIT] 2.1 (from Mike Pall) and logic to build it.
Intended to be consumed by the [mlua-sys] crate.

[branch]: https://github.com/openresty/luajit2
[LuaJIT]: https://github.com/LuaJIT/LuaJIT
[mlua-sys]: https://crates.io/crates/mlua-sys

# License
Expand Down
36 changes: 29 additions & 7 deletions extras/msvcbuild.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@rem Script to build LuaJIT with MSVC.
@rem Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h
@rem Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
@rem
@rem Open a "Visual Studio Command Prompt" (either x86 or x64).
@rem Then cd to this directory and run this script. Use the following
Expand Down Expand Up @@ -28,27 +28,37 @@
@set BUILDTYPE=release
@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c lib_buffer.c

@setlocal
@call :SETHOSTVARS
%LJCOMPILE% host\minilua.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:minilua.exe minilua.obj
@if errorlevel 1 goto :BAD
if exist minilua.exe.manifest^
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
@endlocal

@set DASMFLAGS=-D WIN -D JIT -D FFI -D P64
@set DASMFLAGS=-D WIN -D JIT -D FFI -D ENDIAN_LE -D FPU -D P64
@set LJARCH=x64
@minilua
@if errorlevel 8 goto :X64
@if errorlevel 8 goto :NO32
@set DASC=vm_x86.dasc
@set DASMFLAGS=-D WIN -D JIT -D FFI
@set DASMFLAGS=-D WIN -D JIT -D FFI -D ENDIAN_LE -D FPU
@set LJARCH=x86
@set LJCOMPILE=%LJCOMPILE% /arch:SSE2
@goto :DA
:NO32
@if "%VSCMD_ARG_TGT_ARCH%" neq "arm64" goto :X64
@set DASC=vm_arm64.dasc
@set DASMTARGET=-D LUAJIT_TARGET=LUAJIT_ARCH_ARM64
@set LJARCH=arm64
@goto :DA
:X64
@if "%1" neq "nogc64" goto :GC64
@if "%1" neq "nogc64" goto :DA
@shift
@set DASC=vm_x86.dasc
@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_DISABLE_GC64
:GC64
:DA
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
@if errorlevel 1 goto :BAD

Expand All @@ -57,12 +67,18 @@ minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_ENABLE_LUA52COMPAT
:NOLUA52C

%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
if exist ..\.git ( git show -s --format=%%ct >luajit_relver.txt ) else ( type ..\.relver >luajit_relver.txt )
minilua host\genversion.lua

@setlocal
@call :SETHOSTVARS
%LJCOMPILE% /I "." /I %DASMDIR% %DASMTARGET% host\buildvm*.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD
if exist buildvm.exe.manifest^
%LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
@endlocal

buildvm -m peobj -o lj_vm.obj
@if errorlevel 1 goto :BAD
Expand Down Expand Up @@ -121,6 +137,12 @@ if exist luajit.exe.manifest^
@echo.
@echo === Successfully built LuaJIT for Windows/%LJARCH% ===

@goto :END
:SETHOSTVARS
@if "%VSCMD_ARG_HOST_ARCH%_%VSCMD_ARG_TGT_ARCH%" equ "x64_arm64" (
call "%VSINSTALLDIR%Common7\Tools\VsDevCmd.bat" -arch=%VSCMD_ARG_HOST_ARCH% -no_logo
echo on
)
@goto :END
:BAD
@echo.
Expand Down
2 changes: 1 addition & 1 deletion luajit2
Submodule luajit2 updated 249 files

0 comments on commit 03387ca

Please sign in to comment.