Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build native windows-arm64 Mono cross-compilers #89651

Merged
merged 9 commits into from
Oct 17, 2023
2 changes: 2 additions & 0 deletions eng/pipelines/runtime-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ extends:
runtimeFlavor: mono
buildConfig: release
platforms:
- windows_arm64
- windows_x64
jobParameters:
buildArgs: -s mono+packs -c $(_BuildConfig)
Expand Down Expand Up @@ -633,6 +634,7 @@ extends:
- Build_tvos_arm64_release_Mono
- Build_tvossimulator_arm64_release_Mono
- Build_tvossimulator_x64_release_Mono
- Build_windows_arm64_release_CrossAOT_Mono
- Build_windows_x64_release_CrossAOT_Mono
- Build_windows_x64_release_CoreCLR
- Build_windows_x86_release_CoreCLR
Expand Down
3 changes: 1 addition & 2 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,8 @@ extends:
- linux_musl_x64
- linux_arm64
- linux_musl_arm64
- windows_arm64
- windows_x64
# - windows_x86
# - windows_arm64
jobParameters:
runtimeVariant: crossaot
dependsOn:
Expand Down
1 change: 1 addition & 0 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "windows")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") # statically link VC runtime library
add_compile_options(/W4) # set warning level 4
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4324>) # 'struct_name' : structure was padded due to __declspec(align())
add_compile_options(/EHsc) # set exception handling behavior
add_compile_options(/FC) # use full pathnames in diagnostics
add_link_options(/STACK:0x800000) # set stack size to 8MB (default is 1MB)
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
<_MonoCPPFLAGS Include="-DWIN32_LEAN_AND_MEAN" />
<!--<_MonoCPPFLAGS Include="-D_WINDOWS" />--> <!-- set in monow.vcxproj, not sure we really need it -->
<_MonoCPPFLAGS Condition="'$(Platform)' == 'x64' or '$(Platform)' == 'arm64'" Include="-DWIN64" />
<_MonoCPPFLAGS Condition="'$(Platform)' == 'arm64'" Include="-DUSE_SOFT_INTRINSICS" />
<_MonoCPPFLAGS Condition="'$(Configuration)' == 'Release'" Include="-DNDEBUG" />
<_MonoCPPFLAGS Condition="'$(Configuration)' == 'Debug'" Include="-D_DEBUG" />
<!-- <_MonoCPPFLAGS Include="-D__default_codegen__" /> --> <!-- doesn't seem to be used -->
Expand Down Expand Up @@ -749,6 +750,7 @@
<_MonoAOTCPPFLAGS Include="-DWIN32_LEAN_AND_MEAN" />
<!--<_MonoAOTCPPFLAGS Include="-D_WINDOWS" />--> <!-- set in monow.vcxproj, not sure we really need it -->
<_MonoAOTCPPFLAGS Condition="'$(Platform)' == 'x64' or '$(Platform)' == 'arm64'" Include="-DWIN64" />
<_MonoAOTCPPFLAGS Condition="'$(AotHostArchitecture)' == 'arm64'" Include="-DUSE_SOFT_INTRINSICS" />
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Release' or '$(_ForceRelease)' == 'true'" Include="-DNDEBUG" />
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Debug' and '$(_ForceRelease)' != 'true'" Include="-D_DEBUG" />
<!-- <_MonoAOTCPPFLAGS Include="-D__default_codegen__" /> --> <!-- doesn't seem to be used -->
Expand Down
4 changes: 4 additions & 0 deletions src/mono/mono/mini/exceptions-amd64.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,11 @@ mono_arch_ip_from_context (void *sigctx)
#if defined(MONO_ARCH_USE_SIGACTION)
return (gpointer)UCONTEXT_REG_RIP ((ucontext_t*)sigctx);
#elif defined(HOST_WIN32)
#if defined(MONO_CROSS_COMPILE)
return (gpointer)NULL;
#else
return (gpointer)(((CONTEXT*)sigctx)->Rip);
#endif
#else
MonoContext *ctx = (MonoContext*)sigctx;
return (gpointer)ctx->gregs [AMD64_RIP];
Expand Down
6 changes: 6 additions & 0 deletions src/mono/mono/utils/mach-support-arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,10 @@ mono_mach_arch_set_thread_states (thread_port_t thread, thread_state_t state, ma
#endif
}

#else

#include <mono/utils/mono-compiler.h>

MONO_EMPTY_SOURCE_FILE (mach_support_arm64);

