Windows/ARM64: Add MSVC cross-build support for x64 to ARM64.

Thanks to invertego. #1081
This commit is contained in:
Mike Pall 2023-09-17 10:44:04 +02:00
parent 7a2b83a0c5
commit e897c5743f
2 changed files with 17 additions and 1 deletions

View File

@ -214,6 +214,9 @@ msvcbuild
Check the <tt>msvcbuild.bat</tt> file for more options. Check the <tt>msvcbuild.bat</tt> file for more options.
Then follow the installation instructions below. Then follow the installation instructions below.
</p> </p>
<p>
For an x64 to ARM64 cross-build run this first: <tt>vcvarsall.bat x64_arm64</tt>
</p>
<h3>Building with MinGW or Cygwin</h3> <h3>Building with MinGW or Cygwin</h3>
<p> <p>
Open a command prompt window and make sure the MinGW or Cygwin programs Open a command prompt window and make sure the MinGW or Cygwin programs

View File

@ -27,12 +27,15 @@
@set BUILDTYPE=release @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=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 %LJCOMPILE% host\minilua.c
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
%LJLINK% /out:minilua.exe minilua.obj %LJLINK% /out:minilua.exe minilua.obj
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
if exist minilua.exe.manifest^ if exist minilua.exe.manifest^
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
@endlocal
@set DASMFLAGS=-D WIN -D JIT -D FFI -D ENDIAN_LE -D FPU -D P64 @set DASMFLAGS=-D WIN -D JIT -D FFI -D ENDIAN_LE -D FPU -D P64
@set LJARCH=x64 @set LJARCH=x64
@ -46,6 +49,7 @@ if exist minilua.exe.manifest^
:NO32 :NO32
@if "%VSCMD_ARG_TGT_ARCH%" neq "arm64" goto :X64 @if "%VSCMD_ARG_TGT_ARCH%" neq "arm64" goto :X64
@set DASC=vm_arm64.dasc @set DASC=vm_arm64.dasc
@set DASMTARGET=-D LUAJIT_TARGET=LUAJIT_ARCH_ARM64
@set LJARCH=arm64 @set LJARCH=arm64
@goto :DA @goto :DA
:X64 :X64
@ -60,12 +64,15 @@ minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
if exist ..\.git ( git show -s --format=%%ct >luajit_relver.txt ) else ( type ..\.relver >luajit_relver.txt ) if exist ..\.git ( git show -s --format=%%ct >luajit_relver.txt ) else ( type ..\.relver >luajit_relver.txt )
minilua host\genversion.lua minilua host\genversion.lua
%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c @setlocal
@call :SETHOSTVARS
%LJCOMPILE% /I "." /I %DASMDIR% %DASMTARGET% host\buildvm*.c
@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
if exist buildvm.exe.manifest^ if exist buildvm.exe.manifest^
%LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
@endlocal
buildvm -m peobj -o lj_vm.obj buildvm -m peobj -o lj_vm.obj
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
@ -124,6 +131,12 @@ if exist luajit.exe.manifest^
@echo. @echo.
@echo === Successfully built LuaJIT for Windows/%LJARCH% === @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 @goto :END
:BAD :BAD
@echo. @echo.