[luajit] Improve static and dynamic CRT support (#8929)

* [luajit] Improve static and dynamic CRT support

* [luajit] fix CRT linkage always static

* [luajit] Fix luajit.exe static build failure

* [luajit] Remove old patch

* [luajit] Remove old patch

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
This commit is contained in:
Rémy Tassoux 2020-02-14 02:48:46 +01:00 committed by GitHub
parent c819b7f6bf
commit 76fba5ec78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 165 additions and 154 deletions

View File

@ -1,5 +1,5 @@
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index 6f64a49..ba77cd5 100644 index 42e3652..6a889e1 100644
--- a/src/msvcbuild.bat --- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat +++ b/src/msvcbuild.bat
@@ -14,17 +14,18 @@ @@ -14,17 +14,18 @@
@ -38,7 +38,7 @@ index 6f64a49..ba77cd5 100644
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
%LJLINK% /out:buildvm.exe buildvm*.obj %LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
@@ -50,30 +51,30 @@ if exist buildvm.exe.manifest^ @@ -50,39 +51,39 @@ if exist buildvm.exe.manifest^
buildvm -m peobj -o lj_vm.obj buildvm -m peobj -o lj_vm.obj
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
@ -67,23 +67,18 @@ index 6f64a49..ba77cd5 100644
@shift @shift
@set LJCOMPILE=%LJCOMPILE% /Zi @set LJCOMPILE=%LJCOMPILE% /Zi
-@set LJLINK=%LJLINK% /debug -@set LJLINK=%LJLINK% /debug
@set DEBUG=1
:NODEBUG :NODEBUG
-@if "%1"=="amalg" goto :AMALGDLL -@if "%1"=="amalg" goto :AMALGDLL
-@if "%1"=="static" goto :STATIC -@if "%1"=="static" goto :STATIC
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+@if "%2"=="amalg" goto :AMALGDLL +@if "%2"=="amalg" goto :AMALGDLL
+@if "%2"=="static" goto :STATIC +@if "%2"=="static" goto :STATIC
@if "%DEBUG%"=="1" set LJCOMPILE=%LJCOMPILE% /MDd +%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
@if "%DEBUG%"=="" set LJCOMPILE=%LJCOMPILE% /MD
-%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+%LJCOMPILE% /DLUA_BUILD_AS_DLL %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj %LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
@@ -81,13 +82,13 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c @goto :MTDLL
:STATIC :STATIC
@if "%DEBUG%"=="1" set LJCOMPILE=%LJCOMPILE% /MTd
@if "%DEBUG%"=="" set LJCOMPILE=%LJCOMPILE% /MT
-%LJCOMPILE% lj_*.c lib_*.c -%LJCOMPILE% lj_*.c lib_*.c
+%LJCOMPILE% %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb +%LJCOMPILE% %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
@ -96,7 +91,7 @@ index 6f64a49..ba77cd5 100644
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj %LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
@@ -95,7 +96,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c @@ -90,7 +91,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
if exist %LJDLLNAME%.manifest^ if exist %LJDLLNAME%.manifest^
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2 %LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2
@ -105,7 +100,7 @@ index 6f64a49..ba77cd5 100644
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME% %LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
@@ -103,8 +104,8 @@ if exist luajit.exe.manifest^ @@ -98,8 +99,8 @@ if exist luajit.exe.manifest^
%LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
@del *.obj *.manifest minilua.exe buildvm.exe @del *.obj *.manifest minilua.exe buildvm.exe
@ -116,7 +111,7 @@ index 6f64a49..ba77cd5 100644
@echo. @echo.
@echo === Successfully built LuaJIT for Windows/%LJARCH% === @echo === Successfully built LuaJIT for Windows/%LJARCH% ===
@@ -117,4 +118,5 @@ if exist luajit.exe.manifest^ @@ -112,4 +113,5 @@ if exist luajit.exe.manifest^
@goto :END @goto :END
:FAIL :FAIL
@echo You must open a "Visual Studio .NET Command Prompt" to run this script @echo You must open a "Visual Studio .NET Command Prompt" to run this script

View File

@ -1,26 +0,0 @@
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index bd0c4c5..95e1cf4 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -67,15 +67,20 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
@shift
@set LJCOMPILE=%LJCOMPILE% /Zi
@set LJLINK=%LJLINK% /debug
+@set DEBUG=1
:NODEBUG
@if "%1"=="amalg" goto :AMALGDLL
@if "%1"=="static" goto :STATIC
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+@if "%DEBUG%"=="1" set LJCOMPILE=%LJCOMPILE% /MDd
+@if "%DEBUG%"=="" set LJCOMPILE=%LJCOMPILE% /MD
+%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:STATIC
+@if "%DEBUG%"=="1" set LJCOMPILE=%LJCOMPILE% /MTd
+@if "%DEBUG%"=="" set LJCOMPILE=%LJCOMPILE% /MT
%LJCOMPILE% lj_*.c lib_*.c
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj

View File

@ -0,0 +1,42 @@
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index 6a889e1..08c4e3c 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -64,20 +64,23 @@ buildvm -m vmdef -o %SOURCEDIR%\jit\vmdef.lua %ALL_LIB%
buildvm -m folddef -o %SOURCEDIR%\lj_folddef.h %SOURCEDIR%\lj_opt_fold.c
@if errorlevel 1 goto :BAD
+@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 LJCOMPILE=%LJCOMPILE% /Zi
+@set CRT_LINKAGE=%CRT_LINKAGE%d
:NODEBUG
-@if "%2"=="amalg" goto :AMALGDLL
+@if "%3"=="amalg" goto :AMALGDLL
-@if "%2"=="static" goto :STATIC
+@if "%3"=="static" goto :STATIC
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
+%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% %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
@@ -94,7 +94,7 @@
if exist %LJDLLNAME%.manifest^
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2
-%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

View File

@ -7,8 +7,8 @@ vcpkg_from_github(
SHA512 65d982d7fe532a61335613f414f3b8fa5333747bdf7aefc2c2d52022d227594ade827639049b97e3c4ffae9f38f32cb15f1a17b1780fb0a943e1a3af05e2b576 SHA512 65d982d7fe532a61335613f414f3b8fa5333747bdf7aefc2c2d52022d227594ade827639049b97e3c4ffae9f38f32cb15f1a17b1780fb0a943e1a3af05e2b576
HEAD_REF master HEAD_REF master
PATCHES PATCHES
001-fixStaticBuild.patch 001-fix-build-path.patch
002-fix-build-path.patch 002-fix-crt-linkage.patch
) )
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
@ -24,7 +24,7 @@ if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL debug)
vcpkg_execute_required_process_repeat( vcpkg_execute_required_process_repeat(
COUNT 1 COUNT 1
COMMAND "${SOURCE_PATH}/src/msvcbuild.bat" ${SOURCE_PATH}/src debug ${LJIT_STATIC} COMMAND "${SOURCE_PATH}/src/msvcbuild.bat" ${SOURCE_PATH}/src ${VCPKG_CRT_LINKAGE} debug ${LJIT_STATIC}
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"
LOGNAME build-${TARGET_TRIPLET}-dbg LOGNAME build-${TARGET_TRIPLET}-dbg
) )
@ -47,7 +47,7 @@ if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL release)
vcpkg_execute_required_process_repeat(d8un vcpkg_execute_required_process_repeat(d8un
COUNT 1 COUNT 1
COMMAND "${SOURCE_PATH}/src/msvcbuild.bat" ${SOURCE_PATH}/src ${LJIT_STATIC} COMMAND "${SOURCE_PATH}/src/msvcbuild.bat" ${SOURCE_PATH}/src ${VCPKG_CRT_LINKAGE} ${LJIT_STATIC}
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
LOGNAME build-${TARGET_TRIPLET}-rel LOGNAME build-${TARGET_TRIPLET}-rel
) )