Skip to content

Commit

Permalink
add windows arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
jem-patel committed Nov 17, 2022
1 parent e38c658 commit bbcf113
Show file tree
Hide file tree
Showing 68 changed files with 3,093 additions and 92 deletions.
14 changes: 14 additions & 0 deletions .yamato/Build Windows ARM64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Build Windows ARM64

agent:
type: Unity::VM
image: platform-foundation/windows-vs2019-il2cpp-bokken:stable
flavor: b1.xlarge

commands:
- .yamato/scripts/build_win_arm64.bat

artifacts:
win-arm64:
paths:
- incomingbuilds\win-arm64\**
1 change: 1 addition & 0 deletions .yamato/Collate Builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
- .yamato/Build Runtime OSX.yml
- .yamato/Build Windows x64.yml
- .yamato/Build Windows x86.yml
- .yamato/Build Windows ARM64.yml

commands:
- .yamato/scripts/collate_builds.sh
Expand Down
12 changes: 12 additions & 0 deletions .yamato/scripts/build_win_arm64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo off
git submodule update --init --recursive

perl external/buildscripts/build_runtime_win_arm64.pl --stevedorebuilddeps=1
if NOT %errorlevel% == 0 (
echo "mono build script failed"
EXIT /B %errorlevel%
)
echo "mono build script ran successfully"

md incomingbuilds\win-arm64
xcopy /s /e /h /y builds\* incomingbuilds\win-arm64
15 changes: 7 additions & 8 deletions external/buildscripts/build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1351,14 +1351,13 @@
{
if ($^O eq "cygwin")
{
system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--clean=$clean", "--debug=$debug") eq 0 or die ('failed building mono with VS\n');
system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--targetArch=$targetArch", "--clean=$clean", "--debug=$debug") eq 0 or die ('failed building mono with VS\n');

# Copy over the VS built stuff that we want to use instead into the prefix directory
my $archNameForBuild = $arch32 ? 'Win32' : 'x64';
my $config = $debug ? "Debug" : "Release";
system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono.exe $monoprefix/bin/.") eq 0 or die ("failed copying mono.exe\n");
system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.dll $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.dll\n");
system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.pdb $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.pdb\n");
system("cp $monoroot/msvc/$targetArch/bin/$config/mono.exe $monoprefix/bin/.") eq 0 or die ("failed copying mono.exe\n");
system("cp $monoroot/msvc/$targetArch/bin/$config/mono-2.0.dll $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.dll\n");
system("cp $monoroot/msvc/$targetArch/bin/$config/mono-2.0.pdb $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.pdb\n");
}

system("cp -R $addtoresultsdistdir/bin/. $monoprefix/bin/") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n");
Expand Down Expand Up @@ -1536,9 +1535,9 @@
}
else
{
$embedDirArchDestination = $arch32 ? "$embedDirRoot/win32" : "$embedDirRoot/win64";
$distDirArchBin = $arch32 ? "$distdir/bin" : "$distdir/bin-x64";
$versionsOutputFile = $arch32 ? "$buildsroot/versions-win32.txt" : "$buildsroot/versions-win64.txt";
$embedDirArchDestination = "$embedDirRoot/$targetArch";
$distDirArchBin = $targetArch;
$versionsOutputFile = "$buildsroot/versions-$targetArch.txt"
}

# Make sure the directory for our architecture is clean before we copy stuff into it
Expand Down
7 changes: 5 additions & 2 deletions external/buildscripts/build_all_win.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
}

print(">>> Building i686\n");
system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building win32');
system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--clean=1", "--classlibtests=0", "--targetarch=Win32", @passAlongArgs) eq 0 or die ('failing building win32');

print(">>> Building x86_64\n");
system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x64');
system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--clean=1", "--classlibtests=0", "--targetarch=x64", @passAlongArgs) eq 0 or die ('failing building x64');

