Skip to content

Commit

Permalink
[luajit] Fix build failure that resulted in no output. (#26360)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal committed Aug 16, 2022
1 parent 5f83f03 commit acc3bcf
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 70 deletions.
44 changes: 0 additions & 44 deletions ports/luajit/002-fix-crt-linkage.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index aab4ef1..ff9df57 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -15,19 +15,20 @@
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index d323d8d..6e61150 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -15,19 +15,20 @@
@setlocal
@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_APICHECK
@set DEBUGCFLAGS=
Expand All @@ -15,28 +15,45 @@ index aab4ef1..ff9df57 100644
-@set DASMDIR=..\dynasm
+@set DASMDIR=%SOURCEDIR%\..\dynasm
@set DASM=%DASMDIR%\dynasm.lua
@set DASC=vm_x64.dasc
-@set DASC=vm_x64.dasc
+@set DASC=%SOURCEDIR%\vm_x64.dasc
@set LJDLLNAME=lua51.dll
@set LJLIBNAME=lua51.lib
@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
+@set ALL_LIB=%SOURCEDIR%\lib_base.c %SOURCEDIR%\lib_math.c %SOURCEDIR%\lib_bit.c %SOURCEDIR%\lib_string.c %SOURCEDIR%\lib_table.c %SOURCEDIR%\lib_io.c %SOURCEDIR%\lib_os.c %SOURCEDIR%\lib_package.c %SOURCEDIR%\lib_debug.c %SOURCEDIR%\lib_jit.c %SOURCEDIR%\lib_ffi.c
+@set ALL_LIB=%SOURCEDIR%\lib_base.c %SOURCEDIR%\lib_math.c %SOURCEDIR%\lib_bit.c %SOURCEDIR%\lib_string.c %SOURCEDIR%\lib_table.c %SOURCEDIR%\lib_io.c %SOURCEDIR%\lib_os.c %SOURCEDIR%\lib_package.c %SOURCEDIR%\lib_debug.c %SOURCEDIR%\lib_jit.c %SOURCEDIR%\lib_ffi.c %SOURCEDIR%\lib_buffer.c

-%LJCOMPILE% host\minilua.c
+%LJCOMPILE% %SOURCEDIR%\host\minilua.c /Fdminilua.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:minilua.exe minilua.obj
@if errorlevel 1 goto :BAD
@@ -51,7 +52,7 @@ if exist minilua.exe.manifest^
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
@@ -38,20 +39,20 @@ if exist minilua.exe.manifest^
@set LJARCH=x64
@minilua
@if errorlevel 8 goto :X64
-@set DASC=vm_x86.dasc
+@set DASC=%SOURCEDIR%\vm_x86.dasc
@set DASMFLAGS=-D WIN -D JIT -D FFI
@set LJARCH=x86
@set LJCOMPILE=%LJCOMPILE% /arch:SSE2
:X64
@if "%1" neq "nogc64" goto :GC64
@shift
-@set DASC=vm_x86.dasc
+@set DASC=%SOURCEDIR%\vm_x86.dasc
@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_DISABLE_GC64
:GC64
-minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
+minilua %DASM% -LN %DASMFLAGS% -o %SOURCEDIR%\host\buildvm_arch.h %DASC%
@if errorlevel 1 goto :BAD

-%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
+%LJCOMPILE% /I "." /I %DASMDIR% %SOURCEDIR%\host\buildvm*.c /Fdbuildvm.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD
@@ -60,41 +61,41 @@ if exist buildvm.exe.manifest^
@@ -60,41 +61,44 @@ if exist buildvm.exe.manifest^

buildvm -m peobj -o lj_vm.obj
@if errorlevel 1 goto :BAD
Expand All @@ -60,27 +77,30 @@ index aab4ef1..ff9df57 100644
@if errorlevel 1 goto :BAD

-@if "%1" neq "debug" goto :NODEBUG
+@if "%2"=="static" set CRT_LINKAGE=/MT
+@if "%2"=="dynamic" set CRT_LINKAGE=/MD
+@set LJLINK=%LJLINK% /debug
+@if "%2" neq "debug" goto :NODEBUG
+@if "%3" neq "debug" goto :NODEBUG
@shift
@set BUILDTYPE=debug
@set LJCOMPILE=%LJCOMPILE% /Zi %DEBUGCFLAGS%
-@set LJLINK=%LJLINK% /opt:ref /opt:icf /incremental:no
+@set CRT_LINKAGE=%CRT_LINKAGE%d
:NODEBUG
@set LJLINK=%LJLINK% /%BUILDTYPE%
-@if "%1"=="amalg" goto :AMALGDLL
-@if "%1"=="static" goto :STATIC
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+@if "%2"=="amalg" goto :AMALGDLL
+@if "%2"=="static" goto :STATIC
+%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
+@if "%3"=="amalg" goto :AMALGDLL
+@if "%3"=="static" goto :STATIC
+%LJCOMPILE% %CRT_LINKAGE% /DLUA_BUILD_AS_DLL %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:STATIC
-%LJCOMPILE% lj_*.c lib_*.c
+%LJCOMPILE% %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
+%LJCOMPILE% %CRT_LINKAGE% %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
Expand All @@ -91,16 +111,16 @@ index aab4ef1..ff9df57 100644
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD
@@ -102,7 +103,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
@@ -102,7 +106,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
if exist %LJDLLNAME%.manifest^
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2

-%LJCOMPILE% luajit.c
+%LJCOMPILE% %SOURCEDIR%\luajit.c /Fdluajit.pdb
+%LJCOMPILE% %CRT_LINKAGE% %SOURCEDIR%\luajit.c /Fdluajit.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
@if errorlevel 1 goto :BAD
@@ -110,8 +111,8 @@ if exist luajit.exe.manifest^
@@ -110,8 +114,8 @@ if exist luajit.exe.manifest^
%LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe

@del *.obj *.manifest minilua.exe buildvm.exe
Expand All @@ -111,7 +131,7 @@ index aab4ef1..ff9df57 100644
@echo.
@echo === Successfully built LuaJIT for Windows/%LJARCH% ===

@@ -124,4 +125,5 @@ if exist luajit.exe.manifest^
@@ -124,4 +128,5 @@ if exist luajit.exe.manifest^
@goto :END
:FAIL
@echo You must open a "Visual Studio Command Prompt" to run this script
Expand Down
23 changes: 17 additions & 6 deletions ports/luajit/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ vcpkg_from_github(
SHA512 0a1d79ab7d2de6894bcff33309e015fdba0ea67cf0425d75b9301a30006039e81b527178dbb3485e1adea177ffe062e6fcef74307f8e725678e70562d57d1a5b
HEAD_REF master
PATCHES
001-fix-build-path.patch
002-fix-crt-linkage.patch
003-do-not-set-macosx-deployment-target.patch
004-fix-build-path-and-crt-linkage.patch
)

if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
Expand All @@ -29,9 +28,17 @@ if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL debug)
LOGNAME build-${TARGET_TRIPLET}-dbg
)

