Skip to content

Commit 9afb76f

Browse files
committed
feat: patch LuaJIT to use UTF-8 internally
This patch to the vendored LuaJIT build changes much of the internal machinery to use UTF-8 for paths, using W-style Windows API functions and _w-type CRT functions with UTF-16LE wchar_t transcoding internally to UTF-8 at the edge. This also patches several functions exposed to Lua like `os.getenv`, `os.remove`, `os.rename`, `os.system`, `os.tmpnam` as well as `io.open`.
1 parent 3499b3d commit 9afb76f

File tree

13 files changed

+501
-37
lines changed

13 files changed

+501
-37
lines changed

vcpkg-configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"kind": "filesystem",
99
"path": "vcpkg-ports",
10-
"baseline": "2024-03-26",
10+
"baseline": "2025-01-19",
1111
"packages": ["glfw3", "luajit"]
1212
}
1313
]

vcpkg-ports/ports/luajit/2023-04-16/msvcbuild.patch

Lines changed: 0 additions & 31 deletions
This file was deleted.

vcpkg-ports/ports/luajit/2023-04-16/003-do-not-set-macosx-deployment-target.patch renamed to vcpkg-ports/ports/luajit/2023-04-16_1/003-do-not-set-macosx-deployment-target.patch

File renamed without changes.

vcpkg-ports/ports/luajit/2023-04-16/005-do-not-pass-ld-e-macosx.patch renamed to vcpkg-ports/ports/luajit/2023-04-16_1/005-do-not-pass-ld-e-macosx.patch

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
From 63a98f283b12265b722b4a7e0cd87d0e527a38f9 Mon Sep 17 00:00:00 2001
2+
From: Lars Viklund <[email protected]>
3+
Date: Mon, 8 Apr 2024 01:03:43 +0200
4+
Subject: [PATCH] feat: output PDBs for the library and apply LTCG
5+
6+
---
7+
src/msvcbuild.bat | 16 ++++++++--------
8+
1 file changed, 8 insertions(+), 8 deletions(-)
9+
10+
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
11+
index 045965f8..ac85da80 100644
12+
--- a/src/msvcbuild.bat
13+
+++ b/src/msvcbuild.bat
14+
@@ -13,9 +13,9 @@
15+
16+
@setlocal
17+
@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_APICHECK
18+
-@set DEBUGCFLAGS=
19+
-@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
20+
-@set LJLINK=link /nologo
21+
+@set DEBUGCFLAGS=/Od
22+
+@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline /Z7 /GL
23+
+@set LJLINK=link /nologo /LTCG
24+
@set LJMT=mt /nologo
25+
@set LJLIB=lib /nologo /nodefaultlib
26+
@set DASMDIR=..\dynasm
27+
@@ -67,14 +67,13 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
28+
@if "%1" neq "debug" goto :NODEBUG
29+
@shift
30+
@set BUILDTYPE=debug
31+
-@set LJCOMPILE=%LJCOMPILE% /Zi %DEBUGCFLAGS%
32+
+@set LJCOMPILE=%LJCOMPILE% /Z7 %DEBUGCFLAGS%
33+
:NODEBUG
34+
-@set LJLINK=%LJLINK% /%BUILDTYPE%
35+
@if "%1"=="amalg" goto :AMALGDLL
36+
@if "%1"=="static" goto :STATIC
37+
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
38+
+%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c /Fdlua51.pdb
39+
@if errorlevel 1 goto :BAD
40+
-%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
41+
+%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj /DEBUG /OPT:ICF /OPT:REF
42+
@if errorlevel 1 goto :BAD
43+
@goto :MTDLL
44+
:STATIC
45+
@@ -92,7 +91,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
46+
if exist %LJDLLNAME%.manifest^
47+
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2
48+
49+
-%LJCOMPILE% luajit.c
50+
+%LJCOMPILE% luajit.c /Fdluajit.pdb
51+
@if errorlevel 1 goto :BAD
52+
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
53+
@if errorlevel 1 goto :BAD
54+
@@ -114,4 +113,5 @@ if exist luajit.exe.manifest^
55+
@goto :END
56+
:FAIL
57+
@echo You must open a "Visual Studio Command Prompt" to run this script
58+
+exit 1
59+
:END
60+
--
61+
2.42.0.windows.2
62+

0 commit comments

Comments
 (0)