print(">>> Building ARM64\n");
system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--clean=1", "--classlibtests=0", "--targetarch=ARM64", @passAlongArgs) eq 0 or die ('failing building ARM64');
7 changes: 4 additions & 3 deletions external/buildscripts/build_runtime_vs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

my $build = 0;
my $clean = 0;
my $arch32 = 0;
my $targetArch = "";
my $debug = 0;
my $gc = "bdwgc";

GetOptions(
'build=i'=>\$build,
'clean=i'=>\$clean,
'arch32=i'=>\$arch32,
'targetarch=s'=>\$targetArch,
'debug=i'=>\$debug,
'gc=s'=>\$gc,
) or die ("illegal cmdline options");
Expand All @@ -49,7 +49,8 @@ sub CompileVCProj
}

$config = $debug ? "Debug" : "Release";
my $arch = $arch32 ? "Win32" : "x64";
my $arch = $targetArch;

my $target = $clean ? "/t:Clean,Build" :"/t:Build";
my $properties = "/p:Configuration=$config;Platform=$arch;MONO_TARGET_GC=$gc;MONO_USE_STATIC_C_RUNTIME=true";

Expand Down
2 changes: 1 addition & 1 deletion external/buildscripts/build_runtime_win.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out
#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=1", "--classlibtests=0", "--forcedefaultbuilddeps=1", "--stevedorebuilddeps=$stevedoreBuildDeps") eq 0 or die ("Failed building mono\n");

system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--forcedefaultbuilddeps=1", "--stevedorebuilddeps=$stevedoreBuildDeps") eq 0 or die ("Failed building mono\n");
system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--targetarch=Win32", "--forcedefaultbuilddeps=1", "--stevedorebuilddeps=$stevedoreBuildDeps") eq 0 or die ("Failed building mono\n");
2 changes: 1 addition & 1 deletion external/buildscripts/build_runtime_win64.pl
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out
#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--classlibtests=0", "--forcedefaultbuilddeps=1", "--stevedorebuilddeps=$stevedoreBuildDeps") eq 0 or die ("Failed building mono\n");

system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=0", "--forcedefaultbuilddeps=1", "--stevedorebuilddeps=$stevedoreBuildDeps") eq 0 or die ("Failed building mono\n");
system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--targetarch=x64", "--forcedefaultbuilddeps=1", "--stevedorebuilddeps=$stevedoreBuildDeps") eq 0 or die ("Failed building mono\n");
20 changes: 20 additions & 0 deletions external/buildscripts/build_runtime_win_arm64.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use Cwd;
use Cwd 'abs_path';
use Getopt::Long;
use File::Basename;
use File::Path;

my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../..");
my $monoroot = abs_path($monoroot);
my $buildScriptsRoot = "$monoroot/external/buildscripts";

my $stevedoreBuildDeps = 1;

GetOptions(
"stevedorebuilddeps=i"=>\$stevedoreBuildDeps,
) or die ("illegal cmdline options");

# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out
#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--classlibtests=0", "--forcedefaultbuilddeps=1", "--stevedorebuilddeps=$stevedoreBuildDeps") eq 0 or die ("Failed building mono\n");

