Fix x64 cross build on arm64 macOS (#75677)

* Fix x64 cross build on arm64 macOS

There were couple of minor issues that prevented successful building of x64 macOS
runtime on arm64 macOS device.
This change fixes them.

* Remove cross architecture combination check

* Reflect PR feedback

* Fix #endif comment
This commit is contained in:
Jan Vorlicek 2022-09-22 00:14:47 +02:00 committed by GitHub
parent 43c9f6bf1c
commit 777b2180c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 17 deletions

View File

@ -443,13 +443,7 @@ else()
endif(CLR_CMAKE_TARGET_UNIX)
# check if host & target os/arch combination are valid
if (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)
if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH))
if(NOT((CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM64) OR (CLR_CMAKE_HOST_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_I386)))
message(FATAL_ERROR "Invalid platform and target arch combination TARGET_ARCH=${CLR_CMAKE_TARGET_ARCH} HOST_ARCH=${CLR_CMAKE_HOST_ARCH}")
endif()
endif()
else()
if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS))
if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows))
message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}")
endif()

View File

@ -2674,7 +2674,7 @@ PALIMPORT BOOL PALAPI PAL_GetUnwindInfoSize(SIZE_T baseAddress, ULONG64 ehFrameH
#if defined(__APPLE__) && defined(__i386__)
#define PAL_CS_NATIVE_DATA_SIZE 76
#elif defined(__APPLE__) && defined(__x86_64__)
#elif defined(__APPLE__) && defined(HOST_AMD64)
#define PAL_CS_NATIVE_DATA_SIZE 120
#elif defined(__APPLE__) && defined(HOST_ARM64)
#define PAL_CS_NATIVE_DATA_SIZE 120
@ -4581,12 +4581,14 @@ void _mm_setcsr(unsigned int i);
#ifdef __cplusplus
#if defined(HOST_ARM64) && defined(TARGET_ARM64)
class CORJIT_FLAGS;
PALIMPORT
VOID
PALAPI
PAL_GetJitCpuCapabilityFlags(CORJIT_FLAGS *flags);
#endif // HOST_ARM64 && TARGET_ARM64
#endif

View File

@ -54,7 +54,7 @@ Abstract:
#endif // HOST_UNIX
#if defined(TARGET_OSX) && defined(TARGET_ARM64)
#if defined(TARGET_OSX) && defined(HOST_ARM64)
// MacOS uses ARM64 instead of AARCH64 to describe these registers
// Create aliases to reuse more code
enum
@ -96,7 +96,7 @@ enum
UNW_AARCH64_V30 = UNW_ARM64_D30,
UNW_AARCH64_V31 = UNW_ARM64_D31
};
#endif // defined(TARGET_OSX) && defined(TARGET_ARM64)
#endif // defined(TARGET_OSX) && defined(HOST_ARM64)
//----------------------------------------------------------------------

View File

@ -148,6 +148,7 @@ static unsigned long GetCpuCapabilityFlagsFromCpuInfo()
}
#endif // defined(HOST_ARM64) && defined(__linux__)
#if defined(HOST_ARM64) && defined(TARGET_ARM64)
PALIMPORT
VOID
PALAPI
@ -155,7 +156,6 @@ PAL_GetJitCpuCapabilityFlags(CORJIT_FLAGS *flags)
{
_ASSERTE(flags);
#if defined(HOST_ARM64)
#if HAVE_AUXV_HWCAP_H
unsigned long hwCap = getauxval(AT_HWCAP);
@ -294,10 +294,5 @@ PAL_GetJitCpuCapabilityFlags(CORJIT_FLAGS *flags)
flags->Set(InstructionSet_AdvSimd);
// flags->Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_FP);
#endif // HAVE_AUXV_HWCAP_H
#elif defined(TARGET_ARM64)
// Enable ARM64 based flags by default so we always crossgen
// ARM64 intrinsics for Linux
flags->Set(InstructionSet_ArmBase);
flags->Set(InstructionSet_AdvSimd);
#endif // defined(HOST_ARM64)
}
#endif // HOST_ARM64 && TARGET_ARM64