file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/minilua.exe" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/tools")
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/minilua.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
# Note that luajit's build system responds to failure by producing no output; in particular a likely outcome is
# only 'minilua.exe' being produced. This reuslted in:
# https://github.com/microsoft/vcpkg/pull/25856#issuecomment-1214285736
# Please ensure luajit.exe is actually produced when making future changes.
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/luajit.exe" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/tools")
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/lua51.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")

if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/lua51.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(COPY "${CURRENT_PACKAGES_DIR}/debug/bin/lua51.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/tools")
endif()
vcpkg_copy_pdbs()
else()
vcpkg_execute_build_process(
Expand Down Expand Up @@ -64,9 +71,13 @@ if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL release)
LOGNAME build-${TARGET_TRIPLET}-rel
)

file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/minilua.exe" DESTINATION "${CURRENT_PACKAGES_DIR}/tools")
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/minilua.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/luajit.exe" DESTINATION "${CURRENT_PACKAGES_DIR}/tools")
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/lua51.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")

if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/lua51.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools)
endif()
vcpkg_copy_pdbs()
else()
vcpkg_execute_build_process(
Expand Down
1 change: 1 addition & 0 deletions ports/luajit/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "luajit",
"version-date": "2022-08-11",
"port-version": 1,
"description": "LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.",
"homepage": "https://github.com/LuaJIT/LuaJIT",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4398,7 +4398,7 @@
},
"luajit": {
"baseline": "2022-08-11",
"port-version": 0
"port-version": 1
},
"luasec": {
"baseline": "1.1.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/luajit.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "bacc33ec723d7fc2b895a1351a2042c5c6fb6971",
"version-date": "2022-08-11",
"port-version": 1
},
{
"git-tree": "4c2d21d9bf0e5cedc0f7540a7e473c2e86f2c5ef",
"version-date": "2022-08-11",
Expand Down

0 comments on commit acc3bcf

Please sign in to comment.