system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--targetarch=ARM64", "--forcedefaultbuilddeps=1", "--stevedorebuilddeps=$stevedoreBuildDeps") eq 0 or die ("Failed building mono\n");
98 changes: 69 additions & 29 deletions external/buildscripts/build_win_no_cygwin.pl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
my $checkoutOnTheFly=0;
my $forceDefaultBuildDeps=0;
my $existingMonoRootPath = '';
my $arch32 = 0;
my $targetArch = "";
my $winPerl = "perl";
my $winMonoRoot = $monoroot;
my $buildDeps = "";
Expand All @@ -45,7 +45,7 @@
'clean=i'=>\$clean,
'artifact=i'=>\$artifact,
'debug=i'=>\$debug,
'arch32=i'=>\$arch32,
'targetarch=s'=>\$targetArch,
'existingmono=s'=>\$existingMonoRootPath,
'winperl=s'=>\$winPerl,
'winmonoroot=s'=>\$winMonoRoot,
Expand Down Expand Up @@ -101,9 +101,13 @@
print(">>> mono-build-deps is not required for windows runtime builds...\n");
}
system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--clean=$clean", "--debug=$debug", "--gc=boehm") eq 0 or die ('failed building mono bdwgc with VS\n');
system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--clean=$clean", "--debug=$debug", "--gc=sgen") eq 0 or die ('failed building mono sgen with VS\n');
system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--targetarch=$targetArch", "--clean=$clean", "--debug=$debug", "--gc=boehm") eq 0 or die ('failed building mono bdwgc with VS\n');
if($targetArch ne 'ARM64')
{
system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--targetarch=$targetArch", "--clean=$clean", "--debug=$debug", "--gc=sgen") eq 0 or die ('failed building mono sgen with VS\n');
}
if (!(-d "$monoroot\\tmp"))
{
print(">>> Creating directory $monoroot\\tmp\n");
Expand All @@ -121,22 +125,29 @@
print(">>> Creating directory $monoprefix\\bin\n");
system("mkdir $monoprefix\\bin") eq 0 or die ("failing creating $monoprefix\\bin\n");;
}
# Copy over the VS built stuff that we want to use instead into the prefix directory
my $archNameForBuild = $arch32 ? 'Win32' : 'x64';
my $archNameForBuild = $targetArch;
my $configDirName = $debug ? "Debug" : "Release";
copy("$monoroot/msvc/build/boehm/$archNameForBuild/bin/$configDirName/mono-bdwgc.exe", "$monoprefix/bin/mono-bdwgc.exe") or die ("failed copying mono-bdwgc.exe\n");
copy("$monoroot/msvc/build/boehm/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.dll", "$monoprefix/bin/mono-2.0-bdwgc.dll") or die ("failed copying mono-2.0-bdwgc.dll\n");
copy("$monoroot/msvc/build/boehm/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.pdb", "$monoprefix/bin/mono-2.0-bdwgc.pdb") or die ("failed copying mono-2.0-bdwgc.pdb\n");
copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/.") or die ("failed copying mono-sgen.exe\n");
copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.dll\n");
copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.pdb\n");
# sgen as default exe
copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/mono.exe") or die ("failed copying mono-sgen.exe to mono.exe\n");
if($targetArch ne 'ARM64')
{
copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/.") or die ("failed copying mono-sgen.exe\n");
copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.dll\n");
copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.pdb\n");
# sgen as default exe
copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/mono.exe") or die ("failed copying mono-sgen.exe to mono.exe\n");
}
else
{
# bdwgc as default exe
copy("$monoroot/msvc/build/boehm/$archNameForBuild/bin/$configDirName/mono-bdwgc.exe", "$monoprefix/bin/mono.exe") or die ("failed copying mono-bdwgc.exe to mono.exe\n");
}
copy("$monoroot/msvc/build/boehm/$archNameForBuild/bin/$configDirName/MonoPosixHelper.dll", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.dll\n");
copy("$monoroot/msvc/build/boehm/$archNameForBuild/bin/$configDirName/MonoPosixHelper.pdb", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.pdb\n");
Expand All @@ -153,10 +164,33 @@
my $embedDirRoot = "$buildsroot\\embedruntimes";
my $embedDirArchDestination = $arch32 ? "$embedDirRoot\\win32" : "$embedDirRoot\\win64";
my $distDirArchBin = $arch32 ? "$distdir\\bin" : "$distdir\\bin-x64";
my $versionsOutputFile = $arch32 ? "$buildsroot\\versions-win32.txt" : "$buildsroot\\versions-win64.txt";
my $embedDirArchDestination = "";
my $distDirArchBin = "";
my $versionsOutputFile = "";
print(">>> TARGET ARCH IS $targetArch\n");
if($targetArch eq "Win32")
{
$embedDirArchDestination = "$embedDirRoot\\win32";
$distDirArchBin = "$distdir\\bin";
$versionsOutputFile = "$buildsroot\\versions-win32.txt";
}
if($targetArch eq "x64")
{
$embedDirArchDestination = "$embedDirRoot\\win64";
$distDirArchBin = "$distdir\\bin-x64";
$versionsOutputFile = "$buildsroot\\versions-win64.txt";
}
if($targetArch eq "ARM64")
{
$embedDirArchDestination = "$embedDirRoot\\win-arm64";
$distDirArchBin = "$distdir\\bin-arm64";
$versionsOutputFile = "$buildsroot\\versions-win-arm64.txt";
}
# Make sure the directory for our architecture is clean before we copy stuff into it
if (-d "$embedDirArchDestination")
{
Expand Down Expand Up @@ -199,22 +233,28 @@
copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.dll\n");
copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.pdb\n");
copy("$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.dll\n");
copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.pdb\n");
if($targetArch ne 'ARM64')
{
copy("$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.dll\n");
copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.pdb\n");
}
copy("$monoprefix/bin/MonoPosixHelper.dll", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.dll\n");
copy("$monoprefix/bin/MonoPosixHelper.pdb", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.pdb\n");
# monodistribution directory setup
print(">>> Creating monodistribution directory\n");
copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.dll\n");
copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n");
copy("$monoprefix/bin/mono-2.0-sgen.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.dll\n");
copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.pdb\n");
copy("$monoprefix/bin/mono-sgen.exe", "$distDirArchBin/.") or die ("failed copying mono-sgen.exe\n");
if($targetArch ne 'ARM64')
{
copy("$monoprefix/bin/mono-2.0-sgen.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.dll\n");
copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.pdb\n");
copy("$monoprefix/bin/mono-sgen.exe", "$distDirArchBin/.") or die ("failed copying mono-sgen.exe\n");
}
copy("$monoprefix/bin/mono-bdwgc.exe", "$distDirArchBin/.") or die ("failed copying mono-bdwgc.exe\n");
copy("$monoprefix/bin/mono.exe", "$distDirArchBin/.") or die ("failed copying mono.exe\n");
Expand Down
2 changes: 1 addition & 1 deletion mono/metadata/coree.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ STDAPI MonoFixupCorEE(HMODULE ModuleHandle)
#if defined(_M_IA64)
ProcRva = (DWORD)((DWORD_PTR)PLabel - (DWORD_PTR)DosHeader);
*(PLabel)++ = *ExportFixup->ProcAddress.PLabel;
#elif defined(_M_AMD64)
#elif defined(_M_AMD64) || defined(_M_ARM64)
ProcRva = (DWORD)((DWORD_PTR)Trampoline - (DWORD_PTR)DosHeader);
/* mov r11, ExportFixup->ProcAddress */
*(Trampoline)++ = 0x49;
Expand Down
7 changes: 6 additions & 1 deletion mono/mini/mini-arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/

#include <config.h>

#include "mini.h"
#include "cpu-arm64.h"
#include "ir-emit.h"
Expand Down Expand Up @@ -45,6 +47,9 @@

#define FP_TEMP_REG ARMREG_D16
#define FP_TEMP_REG2 ARMREG_D17
#ifdef HOST_WIN32
#define __attribute__(x)
#endif

#define THUNK_SIZE (4 * 4)

Expand Down Expand Up @@ -2040,7 +2045,7 @@ mono_arch_flush_icache (guint8 *code, gint size)
#ifndef MONO_CROSS_COMPILE
#if __APPLE__
sys_icache_invalidate (code, size);
#else
#elif !HOST_WIN32
/* Don't rely on GCC's __clear_cache implementation, as it caches
* icache/dcache cache line sizes, that can vary between cores on
* big.LITTLE architectures. */
Expand Down
Loading

0 comments on commit bbcf113

Please sign in to comment.