This PR allows an `osx-arm64` or `osx-x64` machine to produce a `mono-aot-cross` compiler that will run on the following host and create AOT images for the following targets:
| Host | Target | Test App runs |
|--------|--------|--------|
| osx-arm64 | iossimulator-x64 | ✅ |
| osx-arm64 | android-x64 | ✅ |
| osx-arm64 | android-x86 | ✅ - depends on a hack for https://github.com/dotnet/runtime/issues/89039 |
Additionally a `linux-x64` or `linux-arm64` machine can build a `mono-aot-cross` compiler for these host/target pairs:
| Host | Target | Test App runs |
|--------|--------|--------|
| linux-arm64 | android-x64 | :question: |
| linux-arm64 | linux_musl-x64 | :question: |
| linux-arm64 | android-x86 | :question: |
Related to https://github.com/dotnet/runtime/issues/82495
* [aot][ios] Build cross-compilers targeting x64 hosted on arm64
* Use MONO_CROSS_COMPILE instead of host checks
* [android][x86] Build mono-aot-cross hosted on osx-arm64 targeting android-x86
* fix build of mono-aot-cross hosted on linux-arm64 targeting android-x64
* runtime pipeline changes to build arm64 artifacts on x64 hardware
* Fix linux_musl-arm64 builds
---------
Co-authored-by: Jo Shields <directhex@apebox.org>
platforms:
- linux_x64
- linux_musl_x64
+ - linux_arm64
+ - linux_musl_arm64
jobParameters:
buildArgs: -s mono+packs -c $(_BuildConfig)
/p:MonoCrossAOTTargetOS=android+browser /p:SkipMonoCrossJitConfigure=true /p:BuildMonoAOTCrossCompilerOnly=true
runtimeFlavor: mono
buildConfig: release
platforms:
- - linux_arm64
- - linux_musl_arm64
- jobParameters:
- buildArgs: -s mono+packs -c $(_BuildConfig)
- /p:MonoCrossAOTTargetOS=browser /p:SkipMonoCrossJitConfigure=true /p:BuildMonoAOTCrossCompilerOnly=true
- nameSuffix: CrossAOT_Mono
- runtimeVariant: crossaot
- dependsOn:
- - mono_browser_offsets
- monoCrossAOTTargetOS:
- - browser
- isOfficialBuild: ${{ variables.isOfficialBuild }}
- extraStepsTemplate: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
- extraStepsParameters:
- name: MonoRuntimePacks
-
- - template: /eng/pipelines/common/platform-matrix.yml
- parameters:
- jobTemplate: /eng/pipelines/common/global-build-job.yml
- runtimeFlavor: mono
- buildConfig: release
- platforms:
- windows_x64
jobParameters:
buildArgs: -s mono+packs -c $(_BuildConfig)
buildConfig: release
platforms:
- osx_x64
+ - osx_arm64
jobParameters:
buildArgs: -s mono+packs -c $(_BuildConfig)
/p:MonoCrossAOTTargetOS=android+browser+tvos+ios+maccatalyst /p:SkipMonoCrossJitConfigure=true /p:BuildMonoAOTCrossCompilerOnly=true
extraStepsParameters:
name: MonoRuntimePacks
- - template: /eng/pipelines/common/platform-matrix.yml
- parameters:
- jobTemplate: /eng/pipelines/common/global-build-job.yml
- runtimeFlavor: mono
- buildConfig: release
- platforms:
- - osx_arm64
- jobParameters:
- buildArgs: -s mono+packs -c $(_BuildConfig)
- /p:MonoCrossAOTTargetOS=browser /p:SkipMonoCrossJitConfigure=true /p:BuildMonoAOTCrossCompilerOnly=true
- nameSuffix: CrossAOT_Mono
- runtimeVariant: crossaot
- dependsOn:
- - mono_browser_offsets
- monoCrossAOTTargetOS:
- - browser
- isOfficialBuild: ${{ variables.isOfficialBuild }}
- extraStepsTemplate: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
- extraStepsParameters:
- name: MonoRuntimePacks
-
#
# Build Mono LLVM runtime packs
#
platforms:
- linux_x64
- linux_musl_x64
- # - linux_arm64
- # - linux_musl_arm64
+ - linux_arm64
+ - linux_musl_arm64
- windows_x64
# - windows_x86
# - windows_arm64
buildConfig: release
platforms:
- osx_x64
+ - osx_arm64
jobParameters:
runtimeVariant: crossaot
dependsOn:
eq(dependencies.evaluate_paths.outputs['SetPathVars_installer.containsChange'], true),
eq(variables['isRollingBuild'], true))
- - template: /eng/pipelines/common/platform-matrix.yml
- parameters:
- jobTemplate: /eng/pipelines/mono/templates/build-job.yml
- runtimeFlavor: mono
- buildConfig: release
- platforms:
- - linux_arm64
- - linux_musl_arm64
- - osx_arm64
- jobParameters:
- runtimeVariant: crossaot
- dependsOn:
- - mono_browser_offsets
- monoCrossAOTTargetOS:
- - browser
- condition: >-
- or(
- eq(dependencies.evaluate_paths.outputs['SetPathVars_mono.containsChange'], true),
- eq(dependencies.evaluate_paths.outputs['SetPathVars_installer.containsChange'], true),
- eq(variables['isRollingBuild'], true))
-
#
# Build Mono release
# Only when libraries or mono changed
void
mono_arch_handle_altstack_exception (void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *siginfo, gpointer fault_addr, gboolean stack_ovf)
{
-#if defined(MONO_ARCH_USE_SIGACTION)
+#if defined(MONO_ARCH_USE_SIGACTION) && !defined(MONO_CROSS_COMPILE)
MonoException *exc = NULL;
gpointer *sp;
MonoJitTlsData *jit_tls = NULL;
mono_arch_cpu_init (void)
{
#ifndef _MSC_VER
+#if !defined(MONO_CROSS_COMPILE)
guint16 fpcw;
/* spec compliance requires running with double precision */
fpcw |= X86_FPCW_PREC_DOUBLE;
__asm__ __volatile__ ("fldcw %0\n": : "m" (fpcw));
__asm__ __volatile__ ("fnstcw %0\n": "=m" (fpcw));
+#endif
#else
/* TODO: This is crashing on Win64 right now.
* _control87 (_PC_53, MCW_PC);
void
mono_arch_cpu_init (void)
{
+#if !defined(MONO_CROSS_COMPILE)
/* spec compliance requires running with double precision */
#ifndef _MSC_VER
guint16 fpcw;
#else
_control87 (_PC_53, MCW_PC);
#endif
+#endif
}
/*
#if defined(TARGET_X86)
#if defined(__APPLE__)
-#define MONO_HAVE_SIMD_REG
+#if !defined(MONO_CROSS_COMPILE)
typedef struct __darwin_xmm_reg MonoContextSimdReg;
+#else
+/* if building for an arm64 host machine, a cross compiler that produces x86 modules, fake a MonoContextSimdReg */
+typedef __uint128_t MonoContextSimdReg;
+#endif
#endif
#elif defined(TARGET_AMD64)
#if defined(__APPLE__)
#define MONO_HAVE_SIMD_REG
+#if !defined(MONO_CROSS_COMPILE)
typedef struct __darwin_xmm_reg MonoContextSimdReg;
+#else
+/* if building for an arm64 host machine, a cross compiler that produces x64 modules, fake a MonoContextSimdReg */
+typedef __uint128_t MonoContextSimdReg;
+#endif
#elif defined(__linux__) && defined(__GLIBC__)
#define MONO_HAVE_SIMD_REG
+#if !defined(MONO_CROSS_COMPILE)
typedef struct _libc_xmmreg MonoContextSimdReg;
+#else
+/* if building for an arm64 host machine, a cross compiler that produces x64 modules, fake a MonoContextSimdReg */
+typedef __uint128_t MonoContextSimdReg;
+#endif
#elif defined(HOST_WIN32)
#define MONO_HAVE_SIMD_REG
//#define MONO_HAVE_SIMD_REG_AVX
typedef struct _libc_xmmreg MonoContextSimdReg;
#elif defined(__linux__) || defined(__OpenBSD__)
#define MONO_HAVE_SIMD_REG
+#if !defined(MONO_CROSS_COMPILE)
#include <emmintrin.h>
typedef __m128d MonoContextSimdReg;
+#else
+/* if building for an arm64 host machine, a cross compiler that produces x64 modules, fake a MonoContextSimdReg */
+typedef __uint128_t MonoContextSimdReg;
+#endif
#endif
#elif defined(TARGET_ARM64)
/* We need a definition for MonoContextSimdReg even when cross-compiling
#elif defined(TARGET_AMD64)
-#if defined(__APPLE__)
+#if defined(MONO_CROSS_COMPILE)
+ #define UCONTEXT_REG_RDX(ctx) NULL
+ #define UCONTEXT_REG_RSP(ctx) NULL
+ #define UCONTEXT_REG_RSI(ctx) NULL
+ #define UCONTEXT_REG_RDI(ctx) NULL
+ #define UCONTEXT_REG_RIP(ctx) NULL
+
+#elif defined(__APPLE__)
#define UCONTEXT_REG_RAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__rax)
#define UCONTEXT_REG_RBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__rbx)
#define UCONTEXT_REG_RCX(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__rcx)