Skip to content

Commit 777b218

Browse files
authored
Fix x64 cross build on arm64 macOS (dotnet#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
1 parent 43c9f6b commit 777b218

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

eng/native/configureplatform.cmake

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,7 @@ else()
443443
endif(CLR_CMAKE_TARGET_UNIX)
444444

445445
# check if host & target os/arch combination are valid
446-
if (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)
447-
if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH))
448-
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)))
449-
message(FATAL_ERROR "Invalid platform and target arch combination TARGET_ARCH=${CLR_CMAKE_TARGET_ARCH} HOST_ARCH=${CLR_CMAKE_HOST_ARCH}")
450-
endif()
451-
endif()
452-
else()
446+
if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS))
453447
if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows))
454448
message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}")
455449
endif()

src/coreclr/pal/inc/pal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2674,7 +2674,7 @@ PALIMPORT BOOL PALAPI PAL_GetUnwindInfoSize(SIZE_T baseAddress, ULONG64 ehFrameH
26742674

26752675
#if defined(__APPLE__) && defined(__i386__)
26762676
#define PAL_CS_NATIVE_DATA_SIZE 76
2677-
#elif defined(__APPLE__) && defined(__x86_64__)
2677+
#elif defined(__APPLE__) && defined(HOST_AMD64)
26782678
#define PAL_CS_NATIVE_DATA_SIZE 120
26792679
#elif defined(__APPLE__) && defined(HOST_ARM64)
26802680
#define PAL_CS_NATIVE_DATA_SIZE 120
@@ -4581,12 +4581,14 @@ void _mm_setcsr(unsigned int i);
45814581

45824582
#ifdef __cplusplus
45834583

4584+
#if defined(HOST_ARM64) && defined(TARGET_ARM64)
45844585
class CORJIT_FLAGS;
45854586

45864587
PALIMPORT
45874588
VOID
45884589
PALAPI
45894590
PAL_GetJitCpuCapabilityFlags(CORJIT_FLAGS *flags);
4591+
#endif // HOST_ARM64 && TARGET_ARM64
45904592

45914593
#endif
45924594

src/coreclr/pal/src/exception/seh-unwind.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Module Name:
5454

5555
#endif // HOST_UNIX
5656

57-
#if defined(TARGET_OSX) && defined(TARGET_ARM64)
57+
#if defined(TARGET_OSX) && defined(HOST_ARM64)
5858
// MacOS uses ARM64 instead of AARCH64 to describe these registers
5959
// Create aliases to reuse more code
6060
enum
@@ -96,7 +96,7 @@ enum
9696
UNW_AARCH64_V30 = UNW_ARM64_D30,
9797
UNW_AARCH64_V31 = UNW_ARM64_D31
9898
};
99-
#endif // defined(TARGET_OSX) && defined(TARGET_ARM64)
99+
#endif // defined(TARGET_OSX) && defined(HOST_ARM64)
100100

101101

102102
//----------------------------------------------------------------------

src/coreclr/pal/src/misc/jitsupport.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ static unsigned long GetCpuCapabilityFlagsFromCpuInfo()
148148
}
149149
#endif // defined(HOST_ARM64) && defined(__linux__)
150150

151+
#if defined(HOST_ARM64) && defined(TARGET_ARM64)
151152
PALIMPORT
152153
VOID
153154
PALAPI
154155
PAL_GetJitCpuCapabilityFlags(CORJIT_FLAGS *flags)
155156
{
156157
_ASSERTE(flags);
157158

158-
#if defined(HOST_ARM64)
159159
#if HAVE_AUXV_HWCAP_H
160160
unsigned long hwCap = getauxval(AT_HWCAP);
161161

@@ -294,10 +294,5 @@ PAL_GetJitCpuCapabilityFlags(CORJIT_FLAGS *flags)
294294
flags->Set(InstructionSet_AdvSimd);
295295
// flags->Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_FP);
296296
#endif // HAVE_AUXV_HWCAP_H
297-
#elif defined(TARGET_ARM64)
298-
// Enable ARM64 based flags by default so we always crossgen
299-
// ARM64 intrinsics for Linux
300-
flags->Set(InstructionSet_ArmBase);
301-
flags->Set(InstructionSet_AdvSimd);
302-
#endif // defined(HOST_ARM64)
303297
}
298+
#endif // HOST_ARM64 && TARGET_ARM64

0 commit comments

Comments
 (0)