#endif
4 changes: 3 additions & 1 deletion src/mono/mono/utils/mono-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ typedef __uint128_t MonoContextSimdReg;
#elif defined(HOST_WIN32)
#define MONO_HAVE_SIMD_REG
//#define MONO_HAVE_SIMD_REG_AVX
#include <intrin.h>
#include <emmintrin.h>
typedef __m128d MonoContextSimdReg;
#elif defined(HOST_ANDROID)
Expand All @@ -77,6 +78,7 @@ typedef __uint128_t MonoContextSimdReg;
a stand-in. This is not expected to work for Windows ARM64 native builds. */
#if defined(HOST_WIN32)
#define MONO_HAVE_SIMD_REG
#include <intrin.h>
#include <emmintrin.h>
typedef __m128d MonoContextSimdReg;
#else
Expand Down Expand Up @@ -507,7 +509,7 @@ typedef struct {

#define MONO_ARCH_HAS_MONO_CONTEXT 1

#elif (defined(__aarch64__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_ARM64))
#elif ((defined(_M_ARM64) || defined(__aarch64__)) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_ARM64))

#include <mono/arch/arm64/arm64-codegen.h>

Expand Down
7 changes: 6 additions & 1 deletion src/mono/mono/utils/mono-threads-coop.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,20 @@ copy_stack_data_internal (MonoThreadInfo *info, MonoStackData *stackdata_begin,
#ifdef _MSC_VER
typedef void (*CopyStackDataFunc)(MonoThreadInfo *, MonoStackData *, gconstpointer, gconstpointer);

#ifdef HOST_AMD64
#if defined(HOST_AMD64) || defined(HOST_ARM64)
#include <intrin.h>
#include <emmintrin.h>
// Implementation of __builtin_unwind_init under MSVC, dumping nonvolatile registers into MonoBuiltinUnwindInfo.
typedef struct {
__m128d fregs [10];
host_mgreg_t gregs [8];
} MonoBuiltinUnwindInfo;

#if defined(HOST_AMD64)
// Defined in win64.asm
G_EXTERN_C void
copy_stack_data_internal_win32_wrapper (MonoThreadInfo *, MonoStackData *, MonoBuiltinUnwindInfo *, CopyStackDataFunc);
#endif
#else
// Implementation of __builtin_unwind_init under MSVC, dumping nonvolatile registers into MonoBuiltinUnwindInfo.
typedef struct {
Expand Down Expand Up @@ -238,8 +241,10 @@ copy_stack_data_internal_win32_wrapper (MonoThreadInfo *info, MonoStackData *sta
static void
copy_stack_data (MonoThreadInfo *info, MonoStackData *stackdata_begin)
{
#if defined(HOST_AMD64)
MonoBuiltinUnwindInfo unwind_info_data;
copy_stack_data_internal_win32_wrapper (info, stackdata_begin, &unwind_info_data, copy_stack_data_internal);
#endif
}
#else
static void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"version": "${PackageVersion}",
"alias-to": {
"win-x64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x86",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x86",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-arm64.Cross.android-x86",
"linux-x64": "Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.android-x86",
"linux-arm64": "Microsoft.NETCore.App.Runtime.AOT.linux-arm64.Cross.android-x86",
"osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.android-x86",
Expand All @@ -217,7 +217,7 @@
"version": "${PackageVersion}",
"alias-to": {
"win-x64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x64",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x64",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-arm64.Cross.android-x64",
"linux-x64": "Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.android-x64",
"linux-arm64": "Microsoft.NETCore.App.Runtime.AOT.linux-arm64.Cross.android-x64",
"osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.android-x64",
Expand All @@ -229,7 +229,7 @@
"version": "${PackageVersion}",
"alias-to": {
"win-x64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-arm64.Cross.android-arm",
"linux-x64": "Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.android-arm",
"linux-arm64": "Microsoft.NETCore.App.Runtime.AOT.linux-arm64.Cross.android-arm",
"osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.android-arm",
Expand All @@ -241,7 +241,7 @@
"version": "${PackageVersion}",
"alias-to": {
"win-x64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-arm64.Cross.android-arm64",
"linux-x64": "Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.android-arm64",
"linux-arm64": "Microsoft.NETCore.App.Runtime.AOT.linux-arm64.Cross.android-arm64",
"osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.android-arm64",
Expand Down Expand Up @@ -365,7 +365,7 @@
"version": "${PackageVersion}",
"alias-to": {
"win-x64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm",
"win-arm64": "Microsoft.NETCore.App.Runtime.AOT.win-arm64.Cross.browser-wasm",
"linux-x64": "Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm",
"linux-arm64": "Microsoft.NETCore.App.Runtime.AOT.linux-arm64.Cross.browser-wasm",
"osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.browser-wasm",
Expand Down
Loading