From c4d5ca2a81fb9a1e143c674a46a4b9bed8154987 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 7 Jan 2025 11:25:39 +0100 Subject: [PATCH 01/15] Make it possible to compile CoreCLR on iOS-like platforms with './build.sh clr+clr.nativeaotlibs+libs+packs -os [iossimulator/maccatalyst/ios] -arch arm64 -cross' Build the singlefilehost even if we don't currently use it Make coreclrhost.h compatible v C(not++) Fix TargetOS::IsMacOS WIP: AppleAppBuilder support for CoreCLR Make the sample app working: dotnet publish src/mono/sample/iOS/Program.csproj -c Release /p:TargetOS=iossimulator /p:TargetArchitecture=arm64 /p:AppleAppBuilderRuntime=CoreCLR /p:DeployAndRun=true /p:UseMonoRuntime=false /p:RunAOTCompilation=false /p:MonoForceInterpreter=false Cleanup Update src/tasks/AppleAppBuilder/AppleAppBuilder.csproj Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> Use sys_icache_invalidate for all iOS-like platforms Consolidate macOS-only entrypoints in a single #if block Apply feedback Fix jitinterface cross-build Infer AppleAppBuilderRuntime from UseMonoRuntime and UseNativeAOTRuntime Minor changes to test infrastructure Add basic documentation Add nearly complete support for building runtime tests Fix building seh-unwind with older iOS SDK Use enum for TargetRuntime in AppleAppBuilder Fix LibraryBuilder build Cleanup Fix after rebase Revert accidental change Fix tvOS build Drop CoreCLR tvOS Simulator support for now --- docs/workflow/building/coreclr/ios.md | 33 ++++ eng/Subsets.props | 6 +- ...Reflection.ReadyToRun.Experimental.pkgproj | 2 +- src/coreclr/CMakeLists.txt | 21 ++- src/coreclr/debug/daccess/CMakeLists.txt | 6 +- src/coreclr/dlls/mscordac/CMakeLists.txt | 4 +- .../dlls/mscoree/coreclr/CMakeLists.txt | 3 + src/coreclr/hosts/inc/coreclrhost.h | 6 + src/coreclr/inc/crosscomp.h | 6 +- src/coreclr/inc/executableallocator.h | 4 +- src/coreclr/inc/targetosarch.h | 2 +- src/coreclr/jit/CMakeLists.txt | 2 +- src/coreclr/minipal/Unix/doublemapping.cpp | 34 ++-- src/coreclr/pal/inc/pal.h | 4 +- src/coreclr/pal/src/CMakeLists.txt | 21 ++- src/coreclr/pal/src/configure.cmake | 6 +- src/coreclr/pal/src/debug/debug.cpp | 2 + src/coreclr/pal/src/exception/seh-unwind.cpp | 12 +- src/coreclr/pal/src/include/pal/context.h | 16 +- src/coreclr/pal/src/include/pal/dbgmsg.h | 6 +- src/coreclr/pal/src/map/virtual.cpp | 30 +++- src/coreclr/pal/src/misc/dbgmsg.cpp | 4 +- src/coreclr/pal/src/misc/sysinfo.cpp | 6 +- src/coreclr/pal/src/thread/context.cpp | 29 ++-- src/coreclr/pal/src/thread/process.cpp | 16 +- .../ObjectWriter/TargetExtensions.cs | 5 + .../aot/crossgen2/Crossgen2RootCommand.cs | 2 +- .../tools/aot/jitinterface/jitwrapper.cpp | 4 + src/coreclr/utilcode/executableallocator.cpp | 4 +- src/coreclr/vm/amd64/asmhelpers.S | 6 +- src/coreclr/vm/amd64/jithelpers_fast.S | 2 +- src/coreclr/vm/arm64/asmhelpers.S | 8 +- src/coreclr/vm/arm64/stubs.cpp | 4 +- src/coreclr/vm/cdacplatformmetadata.cpp | 2 +- src/coreclr/vm/comdelegate.cpp | 2 +- src/coreclr/vm/jitinterface.cpp | 2 +- src/coreclr/vm/threads.h | 2 +- src/coreclr/vm/threadstatics.cpp | 14 +- .../Directory.Build.props | 1 + .../apple/build/AppleBuild.InTree.targets | 9 + src/mono/msbuild/apple/build/AppleBuild.props | 10 +- .../msbuild/apple/build/AppleBuild.targets | 14 +- .../corehost/apphost/static/CMakeLists.txt | 8 +- src/native/corehost/hostmisc/pal.h | 2 +- .../hostpolicy/hostpolicy_context.cpp | 4 +- src/native/external/libunwind.cmake | 4 +- .../external/libunwind_extras/CMakeLists.txt | 10 +- .../CMakeLists.txt | 6 + src/native/libs/System.Native/CMakeLists.txt | 2 +- src/native/libs/System.Native/entrypoints.c | 2 + .../System.Net.Security.Native/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../entrypoints.c | 46 ++--- src/native/libs/configure.cmake | 2 +- src/tasks/AppleAppBuilder/AppleAppBuilder.cs | 40 +++-- .../AppleAppBuilder/AppleAppBuilder.csproj | 2 + src/tasks/AppleAppBuilder/TargetRuntime.cs | 9 + .../Templates/CMakeLists.txt.template | 2 +- .../Templates/runtime-coreclr.m | 161 ++++++++++++++++++ src/tasks/AppleAppBuilder/Xcode.cs | 130 +++++++++----- .../LibraryBuilder/LibraryBuilder.csproj | 1 + src/tests/Directory.Build.props | 3 +- src/tests/build.proj | 21 ++- 63 files changed, 602 insertions(+), 229 deletions(-) create mode 100644 docs/workflow/building/coreclr/ios.md create mode 100644 src/tasks/AppleAppBuilder/TargetRuntime.cs create mode 100644 src/tasks/AppleAppBuilder/Templates/runtime-coreclr.m diff --git a/docs/workflow/building/coreclr/ios.md b/docs/workflow/building/coreclr/ios.md new file mode 100644 index 00000000000000..9061fd17da438c --- /dev/null +++ b/docs/workflow/building/coreclr/ios.md @@ -0,0 +1,33 @@ +# Cross Compilation for iOS Simulator on macOS + +## Requirements + +Build requirements are the same as for building native CoreCLR on macOS. iPhone SDK has to be enabled in Xcode installation. + +## Cross compiling CoreCLR + +Build the runtime pack and tools with + +``` +./build.sh clr+clr.runtime+libs+packs -os [iossimulator/maccatalyst] -arch [x64/arm64] -cross -c Release +``` + +## Running the sample iOS app + +Build and run the sample app with + +``` +./dotnet.sh publish src/mono/sample/iOS/Program.csproj -c Release /p:TargetOS=iossimulator /p:TargetArchitecture=arm64 /p:DeployAndRun=true /p:UseMonoRuntime=false /p:RunAOTCompilation=false /p:MonoForceInterpreter=false +``` + +The command also produces an XCode project that can be opened with `open ./src/mono/sample/iOS/bin/iossimulator-arm64/Bundle/HelloiOS/HelloiOS.xcodeproj` and debugged in Xcode. + +## Running the runtime tests + +Build the runtime tests with + +``` +./src/tests/build.sh -os iossimulator arm64 Release -p:UseMonoRuntime=false +``` + +Running the tests is not implemented yet. It will likely need similar app bundle infrastructure as NativeAOT/iOS uses. \ No newline at end of file diff --git a/eng/Subsets.props b/eng/Subsets.props index b406d5b9750b22..ed49497e575c3f 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -82,8 +82,8 @@ - Mono - CoreCLR + CoreCLR + Mono Mono $(PrimaryRuntimeFlavor) @@ -92,7 +92,7 @@ clr.native+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools+host.native clr.native+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools - clr.iltools+clr.packages + clr.iltools+clr.packages clr.alljits+clr.tools+clr.nativeaotlibs+clr.nativeaotruntime diff --git a/src/coreclr/.nuget/ILCompiler.Reflection.ReadyToRun.Experimental/ILCompiler.Reflection.ReadyToRun.Experimental.pkgproj b/src/coreclr/.nuget/ILCompiler.Reflection.ReadyToRun.Experimental/ILCompiler.Reflection.ReadyToRun.Experimental.pkgproj index b2945e29260152..0480327017db55 100644 --- a/src/coreclr/.nuget/ILCompiler.Reflection.ReadyToRun.Experimental/ILCompiler.Reflection.ReadyToRun.Experimental.pkgproj +++ b/src/coreclr/.nuget/ILCompiler.Reflection.ReadyToRun.Experimental/ILCompiler.Reflection.ReadyToRun.Experimental.pkgproj @@ -11,7 +11,7 @@ - + \lib\netstandard2.0\ diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index d65650f5cb88e7..cfae08b84ecb28 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -29,7 +29,7 @@ if(CORECLR_SET_RPATH) set(MACOSX_RPATH ON) endif(CORECLR_SET_RPATH) -if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) +if(CLR_CMAKE_HOST_TVOS) set(FEATURE_STANDALONE_GC 0) endif() @@ -101,8 +101,10 @@ if(CLR_CMAKE_HOST_UNIX) add_linker_flag(-Wl,-z,notext) endif() - if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) + if(NOT CLR_CMAKE_HOST_TVOS) add_subdirectory(pal) + endif() + if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) add_subdirectory(hosts) endif() else() @@ -129,7 +131,7 @@ add_subdirectory(${CLR_SRC_NATIVE_DIR}/containers containers) add_subdirectory(${CLR_SRC_NATIVE_DIR}/eventpipe eventpipe) add_subdirectory(${CLR_SRC_NATIVE_DIR}/minipal shared_minipal) -if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) +if(NOT CLR_CMAKE_HOST_TVOS) add_subdirectory(debug/debug-pal) endif() @@ -243,7 +245,7 @@ if(CLR_CMAKE_HOST_UNIX) add_subdirectory(nativeresources) endif(CLR_CMAKE_HOST_UNIX) -if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) +if(NOT CLR_CMAKE_HOST_TVOS) add_subdirectory(utilcode) add_subdirectory(inc) @@ -257,15 +259,18 @@ if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_H add_subdirectory(binder) add_subdirectory(classlibnative) add_subdirectory(dlls) - add_subdirectory(tools) add_subdirectory(unwinder) add_subdirectory(interop) +endif() - if(CLR_CMAKE_HOST_WIN32) - add_subdirectory(hosts) - endif(CLR_CMAKE_HOST_WIN32) +if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) + add_subdirectory(tools) endif(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) +if(CLR_CMAKE_HOST_WIN32) + add_subdirectory(hosts) +endif(CLR_CMAKE_HOST_WIN32) + #---------------------------------------------------- # Cross target Component install configuration #---------------------------------------------------- diff --git a/src/coreclr/debug/daccess/CMakeLists.txt b/src/coreclr/debug/daccess/CMakeLists.txt index 9ed71521d4283d..fa26f55cc37fa2 100644 --- a/src/coreclr/debug/daccess/CMakeLists.txt +++ b/src/coreclr/debug/daccess/CMakeLists.txt @@ -47,10 +47,10 @@ target_link_libraries(daccess PRIVATE cdacreader_api) add_dependencies(daccess eventing_headers) -if(CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) +if(CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_APPLE) add_definitions(-DUSE_DAC_TABLE_RVA) - set(args $<$>:--dynamic> $ ${GENERATED_INCLUDE_DIR}/dactablerva.h) + set(args $<$>:--dynamic> $ ${GENERATED_INCLUDE_DIR}/dactablerva.h) add_custom_command( OUTPUT ${GENERATED_INCLUDE_DIR}/dactablerva.h @@ -72,4 +72,4 @@ if(CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) ) add_dependencies(daccess dactablerva_header) -endif(CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) +endif(CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_APPLE) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index ef91243448c518..2b33054129d623 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -31,9 +31,9 @@ else(CLR_CMAKE_HOST_WIN32) # Add dependency on export file add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE}) - if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU) + if(CLR_CMAKE_HOST_APPLE OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU) + endif(CLR_CMAKE_HOST_APPLE OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU) if(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_OSX AND CLR_CMAKE_HOST_ARCH_ARM64) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index aed404b39e5ae2..1fe455a2e393d9 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -227,6 +227,9 @@ endif(CLR_CMAKE_TARGET_WIN32) # add the install targets install_clr(TARGETS coreclr DESTINATIONS . sharedFramework COMPONENT runtime) +if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS) + install_clr(TARGETS coreclr_static DESTINATIONS . sharedFramework COMPONENT runtime) +endif() # Enable profile guided optimization add_pgo(coreclr) diff --git a/src/coreclr/hosts/inc/coreclrhost.h b/src/coreclr/hosts/inc/coreclrhost.h index 01eeac600a2240..2988ea0452acfd 100644 --- a/src/coreclr/hosts/inc/coreclrhost.h +++ b/src/coreclr/hosts/inc/coreclrhost.h @@ -19,9 +19,15 @@ // For each hosting API, we define a function prototype and a function pointer // The prototype is useful for implicit linking against the dynamic coreclr // library and the pointer for explicit dynamic loading (dlopen, LoadLibrary) +#ifdef __cplusplus #define CORECLR_HOSTING_API(function, ...) \ extern "C" int CORECLR_CALLING_CONVENTION function(__VA_ARGS__); \ typedef int (CORECLR_CALLING_CONVENTION *function##_ptr)(__VA_ARGS__) +#else +#define CORECLR_HOSTING_API(function, ...) \ + int CORECLR_CALLING_CONVENTION function(__VA_ARGS__); \ + typedef int (CORECLR_CALLING_CONVENTION *function##_ptr)(__VA_ARGS__) +#endif // // Initialize the CoreCLR. Creates and starts CoreCLR host and creates an app domain diff --git a/src/coreclr/inc/crosscomp.h b/src/coreclr/inc/crosscomp.h index 50867accca1ac9..496d1c0247533e 100644 --- a/src/coreclr/inc/crosscomp.h +++ b/src/coreclr/inc/crosscomp.h @@ -17,7 +17,7 @@ #define MAKE_TARGET_DLLNAME_W(name) name W(".dll") #define MAKE_TARGET_DLLNAME_A(name) name ".dll" #else // TARGET_WINDOWS -#ifdef TARGET_OSX +#ifdef TARGET_APPLE #define MAKE_TARGET_DLLNAME_W(name) W("lib") name W(".dylib") #define MAKE_TARGET_DLLNAME_A(name) "lib" name ".dylib" #else @@ -686,9 +686,9 @@ typedef struct _T_KNONVOLATILE_CONTEXT_POINTERS { #if defined(TARGET_OSX) && defined(TARGET_X86) #define DAC_CS_NATIVE_DATA_SIZE 76 -#elif defined(TARGET_OSX) && defined(TARGET_AMD64) +#elif defined(TARGET_APPLE) && defined(TARGET_AMD64) #define DAC_CS_NATIVE_DATA_SIZE 120 -#elif defined(TARGET_OSX) && defined(TARGET_ARM64) +#elif defined(TARGET_APPLE) && defined(TARGET_ARM64) #define DAC_CS_NATIVE_DATA_SIZE 120 #elif defined(TARGET_FREEBSD) && defined(TARGET_X86) #define DAC_CS_NATIVE_DATA_SIZE 12 diff --git a/src/coreclr/inc/executableallocator.h b/src/coreclr/inc/executableallocator.h index 5b9c0d81dc5a2b..11caf3a6857d2d 100644 --- a/src/coreclr/inc/executableallocator.h +++ b/src/coreclr/inc/executableallocator.h @@ -285,7 +285,7 @@ class ExecutableWriterHolder void Unmap() { -#if defined(HOST_OSX) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) +#if defined(HOST_APPLE) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) if (m_addressRX != NULL) { PAL_JitWriteProtect(false); @@ -321,7 +321,7 @@ class ExecutableWriterHolder ExecutableWriterHolder(T* addressRX, size_t size, ExecutableAllocator::CacheableMapping cacheMapping = ExecutableAllocator::AddToCache) { m_addressRX = addressRX; -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) m_addressRW = addressRX; PAL_JitWriteProtect(true); #else diff --git a/src/coreclr/inc/targetosarch.h b/src/coreclr/inc/targetosarch.h index 06f22d8ee487b0..00fe5b70647e7d 100644 --- a/src/coreclr/inc/targetosarch.h +++ b/src/coreclr/inc/targetosarch.h @@ -22,7 +22,7 @@ class TargetOS static bool OSSettingConfigured; static bool IsApplePlatform; #else -#if defined(TARGET_OSX) +#if defined(TARGET_APPLE) static const bool IsApplePlatform = true; #else static const bool IsApplePlatform = false; diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 104a7be7f18202..c936b65a4a83ce 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -624,7 +624,7 @@ set(JIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # Creates a static library "clrjit_static" to link into the VM. add_subdirectory(static) -if (CLR_CMAKE_TARGET_OSX) +if (CLR_CMAKE_TARGET_APPLE) set(TARGET_OS_NAME unix_osx) elseif (CLR_CMAKE_TARGET_UNIX) set(TARGET_OS_NAME unix) diff --git a/src/coreclr/minipal/Unix/doublemapping.cpp b/src/coreclr/minipal/Unix/doublemapping.cpp index ba43e72a0c673c..35879fdc6b5cef 100644 --- a/src/coreclr/minipal/Unix/doublemapping.cpp +++ b/src/coreclr/minipal/Unix/doublemapping.cpp @@ -22,11 +22,11 @@ #include "minipal.h" #include "minipal/cpufeatures.h" -#ifdef TARGET_OSX +#ifdef TARGET_APPLE #include -#else // TARGET_OSX +#else // TARGET_APPLE #ifdef TARGET_64BIT static const off_t MaxDoubleMappedSize = 2048ULL*1024*1024*1024; @@ -34,7 +34,7 @@ static const off_t MaxDoubleMappedSize = 2048ULL*1024*1024*1024; static const off_t MaxDoubleMappedSize = UINT_MAX; #endif -#endif // TARGET_OSX +#endif // TARGET_APPLE bool VMToOSInterface::CreateDoubleMemoryMapper(void** pHandle, size_t *pMaxExecutableCodeSize) { @@ -44,7 +44,7 @@ bool VMToOSInterface::CreateDoubleMemoryMapper(void** pHandle, size_t *pMaxExecu return false; } -#ifndef TARGET_OSX +#ifndef TARGET_APPLE #ifdef TARGET_FREEBSD int fd = shm_open(SHM_ANON, O_RDWR | O_CREAT, S_IRWXU); @@ -78,25 +78,25 @@ bool VMToOSInterface::CreateDoubleMemoryMapper(void** pHandle, size_t *pMaxExecu *pMaxExecutableCodeSize = MaxDoubleMappedSize; *pHandle = (void*)(size_t)fd; -#else // !TARGET_OSX +#else // !TARGET_APPLE *pMaxExecutableCodeSize = SIZE_MAX; *pHandle = NULL; -#endif // !TARGET_OSX +#endif // !TARGET_APPLE return true; } void VMToOSInterface::DestroyDoubleMemoryMapper(void *mapperHandle) { -#ifndef TARGET_OSX +#ifndef TARGET_APPLE close((int)(size_t)mapperHandle); #endif } extern "C" void* PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange(const void* lpBeginAddress, const void* lpEndAddress, size_t dwSize, int fStoreAllocationInfo); -#ifdef TARGET_OSX +#ifdef TARGET_APPLE bool IsMapJitFlagNeeded() { static volatile int isMapJitFlagNeeded = -1; @@ -127,7 +127,7 @@ bool IsMapJitFlagNeeded() return (bool)isMapJitFlagNeeded; } -#endif // TARGET_OSX +#endif // TARGET_APPLE void* VMToOSInterface::ReserveDoubleMappedMemory(void *mapperHandle, size_t offset, size_t size, const void *rangeStart, const void* rangeEnd) { @@ -141,7 +141,7 @@ void* VMToOSInterface::ReserveDoubleMappedMemory(void *mapperHandle, size_t offs } void* result = PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange(rangeStart, rangeEnd, size, 0 /* fStoreAllocationInfo */); -#ifndef TARGET_OSX +#ifndef TARGET_APPLE int mmapFlags = MAP_SHARED; #ifdef TARGET_HAIKU mmapFlags |= MAP_NORESERVE; @@ -156,7 +156,7 @@ void* VMToOSInterface::ReserveDoubleMappedMemory(void *mapperHandle, size_t offs result = NULL; } } -#endif // TARGET_OSX +#endif // TARGET_APPLE // For requests with limited range, don't try to fall back to reserving at any address if ((result != NULL) || !isUnlimitedRange) @@ -164,7 +164,7 @@ void* VMToOSInterface::ReserveDoubleMappedMemory(void *mapperHandle, size_t offs return result; } -#ifndef TARGET_OSX +#ifndef TARGET_APPLE result = mmap(NULL, size, PROT_NONE, mmapFlags, fd, offset); #else int mmapFlags = MAP_ANON | MAP_PRIVATE; @@ -194,20 +194,20 @@ void *VMToOSInterface::CommitDoubleMappedMemory(void* pStart, size_t size, bool bool VMToOSInterface::ReleaseDoubleMappedMemory(void *mapperHandle, void* pStart, size_t offset, size_t size) { -#ifndef TARGET_OSX +#ifndef TARGET_APPLE int fd = (int)(size_t)mapperHandle; if (mmap(pStart, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, offset) == MAP_FAILED) { return false; } memset(pStart, 0, size); -#endif // TARGET_OSX +#endif // TARGET_APPLE return munmap(pStart, size) != -1; } void* VMToOSInterface::GetRWMapping(void *mapperHandle, void* pStart, size_t offset, size_t size) { -#ifndef TARGET_OSX +#ifndef TARGET_APPLE int fd = (int)(size_t)mapperHandle; void* result = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset); if (result == MAP_FAILED) @@ -215,7 +215,7 @@ void* VMToOSInterface::GetRWMapping(void *mapperHandle, void* pStart, size_t off result = NULL; } return result; -#else // TARGET_OSX +#else // TARGET_APPLE #ifdef TARGET_AMD64 vm_address_t startRW; vm_prot_t curProtection, maxProtection; @@ -240,7 +240,7 @@ void* VMToOSInterface::GetRWMapping(void *mapperHandle, void* pStart, size_t off assert(false); return NULL; #endif // TARGET_AMD64 -#endif // TARGET_OSX +#endif // TARGET_APPLE } bool VMToOSInterface::ReleaseRWMapping(void* pStart, size_t size) diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 032b888863ef8b..fdeba4572e469a 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -2871,14 +2871,14 @@ VirtualFree( IN DWORD dwFreeType); -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) PALIMPORT VOID PALAPI PAL_JitWriteProtect(bool writeEnable); -#endif // defined(HOST_OSX) && defined(HOST_ARM64) +#endif // defined(HOST_APPLE) && defined(HOST_ARM64) PALIMPORT diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 07c81a0661352e..06dc3919c230d0 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -1,8 +1,8 @@ -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_HAIKU) +if(CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_HAIKU) # On OSX and *BSD, we use the libunwind that's part of the OS # On Haiku, we used a special port of libunwind set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) -endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_HAIKU) +endif(CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_HAIKU) if(NOT DEFINED ENV{ROOTFS_DIR}) include_directories(SYSTEM /usr/local/include) @@ -17,7 +17,7 @@ if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND) include_directories(${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind/include/tdep) add_subdirectory(${CLR_SRC_NATIVE_DIR}/external/libunwind_extras ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind) -elseif(NOT CLR_CMAKE_TARGET_OSX) +elseif(NOT CLR_CMAKE_TARGET_APPLE) find_unwind_libs(UNWIND_LIBS) else() add_subdirectory(${CLR_SRC_NATIVE_DIR}/external/libunwind_extras ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind) @@ -70,13 +70,18 @@ if(CLR_CMAKE_TARGET_OSX) if(CLR_CMAKE_HOST_ARCH_AMD64) add_definitions(-DXSTATE_SUPPORTED) endif() +endif() + +if(CLR_CMAKE_TARGET_APPLE) + add_definitions(-DTARGET_APPLE) + add_definitions(-D_XOPEN_SOURCE) set(PLATFORM_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/context.S arch/${PAL_ARCH_SOURCES_DIR}/dispatchexceptionwrapper.S exception/machexception.cpp exception/machmessage.cpp ) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_APPLE) if (FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) add_definitions(-DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) @@ -116,12 +121,12 @@ set(ARCH_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/exceptionhelper.S ) -if(NOT CLR_CMAKE_TARGET_OSX) +if(NOT CLR_CMAKE_TARGET_APPLE) list(APPEND PLATFORM_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/callsignalhandlerwrapper.S arch/${PAL_ARCH_SOURCES_DIR}/signalhandlerhelper.cpp ) -endif(NOT CLR_CMAKE_TARGET_OSX) +endif(NOT CLR_CMAKE_TARGET_APPLE) if(CLR_CMAKE_HOST_ARCH_ARM) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -220,7 +225,7 @@ add_library(coreclrpal ) # Build separate pal library for DAC (addition to regular pal library) -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_APPLE) set(LIBUNWIND_DAC_OBJECTS $) add_library(coreclrpal_dac STATIC @@ -242,7 +247,7 @@ else() exception/remote-unwind.cpp ) endif(NOT FEATURE_CROSSBITNESS) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_APPLE) # There is only one function exported in 'tracepointprovider.cpp' namely 'PAL_InitializeTracing', # which is guarded with '#if defined(__linux__)'. On macOS, Xcode issues the following warning: diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake index 8dd44c550ba5db..db41cc5f6a0f6e 100644 --- a/src/coreclr/pal/src/configure.cmake +++ b/src/coreclr/pal/src/configure.cmake @@ -14,7 +14,7 @@ elseif(CLR_CMAKE_TARGET_SUNOS) set(CMAKE_REQUIRED_INCLUDES /opt/local/include) endif() -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_APPLE) set(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE) elseif(NOT CLR_CMAKE_TARGET_FREEBSD AND NOT CLR_CMAKE_TARGET_NETBSD) set(CMAKE_REQUIRED_DEFINITIONS "-D_BSD_SOURCE -D_SVID_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L") @@ -904,7 +904,7 @@ if(NOT CLR_CMAKE_HOST_ARCH_ARM AND NOT CLR_CMAKE_HOST_ARCH_ARM64) set(CMAKE_REQUIRED_LIBRARIES) endif() -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_APPLE) set(HAVE__NSGETENVIRON 1) set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 1) set(PAL_PTRACE "ptrace((cmd), (pid), (caddr_t)(addr), (data))") @@ -943,7 +943,7 @@ else() # Anything else is Linux set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0) set(PAL_PTRACE "ptrace((cmd), (pid), (void*)(addr), (data))") set(HAVE_SCHED_OTHER_ASSIGNABLE 1) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_APPLE) check_struct_has_member( "struct statfs" diff --git a/src/coreclr/pal/src/debug/debug.cpp b/src/coreclr/pal/src/debug/debug.cpp index 8783ff48603219..5f598a65494bb1 100644 --- a/src/coreclr/pal/src/debug/debug.cpp +++ b/src/coreclr/pal/src/debug/debug.cpp @@ -60,7 +60,9 @@ SET_DEFAULT_DEBUG_CHANNEL(DEBUG); // some headers have code with asserts, so do #ifdef __APPLE__ #include +#if defined(TARGET_OSX) #include +#endif #endif // __APPLE__ #if HAVE_MACH_EXCEPTIONS diff --git a/src/coreclr/pal/src/exception/seh-unwind.cpp b/src/coreclr/pal/src/exception/seh-unwind.cpp index 71e94f929cf33f..04a12b6956b506 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -44,7 +44,7 @@ Module Name: #endif // HOST_UNIX -#if defined(TARGET_OSX) && defined(HOST_ARM64) && !defined(HAVE_UNW_AARCH64_X19) +#if defined(TARGET_APPLE) && defined(HOST_ARM64) && !defined(HAVE_UNW_AARCH64_X19) // MacOS uses ARM64 instead of AARCH64 to describe these registers // Create aliases to reuse more code enum @@ -86,7 +86,7 @@ enum UNW_AARCH64_V30 = UNW_ARM64_D30, UNW_AARCH64_V31 = UNW_ARM64_D31 }; -#endif // defined(TARGET_OSX) && defined(HOST_ARM64) +#endif // defined(TARGET_APPLE) && defined(HOST_ARM64) //---------------------------------------------------------------------- @@ -260,7 +260,7 @@ static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwCon { unwContext->fpregs[i] = winContext->D[i]; } -#elif defined(HOST_ARM64) && !defined(TARGET_OSX) +#elif defined(HOST_ARM64) && !defined(TARGET_APPLE) unwContext->uc_mcontext.pc = winContext->Pc; unwContext->uc_mcontext.sp = winContext->Sp; unwContext->uc_mcontext.regs[29] = winContext->Fp; @@ -302,7 +302,7 @@ static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor) unw_set_reg(cursor, UNW_X86_EBX, winContext->Ebx); unw_set_reg(cursor, UNW_X86_ESI, winContext->Esi); unw_set_reg(cursor, UNW_X86_EDI, winContext->Edi); -#elif defined(HOST_ARM64) && defined(TARGET_OSX) +#elif defined(HOST_ARM64) && defined(TARGET_APPLE) // unw_cursor_t is an opaque data structure on macOS // As noted in WinContextToUnwindContext this didn't work for Linux // TBD whether this will work for macOS. @@ -426,12 +426,12 @@ void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_fpreg(cursor, UNW_AARCH64_V30, (unw_fpreg_t*)&winContext->V[30].Low); unw_get_fpreg(cursor, UNW_AARCH64_V31, (unw_fpreg_t*)&winContext->V[31].Low); -#if defined(TARGET_OSX) && defined(TARGET_ARM64) +#if defined(TARGET_APPLE) && defined(TARGET_ARM64) // Strip pointer authentication bits which seem to be leaking out of libunwind // Seems like ptrauth_strip() / __builtin_ptrauth_strip() should work, but currently // errors with "this target does not support pointer authentication" winContext->Pc = winContext->Pc & 0x7fffffffffffull; -#endif // defined(TARGET_OSX) && defined(TARGET_ARM64) +#endif // defined(TARGET_APPLE) && defined(TARGET_ARM64) #elif (defined(HOST_UNIX) && defined(HOST_S390X)) unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->R15); unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->PSWAddr); diff --git a/src/coreclr/pal/src/include/pal/context.h b/src/coreclr/pal/src/include/pal/context.h index 5d515a1434e00c..f769da2a615505 100644 --- a/src/coreclr/pal/src/include/pal/context.h +++ b/src/coreclr/pal/src/include/pal/context.h @@ -63,7 +63,7 @@ bool Xstate_IsAvx512Supported(); bool Xstate_IsApxSupported(); #endif // XSTATE_SUPPORTED || (HOST_AMD64 && HAVE_MACH_EXCEPTIONS) -#if defined(HOST_64BIT) && defined(HOST_ARM64) && !defined(TARGET_FREEBSD) && !defined(TARGET_OSX) +#if defined(HOST_64BIT) && defined(HOST_ARM64) && !defined(TARGET_FREEBSD) && !defined(TARGET_APPLE) #if !defined(SVE_MAGIC) // Add the missing SVE defines @@ -145,7 +145,7 @@ struct sve_context { (SVE_SIG_REGS_OFFSET + SVE_SIG_REGS_SIZE(vq)) #endif // SVE_MAGIC -#endif // HOST_64BIT && HOST_ARM64 && !TARGET_FREEBSD && !TARGET_OSX +#endif // HOST_64BIT && HOST_ARM64 && !TARGET_FREEBSD && !TARGET_APPLE #ifdef HOST_S390X @@ -740,7 +740,7 @@ const struct fpregs* GetConstNativeSigSimdContext(const native_context_t *mc) return GetNativeSigSimdContext(const_cast(mc)); } -#elif !defined(TARGET_OSX) // TARGET_FREEBSD +#elif !defined(TARGET_APPLE) // TARGET_FREEBSD #define MCREG_X0(mc) ((mc).regs[0]) #define MCREG_X1(mc) ((mc).regs[1]) @@ -792,7 +792,7 @@ void GetConstNativeSigSimdContext(const native_context_t *mc, fpsimd_context con GetNativeSigSimdContext(const_cast(mc), const_cast(fp_ptr), const_cast(sve_ptr)); } -#else // TARGET_OSX +#else // TARGET_APPLE #define MCREG_X0(mc) ((mc)->__ss.__x[0]) #define MCREG_X1(mc) ((mc)->__ss.__x[1]) @@ -842,7 +842,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex return GetNativeSigSimdContext(const_cast(mc)); } -#endif // TARGET_OSX +#endif // TARGET_APPLE #elif defined(HOST_LOONGARCH64) @@ -882,7 +882,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex #else // HOST_ARM64 -#ifdef TARGET_OSX +#ifdef TARGET_APPLE #define MCREG_Rbp(mc) ((mc)->__ss.__rbp) #define MCREG_Rip(mc) ((mc)->__ss.__rip) @@ -1002,7 +1002,7 @@ inline void *FPREG_Xstate_Hi16Zmm(const ucontext_t *uc, uint32_t *featureSize) #define FPREG_Xmm(uc, index) *(M128A*) &(FPSTATE(uc).fp_fxsave.xmm[index]) #define FPREG_St(uc, index) *(M128A*) &(FPSTATE(uc).fp_fxsave.fp[index].value) -#else //TARGET_OSX +#else //TARGET_APPLE // For FreeBSD, as found in x86/ucontext.h #define MCREG_Rbp(mc) ((mc).mc_rbp) @@ -1039,7 +1039,7 @@ inline void *FPREG_Xstate_Hi16Zmm(const ucontext_t *uc, uint32_t *featureSize) #define FPREG_Xmm(uc, index) *(M128A*) &(FPSTATE(uc)->sv_xmm[index]) #define FPREG_St(uc, index) *(M128A*) &(FPSTATE(uc)->sv_fp[index].fp_acc) -#endif // TARGET_OSX +#endif // TARGET_APPLE #endif // HOST_ARM64 #else // HOST_64BIT diff --git a/src/coreclr/pal/src/include/pal/dbgmsg.h b/src/coreclr/pal/src/include/pal/dbgmsg.h index ca8d1454de9143..0d0c5e4aed4cee 100644 --- a/src/coreclr/pal/src/include/pal/dbgmsg.h +++ b/src/coreclr/pal/src/include/pal/dbgmsg.h @@ -494,7 +494,7 @@ if new_level is -1, the nesting level will not be modified --*/ int DBG_change_entrylevel(int new_level); -#ifdef __APPLE__ +#ifdef TARGET_OSX /*++ Function : PAL_DisplayDialog @@ -514,10 +514,10 @@ Function : --*/ void PAL_DisplayDialogFormatted(const char *szTitle, const char *szTextFormat, ...); -#else // __APPLE__ +#else // TARGET_OSX #define PAL_DisplayDialog(_szTitle, _szText) #define PAL_DisplayDialogFormatted(_szTitle, _szTextFormat, args...) -#endif // __APPLE__ +#endif // TARGET_OSX #ifdef __cplusplus } diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 16df9848d9b779..a5b04430d410e7 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -39,12 +39,17 @@ SET_DEFAULT_DEBUG_CHANNEL(VIRTUAL); // some headers have code with asserts, so d #include #include #include +#include #if HAVE_VM_ALLOCATE #include #include #endif // HAVE_VM_ALLOCATE +#if defined(TARGET_APPLE) && !defined(TARGET_OSX) +#include +#endif + using namespace CorUnix; CRITICAL_SECTION virtual_critsec; @@ -1234,7 +1239,30 @@ VirtualProtect( return bRetVal; } -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) + +#if defined(TARGET_APPLE) && !defined(TARGET_OSX) + +void +(*jit_write_protect_np)(int enabled); + +static struct jit_write_protect_helper +{ + jit_write_protect_helper() + { + jit_write_protect_np = (void (*)(int))dlsym(RTLD_DEFAULT, "pthread_jit_write_protect_np"); + if (jit_write_protect_np == NULL) + { + ERROR( "pthread_jit_write_protect_np not available.\n" ); + exit(1); + } + } +} jit_write_protect_helper; + +#define pthread_jit_write_protect_np jit_write_protect_np + +#endif + PALAPI VOID PAL_JitWriteProtect(bool writeEnable) { thread_local int enabledCount = 0; diff --git a/src/coreclr/pal/src/misc/dbgmsg.cpp b/src/coreclr/pal/src/misc/dbgmsg.cpp index 4c22dfb4e4716b..3a1da44c9b79c1 100644 --- a/src/coreclr/pal/src/misc/dbgmsg.cpp +++ b/src/coreclr/pal/src/misc/dbgmsg.cpp @@ -733,7 +733,7 @@ bool DBG_ShouldCheckStackAlignment() } #endif // _DEBUG && __APPLE__ -#ifdef __APPLE__ +#if defined(TARGET_OSX) #include "CoreFoundation/CFUserNotification.h" #include "CoreFoundation/CFString.h" #include "Security/AuthSession.h" @@ -853,4 +853,4 @@ void PAL_DisplayDialogFormatted(const char *szTitle, const char *szTextFormat, . va_end(args); } -#endif // __APPLE__ +#endif // TARGET_OSX diff --git a/src/coreclr/pal/src/misc/sysinfo.cpp b/src/coreclr/pal/src/misc/sysinfo.cpp index d2d5af184f2fc4..e0f8af8c6e7c23 100644 --- a/src/coreclr/pal/src/misc/sysinfo.cpp +++ b/src/coreclr/pal/src/misc/sysinfo.cpp @@ -58,12 +58,12 @@ Revision History: #include #endif // HAVE_MACHINE_VMPARAM_H -#if defined(TARGET_OSX) +#if defined(TARGET_APPLE) #include #include #include #include -#endif // defined(TARGET_OSX) +#endif // defined(TARGET_APPLE) #ifdef __HAIKU__ #include @@ -217,6 +217,8 @@ GetSystemInfo( lpSystemInfo->lpMaximumApplicationAddress = (PVOID) (1ull << 47); #elif defined(__sun) lpSystemInfo->lpMaximumApplicationAddress = (PVOID) 0xfffffd7fffe00000ul; +#elif defined(VM_MAX_PAGE_ADDRESS) + lpSystemInfo->lpMaximumApplicationAddress = (PVOID) VM_MAX_PAGE_ADDRESS; #elif defined(__HAIKU__) lpSystemInfo->lpMaximumApplicationAddress = (PVOID) 0x7fffffe00000ul; #elif defined(USERLIMIT) diff --git a/src/coreclr/pal/src/thread/context.cpp b/src/coreclr/pal/src/thread/context.cpp index ecd252936299df..e3c33c7468673a 100644 --- a/src/coreclr/pal/src/thread/context.cpp +++ b/src/coreclr/pal/src/thread/context.cpp @@ -29,6 +29,9 @@ SET_DEFAULT_DEBUG_CHANNEL(THREAD); // some headers have code with asserts, so do #endif #include #include +#if defined(HOST_APPLE) && !defined(HOST_OSX) +#include +#endif extern PGET_GCMARKER_EXCEPTION_CODE g_getGcMarkerExceptionCode; @@ -722,7 +725,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) #endif // (HAVE_GREGSET_T || HAVE___GREGSET_T) && !HOST_S390X && !HOST_LOONGARCH64 && !HOST_RISCV64 && !HOST_POWERPC64 #endif // !HAVE_FPREGS_WITH_CW -#if defined(HOST_ARM64) && !defined(TARGET_OSX) && !defined(TARGET_FREEBSD) +#if defined(HOST_ARM64) && !defined(TARGET_APPLE) && !defined(TARGET_FREEBSD) sve_context* sve = nullptr; fpsimd_context* fp = nullptr; if (((lpContext->ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) || @@ -730,7 +733,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) { GetNativeSigSimdContext(native, &fp, &sve); } -#endif // HOST_ARM64 && !TARGET_OSX && !TARGET_FREEBSD +#endif // HOST_ARM64 && !TARGET_APPLE && !TARGET_FREEBSD if ((lpContext->ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) { @@ -760,7 +763,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) FPREG_Xmm(native, i) = lpContext->FltSave.XmmRegisters[i]; } #elif defined(HOST_ARM64) -#ifdef TARGET_OSX +#ifdef TARGET_APPLE _STRUCT_ARM_NEON_STATE64* fp = GetNativeSigSimdContext(native); fp->__fpsr = lpContext->Fpsr; fp->__fpcr = lpContext->Fpcr; @@ -779,7 +782,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->fp_q[i] = lpContext->V[i]; } } -#else // TARGET_OSX +#else // TARGET_APPLE if (fp) { fp->fpsr = lpContext->Fpsr; @@ -789,7 +792,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->vregs[i] = lpContext->V[i]; } } -#endif // TARGET_OSX +#endif // TARGET_APPLE #elif defined(HOST_ARM) VfpSigFrame* fp = GetNativeSigSimdContext(native); if (fp) @@ -917,7 +920,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) } -#if defined(HOST_64BIT) && defined(HOST_ARM64) && !defined(TARGET_FREEBSD) && !defined(TARGET_OSX) +#if defined(HOST_64BIT) && defined(HOST_ARM64) && !defined(TARGET_FREEBSD) && !defined(TARGET_APPLE) /*++ Function : _GetNativeSigSimdContext @@ -1007,7 +1010,7 @@ void _GetNativeSigSimdContext(uint8_t *data, uint32_t size, fpsimd_context **fp_ *sve_ptr = sve; } } -#endif // HOST_64BIT && HOST_ARM64 && !TARGET_FREEBSD && !TARGET_OSX +#endif // HOST_64BIT && HOST_ARM64 && !TARGET_FREEBSD && !TARGET_APPLE /*++ Function : @@ -1074,7 +1077,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex #endif // (HAVE_GREGSET_T || HAVE___GREGSET_T) && !HOST_S390X && !HOST_LOONGARCH64 && !HOST_RISCV64 && !HOST_POWERPC64 && !HOST_POWERPC64 #endif // !HAVE_FPREGS_WITH_CW -#if defined(HOST_ARM64) && !defined(TARGET_OSX) && !defined(TARGET_FREEBSD) +#if defined(HOST_ARM64) && !defined(TARGET_APPLE) && !defined(TARGET_FREEBSD) const fpsimd_context* fp = nullptr; const sve_context* sve = nullptr; if (((lpContext->ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) || @@ -1082,7 +1085,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex { GetConstNativeSigSimdContext(native, &fp, &sve); } -#endif // HOST_ARM64 && !TARGET_OSX && !TARGET_FREEBSD +#endif // HOST_ARM64 && !TARGET_APPLE && !TARGET_FREEBSD if ((contextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) { @@ -1111,7 +1114,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->FltSave.XmmRegisters[i] = FPREG_Xmm(native, i); } #elif defined(HOST_ARM64) -#ifdef TARGET_OSX +#ifdef TARGET_APPLE const _STRUCT_ARM_NEON_STATE64* fp = GetConstNativeSigSimdContext(native); lpContext->Fpsr = fp->__fpsr; lpContext->Fpcr = fp->__fpcr; @@ -1130,7 +1133,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->fp_q[i]; } } -#else // TARGET_OSX +#else // TARGET_APPLE if (fp) { lpContext->Fpsr = fp->fpsr; @@ -1140,7 +1143,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->vregs[i]; } } -#endif // TARGET_OSX +#endif // TARGET_APPLE #elif defined(HOST_ARM) const VfpSigFrame* fp = GetConstNativeSigSimdContext(native); if (fp) @@ -2181,6 +2184,8 @@ DBG_FlushInstructionCache( #endif syscall(__NR_riscv_flush_icache, (char *)lpBaseAddress, (char *)((INT_PTR)lpBaseAddress + dwSize), 0 /* all harts */); +#elif defined(HOST_APPLE) && !defined(HOST_OSX) + sys_icache_invalidate((void *)lpBaseAddress, dwSize); #else __builtin___clear_cache((char *)lpBaseAddress, (char *)((INT_PTR)lpBaseAddress + dwSize)); #endif diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index 8b51ec971800a8..cb773406dc8bce 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -84,10 +84,8 @@ SET_DEFAULT_DEBUG_CHANNEL(PROCESS); // some headers have code with asserts, so d #endif #ifdef __APPLE__ -#include #include #include -#include #include #include extern "C" @@ -227,7 +225,7 @@ PathCharString* gSharedFilesPath = nullptr; #if defined(__NetBSD__) #define CLR_SEM_MAX_NAMELEN 15 #elif defined(__APPLE__) -#define CLR_SEM_MAX_NAMELEN PSEMNAMLEN +#define CLR_SEM_MAX_NAMELEN 31 #elif defined(NAME_MAX) #define CLR_SEM_MAX_NAMELEN (NAME_MAX - 4) #else @@ -2212,6 +2210,9 @@ PROCCreateCrashDump( INT cbErrorMessageBuffer, bool serialize) { +#if defined(TARGET_IOS) + return FALSE; +#else _ASSERTE(argv.size() > 0); _ASSERTE(errorMessageBuffer == nullptr || cbErrorMessageBuffer > 0); @@ -2339,6 +2340,7 @@ PROCCreateCrashDump( } } return true; +#endif // !TARGET_IOS } /*++ @@ -2609,7 +2611,7 @@ InitializeFlushProcessWriteBuffers() } } -#ifdef TARGET_OSX +#ifdef TARGET_APPLE return TRUE; #else s_helperPage = static_cast(mmap(0, GetVirtualPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); @@ -2639,7 +2641,7 @@ InitializeFlushProcessWriteBuffers() } return status == 0; -#endif // TARGET_OSX +#endif // TARGET_APPLE } #define FATAL_ASSERT(e, msg) \ @@ -2689,7 +2691,7 @@ FlushProcessWriteBuffers() status = pthread_mutex_unlock(&flushProcessWriteBuffersMutex); FATAL_ASSERT(status == 0, "Failed to unlock the flushProcessWriteBuffersMutex lock"); } -#ifdef TARGET_OSX +#ifdef TARGET_APPLE else { mach_msg_type_number_t cThreads; @@ -2718,7 +2720,7 @@ FlushProcessWriteBuffers() machret = vm_deallocate(mach_task_self(), (vm_address_t)pThreads, cThreads * sizeof(thread_act_t)); CHECK_MACH("vm_deallocate()", machret); } -#endif // TARGET_OSX +#endif // TARGET_APPLE } /*++ diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TargetExtensions.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TargetExtensions.cs index 59a0567d790f20..ef76a9abcce5bb 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TargetExtensions.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TargetExtensions.cs @@ -112,6 +112,11 @@ public static MachineOSOverride MachineOSOverrideFromTarget(this TargetDetails t return MachineOSOverride.Linux; case TargetOS.OSX: + case TargetOS.MacCatalyst: + case TargetOS.iOS: + case TargetOS.iOSSimulator: + case TargetOS.tvOS: + case TargetOS.tvOSSimulator: return MachineOSOverride.Apple; case TargetOS.FreeBSD: diff --git a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs index 0f24eceeed0eb2..6265d0df45b65b 100644 --- a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs +++ b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs @@ -295,7 +295,7 @@ public static IEnumerable> GetExtendedHelp(HelpContext _ Console.WriteLine(); string[] ValidArchitectures = new string[] {"arm", "armel", "arm64", "x86", "x64", "riscv64", "loongarch64"}; - string[] ValidOS = new string[] {"windows", "linux", "osx"}; + string[] ValidOS = new string[] {"windows", "linux", "osx", "ios", "iossimulator", "maccatalyst"}; Console.WriteLine(String.Format(SR.SwitchWithDefaultHelp, "--targetos", String.Join("', '", ValidOS), Helpers.GetTargetOS(null).ToString().ToLowerInvariant())); Console.WriteLine(); diff --git a/src/coreclr/tools/aot/jitinterface/jitwrapper.cpp b/src/coreclr/tools/aot/jitinterface/jitwrapper.cpp index 8fd38d192f84e9..48cf7ece4a12b9 100644 --- a/src/coreclr/tools/aot/jitinterface/jitwrapper.cpp +++ b/src/coreclr/tools/aot/jitinterface/jitwrapper.cpp @@ -55,5 +55,9 @@ DLL_EXPORT void JitProcessShutdownWork(ICorJitCompiler * pJit) DLL_EXPORT int JitGetProcessorFeatures() { +#ifndef CROSS_COMPILE return minipal_getcpufeatures(); +#else + return 0; +#endif } diff --git a/src/coreclr/utilcode/executableallocator.cpp b/src/coreclr/utilcode/executableallocator.cpp index 8ee089c4ccfb0f..eb20b6ab4668bb 100644 --- a/src/coreclr/utilcode/executableallocator.cpp +++ b/src/coreclr/utilcode/executableallocator.cpp @@ -124,7 +124,7 @@ bool ExecutableAllocator::IsDoubleMappingEnabled() { LIMITED_METHOD_CONTRACT; -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) return false; #else return g_isWXorXEnabled; @@ -135,7 +135,7 @@ bool ExecutableAllocator::IsWXORXEnabled() { LIMITED_METHOD_CONTRACT; -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) return true; #else return g_isWXorXEnabled; diff --git a/src/coreclr/vm/amd64/asmhelpers.S b/src/coreclr/vm/amd64/asmhelpers.S index 6bce2d2f2d3436..6b3883528e6f80 100644 --- a/src/coreclr/vm/amd64/asmhelpers.S +++ b/src/coreclr/vm/amd64/asmhelpers.S @@ -279,7 +279,7 @@ NESTED_ENTRY ProfileTailcallNaked, _TEXT, NoHandler ret NESTED_END ProfileTailcallNaked, _TEXT -#ifdef TARGET_OSX +#ifdef TARGET_APPLE # EXTERN_C void* GetThreadVarsAddress() # # Helper to calculate the address of relevant __thread_vars section that holds the address of symbol tlv_get_address for thread @@ -291,9 +291,9 @@ LEAF_ENTRY GetThreadVarsAddress, _TEXT ret LEAF_END GetThreadVarsAddress, _TEXT // ------------------------------------------------------------------ -#endif // TARGET_OSX +#endif // TARGET_APPLE -#ifndef TARGET_OSX +#ifndef TARGET_APPLE # EXTERN_C void* GetTlsIndexObjectDescOffset(); # diff --git a/src/coreclr/vm/amd64/jithelpers_fast.S b/src/coreclr/vm/amd64/jithelpers_fast.S index 96195353db2904..b4b1df87c73bd8 100644 --- a/src/coreclr/vm/amd64/jithelpers_fast.S +++ b/src/coreclr/vm/amd64/jithelpers_fast.S @@ -215,7 +215,7 @@ LEAF_END_MARKED JIT_ByRefWriteBarrier, _TEXT // When JIT_WriteBarrier is copied into an allocated page, // helpers use this global variable to jump to it. This variable is set in InitThreadManager. .global C_FUNC(JIT_WriteBarrier_Loc) -#ifdef TARGET_OSX +#ifdef TARGET_APPLE .zerofill __DATA,__common,C_FUNC(JIT_WriteBarrier_Loc),8,3 #else .data diff --git a/src/coreclr/vm/arm64/asmhelpers.S b/src/coreclr/vm/arm64/asmhelpers.S index d40d210dfb03ad..2f6390e3724ed0 100644 --- a/src/coreclr/vm/arm64/asmhelpers.S +++ b/src/coreclr/vm/arm64/asmhelpers.S @@ -757,7 +757,7 @@ LEAF_ENTRY JIT_DispatchIndirectCall, _TEXT br x9 LEAF_END JIT_DispatchIndirectCall, _TEXT -#ifdef TARGET_OSX +#ifdef TARGET_APPLE // ------------------------------------------------------------------ // void* GetThreadVarsAddress() @@ -771,9 +771,9 @@ LEAF_ENTRY GetThreadVarsAddress, _TEXT ret LEAF_END GetThreadVarsAddress, _TEXT // ------------------------------------------------------------------ -#endif // TARGET_OSX +#endif // TARGET_APPLE -#ifndef TARGET_OSX +#ifndef TARGET_APPLE // ------------------------------------------------------------------ // size_t GetThreadStaticsVariableOffset() @@ -805,7 +805,7 @@ LEAF_ENTRY GetTLSResolverAddress, _TEXT EPILOG_RETURN LEAF_END GetTLSResolverAddress, _TEXT // ------------------------------------------------------------------ -#endif // !TARGET_OSX +#endif // !TARGET_APPLE LEAF_ENTRY JIT_PollGC, _TEXT PREPARE_EXTERNAL_VAR g_TrapReturningThreads, x9 diff --git a/src/coreclr/vm/arm64/stubs.cpp b/src/coreclr/vm/arm64/stubs.cpp index 6c7b02bab13e9e..fdc54c5815918a 100644 --- a/src/coreclr/vm/arm64/stubs.cpp +++ b/src/coreclr/vm/arm64/stubs.cpp @@ -1372,7 +1372,7 @@ VOID StubLinkerCPU::EmitShuffleThunk(ShuffleEntry *pShuffleEntryArray) _ASSERTE(!(pEntry->dstofs & ShuffleEntry::FPREGMASK)); -#if !defined(TARGET_OSX) +#if !defined(TARGET_APPLE) EmitLoadStoreRegImm(eLOAD, IntReg(pEntry->dstofs & ShuffleEntry::OFSREGMASK), RegSp, pEntry->srcofs * sizeof(void*)); #else int log2Size = (pEntry->srcofs >> 12); @@ -1388,7 +1388,7 @@ VOID StubLinkerCPU::EmitShuffleThunk(ShuffleEntry *pShuffleEntryArray) // dest must be on the stack _ASSERTE(!(pEntry->dstofs & ShuffleEntry::REGMASK)); -#if !defined(TARGET_OSX) +#if !defined(TARGET_APPLE) EmitLoadStoreRegImm(eLOAD, IntReg(9), RegSp, pEntry->srcofs * sizeof(void*)); EmitLoadStoreRegImm(eSTORE, IntReg(9), RegSp, pEntry->dstofs * sizeof(void*)); #else diff --git a/src/coreclr/vm/cdacplatformmetadata.cpp b/src/coreclr/vm/cdacplatformmetadata.cpp index b89c90fae7ed80..0c9c1233e94870 100644 --- a/src/coreclr/vm/cdacplatformmetadata.cpp +++ b/src/coreclr/vm/cdacplatformmetadata.cpp @@ -11,7 +11,7 @@ void CDacPlatformMetadata::Init() PrecodeMachineDescriptor::Init(&g_cdacPlatformMetadata.precode); #if defined(TARGET_ARM) g_cdacPlatformMetadata.codePointerFlags = CDacCodePointerFlags::HasArm32ThumbBit; -#elif defined(TARGET_ARM64) && defined(TARGET_OSX) +#elif defined(TARGET_ARM64) && defined(TARGET_APPLE) // TODO set HasArm64PtrAuth if arm64e g_cdacPlatformMetadata.codePointerFlags = CDacCodePointerFlags::None; #else diff --git a/src/coreclr/vm/comdelegate.cpp b/src/coreclr/vm/comdelegate.cpp index 18fb1f1e103284..3f5f598956d273 100644 --- a/src/coreclr/vm/comdelegate.cpp +++ b/src/coreclr/vm/comdelegate.cpp @@ -211,7 +211,7 @@ class ShuffleIterator { const unsigned byteIndex = m_argLocDesc->m_byteStackIndex + m_currentByteStackIndex; -#if !defined(TARGET_OSX) || !defined(TARGET_ARM64) +#if !defined(TARGET_APPLE) || !defined(TARGET_ARM64) index = byteIndex / TARGET_POINTER_SIZE; m_currentByteStackIndex += TARGET_POINTER_SIZE; diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 3354a7ec0f2ab4..e284b74639202c 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10150,7 +10150,7 @@ void InlinedCallFrame::GetEEInfo(CORINFO_EE_INFO::InlinedCallFrameInfo *pInfo) CORINFO_OS getClrVmOs() { -#ifdef TARGET_OSX +#ifdef TARGET_APPLE return CORINFO_APPLE; #elif defined(TARGET_UNIX) return CORINFO_UNIX; diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index 272e61d8862420..eda9ac7059d8a9 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -5669,7 +5669,7 @@ inline BOOL IsWriteBarrierCopyEnabled() #ifdef DACCESS_COMPILE return FALSE; #else // DACCESS_COMPILE -#ifdef HOST_OSX +#ifdef HOST_APPLE return TRUE; #else return ExecutableAllocator::IsWXORXEnabled(); diff --git a/src/coreclr/vm/threadstatics.cpp b/src/coreclr/vm/threadstatics.cpp index d63dabb5647ec0..2b773cb317ef41 100644 --- a/src/coreclr/vm/threadstatics.cpp +++ b/src/coreclr/vm/threadstatics.cpp @@ -806,7 +806,7 @@ void FreeTLSIndicesForLoaderAllocator(LoaderAllocator *pLoaderAllocator) static void* GetTlsIndexObjectAddress(); -#if !defined(TARGET_OSX) && defined(TARGET_UNIX) && (defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)) +#if !defined(TARGET_APPLE) && defined(TARGET_UNIX) && (defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)) extern "C" size_t GetTLSResolverAddress(); // Check if the resolver address retrieval code is expected. We verify the exact @@ -905,7 +905,7 @@ static bool IsValidTLSResolver() return false; } -#endif // !TARGET_OSX && TARGET_UNIX && (TARGET_ARM64 || TARGET_LOONGARCH64) +#endif // !TARGET_APPLE && TARGET_UNIX && (TARGET_ARM64 || TARGET_LOONGARCH64) bool CanJITOptimizeTLSAccess() { @@ -924,7 +924,7 @@ bool CanJITOptimizeTLSAccess() // Optimization is disabled for linux musl arm64 #elif defined(TARGET_FREEBSD) && defined(TARGET_ARM64) // Optimization is disabled for FreeBSD/arm64 -#elif !defined(TARGET_OSX) && defined(TARGET_UNIX) && defined(TARGET_ARM64) +#elif !defined(TARGET_APPLE) && defined(TARGET_UNIX) && defined(TARGET_ARM64) bool tlsResolverValid = IsValidTLSResolver(); if (tlsResolverValid) { @@ -960,12 +960,12 @@ bool CanJITOptimizeTLSAccess() } #else optimizeThreadStaticAccess = true; -#if !defined(TARGET_OSX) && defined(TARGET_UNIX) && defined(TARGET_AMD64) +#if !defined(TARGET_APPLE) && defined(TARGET_UNIX) && defined(TARGET_AMD64) // For linux/x64, check if compiled coreclr as .so file and not single file. // For single file, the `tls_index` might not be accurate. // Do not perform this optimization in such case. optimizeThreadStaticAccess = GetTlsIndexObjectAddress() != nullptr; -#endif // !TARGET_OSX && TARGET_UNIX && TARGET_AMD64 +#endif // !TARGET_APPLE && TARGET_UNIX && TARGET_AMD64 #endif return optimizeThreadStaticAccess; @@ -987,7 +987,7 @@ static uint32_t ThreadLocalOffset(void* p) uint8_t* pOurTls = pTls[_tls_index]; return (uint32_t)((uint8_t*)p - pOurTls); } -#elif defined(TARGET_OSX) +#elif defined(TARGET_APPLE) extern "C" void* GetThreadVarsAddress(); static void* GetThreadVarsSectionAddressFromDesc(uint8_t* p) @@ -1081,7 +1081,7 @@ void GetThreadLocalStaticBlocksInfo(CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo) pInfo->offsetOfThreadLocalStoragePointer = offsetof(_TEB, ThreadLocalStoragePointer); threadStaticBaseOffset = ThreadLocalOffset(&t_ThreadStatics); -#elif defined(TARGET_OSX) +#elif defined(TARGET_APPLE) pInfo->threadVarsSection = GetThreadVarsSectionAddress(); diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props index b0984084685b2f..86ea8a85efdf5c 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props @@ -101,6 +101,7 @@ + diff --git a/src/mono/msbuild/apple/build/AppleBuild.InTree.targets b/src/mono/msbuild/apple/build/AppleBuild.InTree.targets index 3d982701bf8b66..bf0b75fc060b08 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.InTree.targets +++ b/src/mono/msbuild/apple/build/AppleBuild.InTree.targets @@ -12,6 +12,15 @@ + + + + + + + diff --git a/src/mono/msbuild/apple/build/AppleBuild.props b/src/mono/msbuild/apple/build/AppleBuild.props index 22984e921c9681..6625f122c63efb 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.props +++ b/src/mono/msbuild/apple/build/AppleBuild.props @@ -1,7 +1,7 @@ - true + true @@ -12,7 +12,7 @@ true $(TargetOS)-$(TargetArchitecture.ToLowerInvariant()) - true + true true false @@ -24,7 +24,7 @@ <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' == 'true'">_AppleNativeAotCompile <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' != 'true'">_AppleAotCompile ComputeIlcCompileInputs;SetupOSSpecificProps;PrepareForILLink - <_ReadRuntimeComponentsManifestTargetName Condition="'$(UseNativeAOTRuntime)' != 'true'">_MonoReadAvailableComponentsManifest + <_ReadRuntimeComponentsManifestTargetName Condition="'$(UseNativeAOTRuntime)' != 'true' and '$(UseMonoRuntime)' != 'false'">_MonoReadAvailableComponentsManifest Publish @@ -44,6 +44,6 @@ <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == ''">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', '..', 'common')) - - + + \ No newline at end of file diff --git a/src/mono/msbuild/apple/build/AppleBuild.targets b/src/mono/msbuild/apple/build/AppleBuild.targets index a136da379cced3..0aafe5b5612d09 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.targets +++ b/src/mono/msbuild/apple/build/AppleBuild.targets @@ -54,12 +54,12 @@ $([MSBuild]::NormalizeDirectory('$(OutDir)', 'Bundle')) $(AppleBundleDir) - <_MonoHeaderPath Condition="'$(UseNativeAOTRuntime)' != 'true'">$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include', 'mono-2.0')) + <_MonoHeaderPath Condition="'$(UseMonoRuntime)' != 'false' and '$(UseNativeAOTRuntime)' != 'true'">$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include', 'mono-2.0')) <_AotModuleTablePath>$(AppleBundleDir)\modules.m $(AssemblyName) - + @@ -298,8 +298,15 @@ + + + NativeAOT + CoreCLR + MonoVM + + UseConsoleUITemplate="$(UseConsoleUITemplate)"> diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 25c1d55e7360cd..18952ba9cb7b1a 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -171,7 +171,6 @@ else() System.IO.Compression.Native-Static System.Net.Security.Native-Static System.Native-Static - System.Security.Cryptography.Native.OpenSsl-Static coreclrpal_dac corguids @@ -180,6 +179,10 @@ else() nativeresourcestring ) + if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_HOST_ANDROID) + LIST(APPEND NATIVE_LIBS System.Security.Cryptography.Native.OpenSsl-Static) + endif() + # additional requirements for System.IO.Compression.Native include(${CLR_SRC_NATIVE_DIR}/libs/System.IO.Compression.Native/extra_libs.cmake) append_extra_compression_libs(NATIVE_LIBS) @@ -201,7 +204,6 @@ else() endif() set(RUNTIMEINFO_LIB runtimeinfo) - endif() if(CLR_CMAKE_TARGET_APPLE) @@ -219,13 +221,11 @@ endif() # if(CLR_CMAKE_TARGET_APPLE) find_library(COREFOUNDATION CoreFoundation) - find_library(CORESERVICES CoreServices) find_library(SECURITY Security) find_library(SYSTEM System) LIST(APPEND NATIVE_LIBS ${COREFOUNDATION} - ${CORESERVICES} ${SECURITY} ${SYSTEM} ) diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index bde8446cc22cdf..0c1f1b2d787c54 100644 --- a/src/native/corehost/hostmisc/pal.h +++ b/src/native/corehost/hostmisc/pal.h @@ -71,7 +71,7 @@ #if defined(TARGET_WINDOWS) #define LIB_PREFIX "" #define LIB_FILE_EXT ".dll" -#elif defined(TARGET_OSX) +#elif defined(TARGET_APPLE) #define LIB_PREFIX "lib" #define LIB_FILE_EXT ".dylib" #else diff --git a/src/native/corehost/hostpolicy/hostpolicy_context.cpp b/src/native/corehost/hostpolicy/hostpolicy_context.cpp index 63ef9cdbc0d32f..01956d5dc75d80 100644 --- a/src/native/corehost/hostpolicy/hostpolicy_context.cpp +++ b/src/native/corehost/hostpolicy/hostpolicy_context.cpp @@ -70,10 +70,12 @@ namespace return SystemResolveDllImport(entry_point_name); } +#if !defined(TARGET_APPLE) || defined(TARGET_OSX) if (strcmp(library_name, LIB_NAME("System.Security.Cryptography.Native.OpenSsl")) == 0) { return CryptoResolveDllImport(entry_point_name); } +#endif #endif if (strcmp(library_name, LIB_NAME("System.IO.Compression.Native")) == 0) @@ -95,7 +97,7 @@ namespace } } -#if defined(TARGET_OSX) +#if defined(TARGET_APPLE) if (strcmp(library_name, LIB_NAME("System.Security.Cryptography.Native.Apple")) == 0) { return CryptoAppleResolveDllImport(entry_point_name); diff --git a/src/native/external/libunwind.cmake b/src/native/external/libunwind.cmake index 5dcca157e23ae6..6d4a03fdff4daf 100644 --- a/src/native/external/libunwind.cmake +++ b/src/native/external/libunwind.cmake @@ -447,7 +447,7 @@ if(CLR_CMAKE_HOST_UNIX) list(APPEND libunwind_setjmp_la_SOURCES riscv/siglongjmp.S) endif() - if(CLR_CMAKE_HOST_OSX) + if(CLR_CMAKE_HOST_APPLE) set(LIBUNWIND_SOURCES_BASE remote/mac/missing-functions.c ${libunwind_remote_la_SOURCES} @@ -463,7 +463,7 @@ if(CLR_CMAKE_HOST_UNIX) ${libunwind_dwarf_generic_la_SOURCES} ${libunwind_elf_la_SOURCES} ) - endif(CLR_CMAKE_HOST_OSX) + endif(CLR_CMAKE_HOST_APPLE) else(CLR_CMAKE_HOST_UNIX) if(CLR_CMAKE_TARGET_ARCH_ARM64) diff --git a/src/native/external/libunwind_extras/CMakeLists.txt b/src/native/external/libunwind_extras/CMakeLists.txt index 2bfd2194c969e2..b08325f09e3bf8 100644 --- a/src/native/external/libunwind_extras/CMakeLists.txt +++ b/src/native/external/libunwind_extras/CMakeLists.txt @@ -78,7 +78,7 @@ if(CLR_CMAKE_HOST_UNIX) ###TODO: maybe add options for RISCV64 endif() - if (CLR_CMAKE_HOST_OSX) + if (CLR_CMAKE_HOST_APPLE) add_definitions(-DUNW_REMOTE_ONLY) add_compile_options(-Wno-sometimes-uninitialized) add_compile_options(-Wno-implicit-function-declaration) @@ -86,7 +86,7 @@ if(CLR_CMAKE_HOST_UNIX) # Our posix abstraction layer will provide these headers set(HAVE_ELF_H 1) set(HAVE_ENDIAN_H 1) - endif(CLR_CMAKE_HOST_OSX) + endif(CLR_CMAKE_HOST_APPLE) endif(CLR_CMAKE_HOST_UNIX) @@ -146,7 +146,7 @@ if(CLR_CMAKE_HOST_WIN32) add_compile_options(-wd4311) # pointer truncation from 'unw_word_t *' to 'long' add_compile_options(-wd4475) # 'fprintf' : length modifier 'L' cannot be used add_compile_options(-wd4477) # fprintf argument type -elseif(CLR_CMAKE_HOST_OSX) +elseif(CLR_CMAKE_HOST_APPLE) include_directories(${CLR_SRC_NATIVE_DIR}/external/libunwind/include/remote) include_directories(${CLR_SRC_NATIVE_DIR}/external/libunwind/include/remote/mac) endif (CLR_CMAKE_HOST_WIN32) @@ -166,11 +166,11 @@ if(CLR_CMAKE_HOST_WIN32) endif(CLR_CMAKE_HOST_WIN32) if(CLR_CMAKE_HOST_UNIX) - if(CLR_CMAKE_HOST_OSX) + if(CLR_CMAKE_HOST_APPLE) add_library(libunwind_dac OBJECT ${LIBUNWIND_SOURCES}) else() add_library(libunwind OBJECT ${LIBUNWIND_SOURCES}) - endif(CLR_CMAKE_HOST_OSX) + endif(CLR_CMAKE_HOST_APPLE) else(CLR_CMAKE_HOST_UNIX) set_source_files_properties(${CLR_DIR}/pal/src/exception/remote-unwind.cpp PROPERTIES COMPILE_FLAGS /TP INCLUDE_DIRECTORIES ${CLR_DIR}/inc) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 035f85a257b97c..53f4456e9229de 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -187,6 +187,12 @@ add_library(System.Globalization.Native-Static entrypoints.c ) +if (DEFINED CMAKE_ICU_DIR) + include_directories(${CMAKE_ICU_DIR}/include) + target_link_libraries(System.Globalization.Native-Static ${CMAKE_ICU_DIR}/lib/libicuuc.a ${CMAKE_ICU_DIR}/lib/libicui18n.a ${CMAKE_ICU_DIR}/lib/libicudata.a) + target_link_libraries(System.Globalization.Native-Static stdc++) +endif() + if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) endif() diff --git a/src/native/libs/System.Native/CMakeLists.txt b/src/native/libs/System.Native/CMakeLists.txt index 7712f255602028..8dbbf14d90f53d 100644 --- a/src/native/libs/System.Native/CMakeLists.txt +++ b/src/native/libs/System.Native/CMakeLists.txt @@ -126,7 +126,7 @@ if (GEN_SHARED_LIB) install_with_stripped_symbols (System.Native PROGRAMS .) endif () -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVE_SOURCES ${NATIVE_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.Native/entrypoints.c b/src/native/libs/System.Native/entrypoints.c index a133f59b179e2d..c25414cbe7b554 100644 --- a/src/native/libs/System.Native/entrypoints.c +++ b/src/native/libs/System.Native/entrypoints.c @@ -34,6 +34,7 @@ static const Entry s_sysNative[] = { DllImportEntry(SystemNative_FStat) +#if !defined(TARGET_APPLE) || defined(TARGET_OSX) DllImportEntry(SystemNative_GetWindowSize) DllImportEntry(SystemNative_IsATty) DllImportEntry(SystemNative_InitializeTerminalAndSignalHandling) @@ -47,6 +48,7 @@ static const Entry s_sysNative[] = DllImportEntry(SystemNative_ReadStdin) DllImportEntry(SystemNative_GetSignalForBreak) DllImportEntry(SystemNative_SetSignalForBreak) +#endif DllImportEntry(SystemNative_GetSystemTimeAsTicks) DllImportEntry(SystemNative_GetDefaultTimeZone) DllImportEntry(SystemNative_GetTimeZoneData) diff --git a/src/native/libs/System.Net.Security.Native/CMakeLists.txt b/src/native/libs/System.Net.Security.Native/CMakeLists.txt index b0e02f41509b58..e8efae3d33a795 100644 --- a/src/native/libs/System.Net.Security.Native/CMakeLists.txt +++ b/src/native/libs/System.Net.Security.Native/CMakeLists.txt @@ -19,7 +19,7 @@ if (GEN_SHARED_LIB) ) endif() -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVEGSS_SOURCES ${NATIVEGSS_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt b/src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt index 84615493f4495c..daba219facad9c 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt @@ -105,7 +105,7 @@ if (GEN_SHARED_LIB) ) endif() -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if (NOT GEN_SHARED_LIB) set(NATIVECRYPTO_SOURCES ${NATIVECRYPTO_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c b/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c index 5163aa5b121236..ea70c53b30477f 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c @@ -8,7 +8,6 @@ #include "pal_ecc.h" #include "pal_hmac.h" #include "pal_keyagree.h" -#include "pal_keychain_macos.h" #include "pal_keyderivation.h" #include "pal_random.h" #include "pal_rsa.h" @@ -19,10 +18,16 @@ #include "pal_ssl.h" #include "pal_swiftbindings.h" #include "pal_symmetric.h" -#include "pal_trust_macos.h" #include "pal_x509.h" -#include "pal_x509_macos.h" #include "pal_x509chain.h" +#if defined(TARGET_OSX) +#include "pal_trust_macos.h" +#include "pal_keychain_macos.h" +#include "pal_x509_macos.h" +#else +#include "pal_keychain_ios.h" +#include "pal_x509_ios.h" +#endif static const Entry s_cryptoAppleNative[] = { @@ -31,6 +36,7 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_ChaCha20Poly1305Encrypt) DllImportEntry(AppleCryptoNative_ChaCha20Poly1305Decrypt) DllImportEntry(AppleCryptoNative_DigestClone) + DllImportEntry(AppleCryptoNative_DigestFree) DllImportEntry(AppleCryptoNative_DigestCreate) DllImportEntry(AppleCryptoNative_DigestCurrent) DllImportEntry(AppleCryptoNative_DigestFinal) @@ -51,15 +57,8 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_HmacOneShot) DllImportEntry(AppleCryptoNative_HmacUpdate) DllImportEntry(AppleCryptoNative_IsAuthenticationFailure) - DllImportEntry(AppleCryptoNative_SecKeychainItemCopyKeychain) - DllImportEntry(AppleCryptoNative_SecKeychainCopyDefault) - DllImportEntry(AppleCryptoNative_SecKeychainCreate) - DllImportEntry(AppleCryptoNative_SecKeychainDelete) DllImportEntry(AppleCryptoNative_SecKeychainEnumerateCerts) - DllImportEntry(AppleCryptoNative_SecKeychainOpen) - DllImportEntry(AppleCryptoNative_SecKeychainUnlock) DllImportEntry(AppleCryptoNative_SecKeychainEnumerateIdentities) - DllImportEntry(AppleCryptoNative_SetKeychainNeverLock) DllImportEntry(AppleCryptoNative_SslCopyCADistinguishedNames) DllImportEntry(AppleCryptoNative_SslCopyCertChain) DllImportEntry(AppleCryptoNative_SslIsHostnameMatch) @@ -80,8 +79,6 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_RsaEncryptionPrimitive) DllImportEntry(AppleCryptoNative_RsaVerificationPrimitive) DllImportEntry(AppleCryptoNative_SecCopyErrorMessageString) - DllImportEntry(AppleCryptoNative_SecKeyExport) - DllImportEntry(AppleCryptoNative_SecKeyImportEphemeral) DllImportEntry(AppleCryptoNative_SecKeyGetSimpleKeySizeInBytes) DllImportEntry(AppleCryptoNative_SecKeyCreateSignature) DllImportEntry(AppleCryptoNative_SecKeyVerifySignature) @@ -108,10 +105,6 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_CryptorCreate) DllImportEntry(AppleCryptoNative_CryptorUpdate) DllImportEntry(AppleCryptoNative_CryptorReset) - DllImportEntry(AppleCryptoNative_StoreEnumerateUserRoot) - DllImportEntry(AppleCryptoNative_StoreEnumerateMachineRoot) - DllImportEntry(AppleCryptoNative_StoreEnumerateUserDisallowed) - DllImportEntry(AppleCryptoNative_StoreEnumerateMachineDisallowed) DllImportEntry(AppleCryptoNative_X509ChainCreate) DllImportEntry(AppleCryptoNative_X509DemuxAndRetainHandle) DllImportEntry(AppleCryptoNative_X509GetContentType) @@ -120,10 +113,7 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_X509CopyPrivateKeyFromIdentity) DllImportEntry(AppleCryptoNative_X509ImportCollection) DllImportEntry(AppleCryptoNative_X509ImportCertificate) - DllImportEntry(AppleCryptoNative_X509ExportData) DllImportEntry(AppleCryptoNative_X509GetRawData) - DllImportEntry(AppleCryptoNative_X509CopyWithPrivateKey) - DllImportEntry(AppleCryptoNative_X509MoveToKeychain) DllImportEntry(AppleCryptoNative_X509ChainCreateDefaultPolicy) DllImportEntry(AppleCryptoNative_X509ChainCreateRevocationPolicy) DllImportEntry(AppleCryptoNative_X509ChainEvaluate) @@ -137,6 +127,24 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_X509StoreRemoveCertificate) DllImportEntry(AppleCryptoNative_Pbkdf2) DllImportEntry(AppleCryptoNative_X509GetSubjectSummary) +#ifdef TARGET_OSX + DllImportEntry(AppleCryptoNative_SecKeychainItemCopyKeychain) + DllImportEntry(AppleCryptoNative_SecKeychainCopyDefault) + DllImportEntry(AppleCryptoNative_SecKeychainCreate) + DllImportEntry(AppleCryptoNative_SecKeychainDelete) + DllImportEntry(AppleCryptoNative_SecKeychainOpen) + DllImportEntry(AppleCryptoNative_SecKeychainUnlock) + DllImportEntry(AppleCryptoNative_SetKeychainNeverLock) + DllImportEntry(AppleCryptoNative_SecKeyExport) + DllImportEntry(AppleCryptoNative_SecKeyImportEphemeral) + DllImportEntry(AppleCryptoNative_StoreEnumerateUserRoot) + DllImportEntry(AppleCryptoNative_StoreEnumerateMachineRoot) + DllImportEntry(AppleCryptoNative_StoreEnumerateUserDisallowed) + DllImportEntry(AppleCryptoNative_StoreEnumerateMachineDisallowed) + DllImportEntry(AppleCryptoNative_X509ExportData) + DllImportEntry(AppleCryptoNative_X509CopyWithPrivateKey) + DllImportEntry(AppleCryptoNative_X509MoveToKeychain) +#endif }; EXTERN_C const void* CryptoAppleResolveDllImport(const char* name); diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 945fbed855ce8e..fc7332a54f9fac 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -9,7 +9,7 @@ include(CheckTypeSize) include(CheckLibraryExists) include(CheckFunctionExists) -if (CLR_CMAKE_TARGET_OSX) +if (CLR_CMAKE_TARGET_APPLE) # Xcode's clang does not include /usr/local/include by default, but brew's does. # This ensures an even playing field. include_directories(SYSTEM /usr/local/include) diff --git a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs index 0e16db616d62e8..9635fe02dc22d9 100644 --- a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs +++ b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs @@ -13,6 +13,7 @@ public class AppleAppBuilderTask : Task { private string targetOS = TargetNames.iOS; + private TargetRuntime targetRuntime; /// /// The Apple OS we are targeting (ios, tvos, iossimulator, tvossimulator) @@ -177,9 +178,9 @@ public string TargetOS public bool StripSymbolTable { get; set; } /// - /// Bundles the application for NativeAOT runtime. Default runtime is Mono. + /// Bundles the application for specific runtime. Valid values: MonoVM, NativeAOT, CoreCLR. /// - public bool UseNativeAOTRuntime { get; set; } + public string Runtime { get; set; } = "MonoVM"; /// /// Extra native dependencies to link into the app @@ -193,28 +194,33 @@ public string TargetOS public void ValidateRuntimeSelection() { - if (UseNativeAOTRuntime) + if (!Enum.TryParse(Runtime, out targetRuntime)) + { + throw new ArgumentException($"The \"{nameof(AppleAppBuilderTask)}\" task was not given an invalid value for parameter \"{nameof(Runtime)}\"."); + } + + if (targetRuntime == TargetRuntime.NativeAOT || targetRuntime == TargetRuntime.CoreCLR) { if (!string.IsNullOrEmpty(MonoRuntimeHeaders)) - throw new ArgumentException($"Property \"{nameof(MonoRuntimeHeaders)}\" is not supported with NativeAOT runtime and will be ignored."); + throw new ArgumentException($"Property \"{nameof(MonoRuntimeHeaders)}\" is not supported with {Runtime} runtime and will be ignored."); - if (!string.IsNullOrEmpty(MainLibraryFileName)) - throw new ArgumentException($"Property \"{nameof(MainLibraryFileName)}\" is not supported with NativeAOT runtime and will be ignored."); + if (!string.IsNullOrEmpty(MainLibraryFileName) && targetRuntime == TargetRuntime.NativeAOT) + throw new ArgumentException($"Property \"{nameof(MainLibraryFileName)}\" is not supported with {Runtime} runtime and will be ignored."); if (ForceInterpreter) - throw new ArgumentException($"Property \"{nameof(ForceInterpreter)}\" is not supported with NativeAOT runtime and will be ignored."); + throw new ArgumentException($"Property \"{nameof(ForceInterpreter)}\" is not supported with {Runtime} runtime and will be ignored."); if (ForceAOT) - throw new ArgumentException($"Property \"{nameof(ForceAOT)}\" is not supported with NativeAOT runtime and will be ignored."); + throw new ArgumentException($"Property \"{nameof(ForceAOT)}\" is not supported with {Runtime} runtime and will be ignored."); - if (RuntimeComponents.Length > 0) + if (RuntimeComponents.Length > 0 && targetRuntime == TargetRuntime.NativeAOT) throw new ArgumentException($"Item \"{nameof(RuntimeComponents)}\" is not supported with NativeAOT runtime and will be ignored."); if (!string.IsNullOrEmpty(DiagnosticPorts)) - throw new ArgumentException($"Property \"{nameof(DiagnosticPorts)}\" is not supported with NativeAOT runtime and will be ignored."); + throw new ArgumentException($"Property \"{nameof(DiagnosticPorts)}\" is not supported with {Runtime} runtime and will be ignored."); if (EnableRuntimeLogging) - throw new ArgumentException($"Property \"{nameof(EnableRuntimeLogging)}\" is not supported with NativeAOT runtime and will be ignored."); + throw new ArgumentException($"Property \"{nameof(EnableRuntimeLogging)}\" is not supported with {Runtime} runtime and will be ignored."); } else { @@ -288,7 +294,7 @@ public override bool Execute() } } - if (!ForceInterpreter && (shouldStaticLink || ForceAOT) && (assemblerFiles.Count == 0 && !UseNativeAOTRuntime)) + if (!ForceInterpreter && (shouldStaticLink || ForceAOT) && (assemblerFiles.Count == 0 && targetRuntime == TargetRuntime.MonoVM)) { throw new InvalidOperationException("Need list of AOT files for static linked builds."); } @@ -315,12 +321,18 @@ public override bool Execute() extraLinkerArgs.Add(item.ItemSpec); } + if (targetRuntime == TargetRuntime.CoreCLR) + { + extraLinkerArgs.Add("-rpath @executable_path"); + shouldStaticLink = false; + } + var generator = new Xcode(Log, TargetOS, Arch); if (GenerateXcodeProject) { XcodeProjectPath = generator.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles, assemblerDataFiles, assemblerFilesToLink, extraLinkerArgs, excludes, - AppDir, binDir, MonoRuntimeHeaders, !shouldStaticLink, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, HybridGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource, UseNativeAOTRuntime, IsLibraryMode); + AppDir, binDir, MonoRuntimeHeaders, !shouldStaticLink, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, HybridGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource, targetRuntime, IsLibraryMode); if (BuildAppBundle) { @@ -346,7 +358,7 @@ public override bool Execute() else if (GenerateCMakeProject) { generator.GenerateCMake(ProjectName, MainLibraryFileName, assemblerFiles, assemblerDataFiles, assemblerFilesToLink, extraLinkerArgs, excludes, - AppDir, binDir, MonoRuntimeHeaders, !shouldStaticLink, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, HybridGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource, UseNativeAOTRuntime, IsLibraryMode); + AppDir, binDir, MonoRuntimeHeaders, !shouldStaticLink, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, HybridGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource, targetRuntime, IsLibraryMode); } return true; diff --git a/src/tasks/AppleAppBuilder/AppleAppBuilder.csproj b/src/tasks/AppleAppBuilder/AppleAppBuilder.csproj index a2c93c2f89d2a0..1f0e6ba463420f 100644 --- a/src/tasks/AppleAppBuilder/AppleAppBuilder.csproj +++ b/src/tasks/AppleAppBuilder/AppleAppBuilder.csproj @@ -9,11 +9,13 @@ + + diff --git a/src/tasks/AppleAppBuilder/TargetRuntime.cs b/src/tasks/AppleAppBuilder/TargetRuntime.cs new file mode 100644 index 00000000000000..81fb9b1c956d18 --- /dev/null +++ b/src/tasks/AppleAppBuilder/TargetRuntime.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +internal enum TargetRuntime +{ + MonoVM, + CoreCLR, + NativeAOT, +} diff --git a/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template b/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template index d988551bedf1bb..b291b723fdc27b 100644 --- a/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template +++ b/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template @@ -28,7 +28,7 @@ endif() %Defines% -if(NOT %UseNativeAOTRuntime%) +if(NOT "%MonoInclude%" STREQUAL "") include_directories("%MonoInclude%") endif() diff --git a/src/tasks/AppleAppBuilder/Templates/runtime-coreclr.m b/src/tasks/AppleAppBuilder/Templates/runtime-coreclr.m new file mode 100644 index 00000000000000..582f041a44d3ee --- /dev/null +++ b/src/tasks/AppleAppBuilder/Templates/runtime-coreclr.m @@ -0,0 +1,161 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#import +#include "coreclrhost.h" +#include +#import +#include +#include +#include +#include +#include + +#import "util.h" + +#define APPLE_RUNTIME_IDENTIFIER "iossimulator-arm64" + +const char * +get_bundle_path (void) +{ + static char *bundle_path = NULL; + if (bundle_path) + return bundle_path; + NSBundle* main_bundle = [NSBundle mainBundle]; + NSString* path = [main_bundle bundlePath]; + +#if TARGET_OS_MACCATALYST + path = [path stringByAppendingString:@"/Contents/Resources"]; +#endif + + bundle_path = strdup ([path UTF8String]); + + return bundle_path; +} + +char * +compute_trusted_platform_assemblies () +{ + const char *bundle_path = get_bundle_path (); + + NSMutableArray *files = [NSMutableArray array]; + NSMutableArray *exes = [NSMutableArray array]; + + NSFileManager *manager = [NSFileManager defaultManager]; + NSString *dir = [NSString stringWithUTF8String: bundle_path]; + NSDirectoryEnumerator *enumerator = [manager enumeratorAtURL:[NSURL fileURLWithPath: dir] + includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey] + options:NSDirectoryEnumerationSkipsSubdirectoryDescendants + errorHandler:nil]; + for (NSURL *file in enumerator) { + // skip subdirectories + NSNumber *isDirectory = nil; + if (![file getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:nil] || [isDirectory boolValue]) + continue; + + NSString *name = nil; + if (![file getResourceValue:&name forKey:NSURLNameKey error:nil]) + continue; + if ([name length] < 4) + continue; + if ([name compare: @".dll" options: NSCaseInsensitiveSearch range: NSMakeRange ([name length] - 4, 4)] == NSOrderedSame) { + [files addObject: [dir stringByAppendingPathComponent: name]]; + } + } + + // Join them all together with a colon separating them + NSString *joined = [files componentsJoinedByString: @":"]; + return strdup([joined UTF8String]); +} + +void* +pinvoke_override (const char *libraryName, const char *entrypointName) +{ + if (!strcmp (libraryName, "__Internal")) + { + return dlsym (RTLD_DEFAULT, entrypointName); + } + return NULL; +} + +void +mono_ios_runtime_init (void) +{ +#if INVARIANT_GLOBALIZATION + setenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1", TRUE); +#endif + +#if HYBRID_GLOBALIZATION + setenv ("DOTNET_SYSTEM_GLOBALIZATION_HYBRID", "1", TRUE); +#endif + + // build using DiagnosticPorts property in AppleAppBuilder + // or set DOTNET_DiagnosticPorts env via mlaunch, xharness when undefined. + // NOTE, using DOTNET_DiagnosticPorts requires app build using AppleAppBuilder and RuntimeComponents=diagnostics_tracing +#ifdef DIAGNOSTIC_PORTS + setenv ("DOTNET_DiagnosticPorts", DIAGNOSTIC_PORTS, true); +#endif + + char **managed_argv; + int argi = get_managed_args (&managed_argv); + + bool wait_for_debugger = FALSE; + + const char* bundle = get_bundle_path (); + chdir (bundle); + + char icu_dat_path [1024]; + int res; +#if defined(HYBRID_GLOBALIZATION) + res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt_hybrid.dat"); +#else + res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt.dat"); +#endif + assert (res > 0); + + char pinvoke_override_addr [16]; + sprintf (pinvoke_override_addr, "%p", &pinvoke_override); + + // TODO: set TRUSTED_PLATFORM_ASSEMBLIES, APP_PATHS and NATIVE_DLL_SEARCH_DIRECTORIES + const char *appctx_keys [] = { + "RUNTIME_IDENTIFIER", + "APP_CONTEXT_BASE_DIRECTORY", + "TRUSTED_PLATFORM_ASSEMBLIES", + "PINVOKE_OVERRIDE", +#if !defined(INVARIANT_GLOBALIZATION) + "ICU_DAT_FILE_PATH" +#endif + }; + const char *appctx_values [] = { + APPLE_RUNTIME_IDENTIFIER, + bundle, + compute_trusted_platform_assemblies(), + pinvoke_override_addr, +#if !defined(INVARIANT_GLOBALIZATION) + icu_dat_path +#endif + }; + + const char* executable = "Program.dll"; + const char *executablePath = [[[[NSBundle mainBundle] executableURL] path] UTF8String]; + unsigned int coreclr_domainId = 0; + void *coreclr_handle = NULL; + + char path [1024]; + res = snprintf (path, sizeof (path) - 1, "%s/%s", bundle, executable); + assert (res > 0); + + res = coreclr_initialize ( + executablePath, executable, + sizeof (appctx_keys) / sizeof (appctx_keys [0]), appctx_keys, appctx_values, + &coreclr_handle, &coreclr_domainId); + assert (res == 0); + + coreclr_execute_assembly (coreclr_handle, coreclr_domainId, argi, managed_argv, path, &res); + // Print this so apps parsing logs can detect when we exited + os_log_info (OS_LOG_DEFAULT, EXIT_CODE_TAG ": %d", res); + + free_managed_args (&managed_argv, argi); + + exit (res); +} diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index ce13c9bf008d14..0b3acb9f32f583 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -190,10 +190,10 @@ public string GenerateXCode( string? diagnosticPorts, IEnumerable runtimeComponents, string? nativeMainSource = null, - bool useNativeAOTRuntime = false, + TargetRuntime targetRuntime = TargetRuntime.MonoVM, bool isLibraryMode = false) { - var cmakeDirectoryPath = GenerateCMake(projectName, entryPointLib, asmFiles, asmDataFiles, asmLinkFiles, extraLinkerArgs, excludes, workspace, binDir, monoInclude, preferDylibs, useConsoleUiTemplate, forceAOT, forceInterpreter, invariantGlobalization, hybridGlobalization, optimized, enableRuntimeLogging, enableAppSandbox, diagnosticPorts, runtimeComponents, nativeMainSource, useNativeAOTRuntime, isLibraryMode); + var cmakeDirectoryPath = GenerateCMake(projectName, entryPointLib, asmFiles, asmDataFiles, asmLinkFiles, extraLinkerArgs, excludes, workspace, binDir, monoInclude, preferDylibs, useConsoleUiTemplate, forceAOT, forceInterpreter, invariantGlobalization, hybridGlobalization, optimized, enableRuntimeLogging, enableAppSandbox, diagnosticPorts, runtimeComponents, nativeMainSource, targetRuntime, isLibraryMode); CreateXcodeProject(projectName, cmakeDirectoryPath); return Path.Combine(binDir, projectName, projectName + ".xcodeproj"); } @@ -263,14 +263,14 @@ public string GenerateCMake( string? diagnosticPorts, IEnumerable runtimeComponents, string? nativeMainSource = null, - bool useNativeAOTRuntime = false, + TargetRuntime targetRuntime = TargetRuntime.MonoVM, bool isLibraryMode = false) { // bundle everything as resources excluding native files - var predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib", "icudt*" }; + var predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "icudt*" }; // TODO: All of these exclusions shouldn't be needed once we carefully construct the publish folder on Helix - if (useNativeAOTRuntime) + if (targetRuntime == TargetRuntime.NativeAOT) { predefinedExcludes.Add(".dll"); predefinedExcludes.Add(".pdb"); @@ -289,6 +289,10 @@ public string GenerateCMake( { predefinedExcludes.Add(".pdb"); } + if (targetRuntime != TargetRuntime.CoreCLR) + { + predefinedExcludes.Add("libcoreclr.dylib"); + } string[] resources = Directory.GetFileSystemEntries(workspace, "", SearchOption.TopDirectoryOnly) .Where(f => !predefinedExcludes.Any(e => (!e.EndsWith('*') && f.EndsWith(e, StringComparison.InvariantCultureIgnoreCase)) || (e.EndsWith('*') && Path.GetFileName(f).StartsWith(e.TrimEnd('*'), StringComparison.InvariantCultureIgnoreCase) && @@ -338,7 +342,8 @@ public string GenerateCMake( string cmakeTemplateName = (isLibraryMode) ? "CMakeLists-librarymode.txt.template" : "CMakeLists.txt.template"; string cmakeLists = Utils.GetEmbeddedResource(cmakeTemplateName) - .Replace("%UseNativeAOTRuntime%", useNativeAOTRuntime ? "TRUE" : "FALSE") + .Replace("%UseMonoRuntime%", targetRuntime == TargetRuntime.MonoVM ? "TRUE" : "FALSE") + .Replace("%UseNativeAOTRuntime%", targetRuntime == TargetRuntime.NativeAOT ? "TRUE" : "FALSE") .Replace("%ProjectName%", projectName) .Replace("%AppResources%", appResources) .Replace("%MainSource%", nativeMainSource) @@ -356,7 +361,7 @@ public string GenerateCMake( // Current differences: // - NativeAOT produces {ProjectName}.dylib, while MonoAOT produces lib{ProjectName}.dylib // - NativeAOT places the library in the 'workspace' location ie 'publish' folder, while MonoAOT places it in 'binDir' ie 'AppBundle' - if (useNativeAOTRuntime) + if (targetRuntime == TargetRuntime.NativeAOT) { libraryPath = Path.Combine(workspace, $"{projectName}.dylib"); } @@ -373,7 +378,7 @@ public string GenerateCMake( cmakeLists = cmakeLists.Replace("%DYLIB_PATH%", libraryPath); // pass the shared library to the linker for dynamic linking - if (useNativeAOTRuntime) + if (targetRuntime == TargetRuntime.NativeAOT) toLink += $" {libraryPath}{Environment.NewLine}"; } else @@ -407,29 +412,38 @@ public string GenerateCMake( } string[] dylibs = Directory.GetFiles(workspace, "*.dylib"); - - // Sort the static libraries to link so the brotli libs are added to the list last (after the compression native libs) - List staticLibsToLink = Directory.GetFiles(workspace, "*.a").OrderBy(libName => libName.Contains("brotli") ? 1 : 0).ToList(); - foreach (string lib in staticLibsToLink) + if (targetRuntime == TargetRuntime.CoreCLR) { - // all component libs already added to linker. - if (allComponentLibs.Any(lib.Contains)) - continue; - - string libName = Path.GetFileNameWithoutExtension(lib); - // libmono must always be statically linked, for other librarires we can use dylibs - bool dylibExists = libName != "libmonosgen-2.0" && dylibs.Any(dylib => Path.GetFileName(dylib) == libName + ".dylib"); - - if (useNativeAOTRuntime) + foreach (string lib in dylibs) { - // link NativeAOT framework libs without '-force_load' - toLink += $" {lib}{Environment.NewLine}"; + toLink += $" \"-force_load {lib}\"{Environment.NewLine}"; } - else if (forceAOT || !(preferDylibs && dylibExists)) + } + else + { + // Sort the static libraries to link so the brotli libs are added to the list last (after the compression native libs) + List staticLibsToLink = Directory.GetFiles(workspace, "*.a").OrderBy(libName => libName.Contains("brotli") ? 1 : 0).ToList(); + foreach (string lib in staticLibsToLink) { - // these libraries are pinvoked - // -force_load will be removed once we enable direct-pinvokes for AOT - toLink += $" \"-force_load {lib}\"{Environment.NewLine}"; + // all component libs already added to linker. + if (allComponentLibs.Any(lib.Contains)) + continue; + + string libName = Path.GetFileNameWithoutExtension(lib); + // libmono must always be statically linked, for other librarires we can use dylibs + bool dylibExists = libName != "libmonosgen-2.0" && dylibs.Any(dylib => Path.GetFileName(dylib) == libName + ".dylib"); + + if (targetRuntime == TargetRuntime.NativeAOT) + { + // link NativeAOT framework libs without '-force_load' + toLink += $" {lib}{Environment.NewLine}"; + } + else if (forceAOT || !(preferDylibs && dylibExists)) + { + // these libraries are pinvoked + // -force_load will be removed once we enable direct-pinvokes for AOT + toLink += $" \"-force_load {lib}\"{Environment.NewLine}"; + } } } @@ -463,7 +477,14 @@ public string GenerateCMake( cmakeLists = cmakeLists.Replace("%EXTRA_LINKER_ARGS%", extraLinkerArgsConcat); cmakeLists = cmakeLists.Replace("%AotSources%", aotSources); cmakeLists = cmakeLists.Replace("%AotTargetsList%", aotList); - cmakeLists = cmakeLists.Replace("%AotModulesSource%", string.IsNullOrEmpty(aotSources) ? "" : "modules.m"); + if (targetRuntime == TargetRuntime.CoreCLR) + { + cmakeLists = cmakeLists.Replace("%AotModulesSource%", "coreclrhost.h"); + } + else + { + cmakeLists = cmakeLists.Replace("%AotModulesSource%", string.IsNullOrEmpty(aotSources) ? "" : "modules.m"); + } var defines = new StringBuilder(); if (forceInterpreter) @@ -496,10 +517,14 @@ public string GenerateCMake( defines.AppendLine($"\nadd_definitions(-DDIAGNOSTIC_PORTS=\"{diagnosticPorts}\")"); } - if (useNativeAOTRuntime) + if (targetRuntime == TargetRuntime.NativeAOT) { defines.AppendLine("add_definitions(-DUSE_NATIVE_AOT=1)"); } + else if (targetRuntime == TargetRuntime.CoreCLR) + { + defines.AppendLine("add_definitions(-DCORECLR=1)"); + } if (isLibraryMode) { @@ -534,30 +559,45 @@ public string GenerateCMake( File.WriteAllText(Path.Combine(binDir, "runtime-librarymode.h"), Utils.GetEmbeddedResource("runtime-librarymode.h")); File.WriteAllText(Path.Combine(binDir, "runtime-librarymode.m"), Utils.GetEmbeddedResource("runtime-librarymode.m")); } - else if (!useNativeAOTRuntime) + else if (targetRuntime != TargetRuntime.NativeAOT) { File.WriteAllText(Path.Combine(binDir, "runtime.h"), Utils.GetEmbeddedResource("runtime.h")); - // lookup statically linked libraries via dlsym(), see handle_pinvoke_override() in runtime.m - var pinvokeOverrides = new StringBuilder(); - foreach (string aFile in Directory.GetFiles(workspace, "*.a")) + if (targetRuntime == TargetRuntime.MonoVM) { - string aFileName = Path.GetFileNameWithoutExtension(aFile); - pinvokeOverrides.AppendLine($" \"{aFileName}\","); + // lookup statically linked libraries via dlsym(), see handle_pinvoke_override() in runtime.m + var pinvokeOverrides = new StringBuilder(); + foreach (string aFile in Directory.GetFiles(workspace, "*.a")) + { + string aFileName = Path.GetFileNameWithoutExtension(aFile); + pinvokeOverrides.AppendLine($" \"{aFileName}\","); - // also register with or without "lib" prefix - aFileName = aFileName.StartsWith("lib") ? aFileName.Remove(0, 3) : "lib" + aFileName; - pinvokeOverrides.AppendLine($" \"{aFileName}\","); - } + // also register with or without "lib" prefix + aFileName = aFileName.StartsWith("lib") ? aFileName.Remove(0, 3) : "lib" + aFileName; + pinvokeOverrides.AppendLine($" \"{aFileName}\","); + } - pinvokeOverrides.AppendLine($" \"System.Globalization.Native\","); + pinvokeOverrides.AppendLine($" \"System.Globalization.Native\","); - File.WriteAllText(Path.Combine(binDir, "runtime.m"), - Utils.GetEmbeddedResource("runtime.m") - .Replace("//%PInvokeOverrideLibraries%", pinvokeOverrides.ToString()) - .Replace("//%APPLE_RUNTIME_IDENTIFIER%", RuntimeIdentifier) - .Replace("%EntryPointLibName%", Path.GetFileName(entryPointLib))); + string runtimeTemplateName = (isLibraryMode) ? "runtime-librarymode.m" : "runtime.m"; + File.WriteAllText(Path.Combine(binDir, "runtime.m"), + Utils.GetEmbeddedResource(runtimeTemplateName) + .Replace("//%PInvokeOverrideLibraries%", pinvokeOverrides.ToString()) + .Replace("//%APPLE_RUNTIME_IDENTIFIER%", RuntimeIdentifier) + .Replace("%EntryPointLibName%", Path.GetFileName(entryPointLib))); + } + else + { + File.WriteAllText(Path.Combine(binDir, "coreclrhost.h"), + Utils.GetEmbeddedResource("coreclrhost.h")); + + // NOTE: Library mode is not supported yet + File.WriteAllText(Path.Combine(binDir, "runtime.m"), + Utils.GetEmbeddedResource("runtime-coreclr.m") + .Replace("//%APPLE_RUNTIME_IDENTIFIER%", RuntimeIdentifier) + .Replace("%EntryPointLibName%", Path.GetFileName(entryPointLib))); + } } File.WriteAllText(Path.Combine(binDir, "util.h"), Utils.GetEmbeddedResource("util.h")); diff --git a/src/tasks/LibraryBuilder/LibraryBuilder.csproj b/src/tasks/LibraryBuilder/LibraryBuilder.csproj index 7fa908222541d9..da2885a5722230 100644 --- a/src/tasks/LibraryBuilder/LibraryBuilder.csproj +++ b/src/tasks/LibraryBuilder/LibraryBuilder.csproj @@ -20,6 +20,7 @@ + diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props index 2f438eea2fea1f..ec537c61c5d9cd 100644 --- a/src/tests/Directory.Build.props +++ b/src/tests/Directory.Build.props @@ -223,7 +223,8 @@ <_targetOS>$(TargetOS) <_targetArchitecture>$(TargetArchitecture) - true + NativeAOT + CoreCLR static true <_IsApplePlatform Condition="'$(TargetsAppleMobile)' == 'true'">true diff --git a/src/tests/build.proj b/src/tests/build.proj index 96b6595c4ba91e..12aaff5466a8d9 100644 --- a/src/tests/build.proj +++ b/src/tests/build.proj @@ -423,8 +423,7 @@ - - + $([System.IO.Path]::GetDirectoryName($([System.IO.Path]::GetDirectoryName($(_CMDDIR))))) $([System.IO.Path]::GetFileName($(CategoryPath))) @@ -443,7 +442,10 @@ false false + + + @@ -454,6 +456,10 @@ + + $(IntermediateOutputPath)\..\$(TestRelativePath)\$(TestName)\native\$(TestName).o + + @@ -488,14 +494,21 @@ Projects="@(RunProj)" Targets="BuildMonoiOSApp" BuildInParallel="true" - Condition="'@(TestDirectories)' != '' and '$(TestBuildMode)' != 'nativeaot'" + Condition="'@(TestDirectories)' != '' and '$(RuntimeFlavor)' != 'coreclr'" + /> + + From 7e6d3bdb926fd3364042de1e33f57e8959eeb780 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 18 Nov 2024 14:05:54 +0100 Subject: [PATCH 02/15] Fix rpath on MacCatalyst --- src/tasks/AppleAppBuilder/AppleAppBuilder.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs index 9635fe02dc22d9..2c1304b0dc3600 100644 --- a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs +++ b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs @@ -323,7 +323,14 @@ public override bool Execute() if (targetRuntime == TargetRuntime.CoreCLR) { - extraLinkerArgs.Add("-rpath @executable_path"); + if (targetOS == TargetNames.MacCatalyst) + { + extraLinkerArgs.Add("-rpath @executable_path/../Resources"); + } + else + { + extraLinkerArgs.Add("-rpath @executable_path"); + } shouldStaticLink = false; } From 0de957b211c3b9126cc5743ae4a451c1ed8b4979 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 18 Nov 2024 17:35:04 +0100 Subject: [PATCH 03/15] Apply suggestions from code review Co-authored-by: Aaron Robinson --- src/coreclr/pal/src/map/virtual.cpp | 2 +- src/native/corehost/hostpolicy/hostpolicy_context.cpp | 2 +- src/native/libs/System.Native/entrypoints.c | 2 +- .../System.Security.Cryptography.Native.Apple/entrypoints.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index a5b04430d410e7..63f29be003f2ef 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -1261,7 +1261,7 @@ static struct jit_write_protect_helper #define pthread_jit_write_protect_np jit_write_protect_np -#endif +#endif // defined(TARGET_APPLE) && !defined(TARGET_OSX) PALAPI VOID PAL_JitWriteProtect(bool writeEnable) { diff --git a/src/native/corehost/hostpolicy/hostpolicy_context.cpp b/src/native/corehost/hostpolicy/hostpolicy_context.cpp index 01956d5dc75d80..351fc02377c74f 100644 --- a/src/native/corehost/hostpolicy/hostpolicy_context.cpp +++ b/src/native/corehost/hostpolicy/hostpolicy_context.cpp @@ -75,7 +75,7 @@ namespace { return CryptoResolveDllImport(entry_point_name); } -#endif +#endif // !defined(TARGET_APPLE) || defined(TARGET_OSX) #endif if (strcmp(library_name, LIB_NAME("System.IO.Compression.Native")) == 0) diff --git a/src/native/libs/System.Native/entrypoints.c b/src/native/libs/System.Native/entrypoints.c index c25414cbe7b554..67586dd86317f0 100644 --- a/src/native/libs/System.Native/entrypoints.c +++ b/src/native/libs/System.Native/entrypoints.c @@ -48,7 +48,7 @@ static const Entry s_sysNative[] = DllImportEntry(SystemNative_ReadStdin) DllImportEntry(SystemNative_GetSignalForBreak) DllImportEntry(SystemNative_SetSignalForBreak) -#endif +#endif // !defined(TARGET_APPLE) || defined(TARGET_OSX) DllImportEntry(SystemNative_GetSystemTimeAsTicks) DllImportEntry(SystemNative_GetDefaultTimeZone) DllImportEntry(SystemNative_GetTimeZoneData) diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c b/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c index ea70c53b30477f..9be3ea855a82a7 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c @@ -27,7 +27,7 @@ #else #include "pal_keychain_ios.h" #include "pal_x509_ios.h" -#endif +#endif // defined(TARGET_OSX) static const Entry s_cryptoAppleNative[] = { @@ -144,7 +144,7 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_X509ExportData) DllImportEntry(AppleCryptoNative_X509CopyWithPrivateKey) DllImportEntry(AppleCryptoNative_X509MoveToKeychain) -#endif +#endif // defined(TARGET_OSX) }; EXTERN_C const void* CryptoAppleResolveDllImport(const char* name); From d0e5ed7d218d3dd7200901142a870a9ee14278c0 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 19 Nov 2024 09:30:25 +0100 Subject: [PATCH 04/15] Use CORECLR_HOSTING_API_LINKAGE for extern 'C' --- src/coreclr/hosts/inc/coreclrhost.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coreclr/hosts/inc/coreclrhost.h b/src/coreclr/hosts/inc/coreclrhost.h index 2988ea0452acfd..8c85a1b5276ba7 100644 --- a/src/coreclr/hosts/inc/coreclrhost.h +++ b/src/coreclr/hosts/inc/coreclrhost.h @@ -14,20 +14,20 @@ #define CORECLR_CALLING_CONVENTION #endif +#ifdef __cplusplus +#define CORECLR_HOSTING_API_LINKAGE extern "C" +#else +#define CORECLR_HOSTING_API_LINKAGE +#endif + #include // For each hosting API, we define a function prototype and a function pointer // The prototype is useful for implicit linking against the dynamic coreclr // library and the pointer for explicit dynamic loading (dlopen, LoadLibrary) -#ifdef __cplusplus #define CORECLR_HOSTING_API(function, ...) \ - extern "C" int CORECLR_CALLING_CONVENTION function(__VA_ARGS__); \ + CORECLR_HOSTING_API_LINKAGE int CORECLR_CALLING_CONVENTION function(__VA_ARGS__); \ typedef int (CORECLR_CALLING_CONVENTION *function##_ptr)(__VA_ARGS__) -#else -#define CORECLR_HOSTING_API(function, ...) \ - int CORECLR_CALLING_CONVENTION function(__VA_ARGS__); \ - typedef int (CORECLR_CALLING_CONVENTION *function##_ptr)(__VA_ARGS__) -#endif // // Initialize the CoreCLR. Creates and starts CoreCLR host and creates an app domain From b5a298d55898025ba651650a9a969c1eb689e4f8 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 19 Nov 2024 09:31:13 +0100 Subject: [PATCH 05/15] Remove extra #include --- src/coreclr/pal/src/map/virtual.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 63f29be003f2ef..16a4a946fc3dc5 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -46,10 +46,6 @@ SET_DEFAULT_DEBUG_CHANNEL(VIRTUAL); // some headers have code with asserts, so d #include #endif // HAVE_VM_ALLOCATE -#if defined(TARGET_APPLE) && !defined(TARGET_OSX) -#include -#endif - using namespace CorUnix; CRITICAL_SECTION virtual_critsec; From 05aa0e60b5b9cc20ac769082db981754c2032090 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 19 Nov 2024 09:39:59 +0100 Subject: [PATCH 06/15] Drop ICU linkage (not needed with Hybrid Globalization) --- src/native/libs/System.Globalization.Native/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 53f4456e9229de..035f85a257b97c 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -187,12 +187,6 @@ add_library(System.Globalization.Native-Static entrypoints.c ) -if (DEFINED CMAKE_ICU_DIR) - include_directories(${CMAKE_ICU_DIR}/include) - target_link_libraries(System.Globalization.Native-Static ${CMAKE_ICU_DIR}/lib/libicuuc.a ${CMAKE_ICU_DIR}/lib/libicui18n.a ${CMAKE_ICU_DIR}/lib/libicudata.a) - target_link_libraries(System.Globalization.Native-Static stdc++) -endif() - if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) endif() From b98a4cdbf2e0383ddb09783225a547cf890c7238 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 19 Nov 2024 10:11:23 +0100 Subject: [PATCH 07/15] Move jit_write_protect_np initialization --- src/coreclr/pal/src/map/virtual.cpp | 39 +++++++++++------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 16a4a946fc3dc5..aa02c81a1514b1 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -55,6 +55,11 @@ static PCMI pVirtualMemory; static size_t s_virtualPageSize = 0; +#if defined(HOST_APPLE) && defined(HOST_ARM64) && !defined(HOST_OSX) +void (*jit_write_protect_np)(int enabled); +#define pthread_jit_write_protect_np jit_write_protect_np +#endif // defined(HOST_APPLE) && defined(HOST_ARM64) && !defined(HOST_OSX) + /* We need MAP_ANON. However on some platforms like HP-UX, it is defined as MAP_ANONYMOUS */ #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) #define MAP_ANON MAP_ANONYMOUS @@ -179,6 +184,15 @@ VIRTUALInitialize(bool initializeExecutableMemoryAllocator) g_executableMemoryAllocator.Initialize(); } +#if defined(HOST_APPLE) && defined(HOST_ARM64) && !defined(HOST_OSX) + jit_write_protect_np = (void (*)(int))dlsym(RTLD_DEFAULT, "pthread_jit_write_protect_np"); + if (jit_write_protect_np == NULL) + { + ERROR("pthread_jit_write_protect_np not available.\n"); + return FALSE; + } +#endif // defined(HOST_APPLE) && defined(HOST_ARM64) && !defined(HOST_OSX) + return TRUE; } @@ -1236,29 +1250,6 @@ VirtualProtect( } #if defined(HOST_APPLE) && defined(HOST_ARM64) - -#if defined(TARGET_APPLE) && !defined(TARGET_OSX) - -void -(*jit_write_protect_np)(int enabled); - -static struct jit_write_protect_helper -{ - jit_write_protect_helper() - { - jit_write_protect_np = (void (*)(int))dlsym(RTLD_DEFAULT, "pthread_jit_write_protect_np"); - if (jit_write_protect_np == NULL) - { - ERROR( "pthread_jit_write_protect_np not available.\n" ); - exit(1); - } - } -} jit_write_protect_helper; - -#define pthread_jit_write_protect_np jit_write_protect_np - -#endif // defined(TARGET_APPLE) && !defined(TARGET_OSX) - PALAPI VOID PAL_JitWriteProtect(bool writeEnable) { thread_local int enabledCount = 0; @@ -1278,7 +1269,7 @@ PALAPI VOID PAL_JitWriteProtect(bool writeEnable) _ASSERTE(enabledCount >= 0); } } -#endif // HOST_OSX && HOST_ARM64 +#endif // HOST_APPLE && HOST_ARM64 #if HAVE_VM_ALLOCATE //--------------------------------------------------------------------------------------- From d43265ccaa0f58d8591c03eb659f13a1c44aa91a Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 29 Nov 2024 19:45:22 +0100 Subject: [PATCH 08/15] Use __APPLE__ in PAL instead of TARGET_APPLE for consistency --- src/coreclr/pal/src/CMakeLists.txt | 1 - src/coreclr/pal/src/exception/seh-unwind.cpp | 12 +++++----- src/coreclr/pal/src/include/pal/context.h | 16 ++++++------- src/coreclr/pal/src/misc/sysinfo.cpp | 4 ++-- src/coreclr/pal/src/thread/context.cpp | 24 ++++++++++---------- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 06dc3919c230d0..7781249b8b8c4b 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -73,7 +73,6 @@ if(CLR_CMAKE_TARGET_OSX) endif() if(CLR_CMAKE_TARGET_APPLE) - add_definitions(-DTARGET_APPLE) add_definitions(-D_XOPEN_SOURCE) set(PLATFORM_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/context.S diff --git a/src/coreclr/pal/src/exception/seh-unwind.cpp b/src/coreclr/pal/src/exception/seh-unwind.cpp index 04a12b6956b506..1100c3159159c0 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -44,7 +44,7 @@ Module Name: #endif // HOST_UNIX -#if defined(TARGET_APPLE) && defined(HOST_ARM64) && !defined(HAVE_UNW_AARCH64_X19) +#if defined(__APPLE__) && defined(HOST_ARM64) && !defined(HAVE_UNW_AARCH64_X19) // MacOS uses ARM64 instead of AARCH64 to describe these registers // Create aliases to reuse more code enum @@ -86,7 +86,7 @@ enum UNW_AARCH64_V30 = UNW_ARM64_D30, UNW_AARCH64_V31 = UNW_ARM64_D31 }; -#endif // defined(TARGET_APPLE) && defined(HOST_ARM64) +#endif // defined(__APPLE__) && defined(HOST_ARM64) //---------------------------------------------------------------------- @@ -260,7 +260,7 @@ static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwCon { unwContext->fpregs[i] = winContext->D[i]; } -#elif defined(HOST_ARM64) && !defined(TARGET_APPLE) +#elif defined(HOST_ARM64) && !defined(__APPLE__) unwContext->uc_mcontext.pc = winContext->Pc; unwContext->uc_mcontext.sp = winContext->Sp; unwContext->uc_mcontext.regs[29] = winContext->Fp; @@ -302,7 +302,7 @@ static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor) unw_set_reg(cursor, UNW_X86_EBX, winContext->Ebx); unw_set_reg(cursor, UNW_X86_ESI, winContext->Esi); unw_set_reg(cursor, UNW_X86_EDI, winContext->Edi); -#elif defined(HOST_ARM64) && defined(TARGET_APPLE) +#elif defined(HOST_ARM64) && defined(__APPLE__) // unw_cursor_t is an opaque data structure on macOS // As noted in WinContextToUnwindContext this didn't work for Linux // TBD whether this will work for macOS. @@ -426,12 +426,12 @@ void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_fpreg(cursor, UNW_AARCH64_V30, (unw_fpreg_t*)&winContext->V[30].Low); unw_get_fpreg(cursor, UNW_AARCH64_V31, (unw_fpreg_t*)&winContext->V[31].Low); -#if defined(TARGET_APPLE) && defined(TARGET_ARM64) +#if defined(__APPLE__) && defined(TARGET_ARM64) // Strip pointer authentication bits which seem to be leaking out of libunwind // Seems like ptrauth_strip() / __builtin_ptrauth_strip() should work, but currently // errors with "this target does not support pointer authentication" winContext->Pc = winContext->Pc & 0x7fffffffffffull; -#endif // defined(TARGET_APPLE) && defined(TARGET_ARM64) +#endif // defined(__APPLE__) && defined(TARGET_ARM64) #elif (defined(HOST_UNIX) && defined(HOST_S390X)) unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->R15); unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->PSWAddr); diff --git a/src/coreclr/pal/src/include/pal/context.h b/src/coreclr/pal/src/include/pal/context.h index f769da2a615505..40f0e9b88990df 100644 --- a/src/coreclr/pal/src/include/pal/context.h +++ b/src/coreclr/pal/src/include/pal/context.h @@ -63,7 +63,7 @@ bool Xstate_IsAvx512Supported(); bool Xstate_IsApxSupported(); #endif // XSTATE_SUPPORTED || (HOST_AMD64 && HAVE_MACH_EXCEPTIONS) -#if defined(HOST_64BIT) && defined(HOST_ARM64) && !defined(TARGET_FREEBSD) && !defined(TARGET_APPLE) +#if defined(HOST_64BIT) && defined(HOST_ARM64) && !defined(TARGET_FREEBSD) && !defined(__APPLE__) #if !defined(SVE_MAGIC) // Add the missing SVE defines @@ -145,7 +145,7 @@ struct sve_context { (SVE_SIG_REGS_OFFSET + SVE_SIG_REGS_SIZE(vq)) #endif // SVE_MAGIC -#endif // HOST_64BIT && HOST_ARM64 && !TARGET_FREEBSD && !TARGET_APPLE +#endif // HOST_64BIT && HOST_ARM64 && !TARGET_FREEBSD && !__APPLE__ #ifdef HOST_S390X @@ -740,7 +740,7 @@ const struct fpregs* GetConstNativeSigSimdContext(const native_context_t *mc) return GetNativeSigSimdContext(const_cast(mc)); } -#elif !defined(TARGET_APPLE) // TARGET_FREEBSD +#elif !defined(__APPLE__) // TARGET_FREEBSD #define MCREG_X0(mc) ((mc).regs[0]) #define MCREG_X1(mc) ((mc).regs[1]) @@ -792,7 +792,7 @@ void GetConstNativeSigSimdContext(const native_context_t *mc, fpsimd_context con GetNativeSigSimdContext(const_cast(mc), const_cast(fp_ptr), const_cast(sve_ptr)); } -#else // TARGET_APPLE +#else // __APPLE__ #define MCREG_X0(mc) ((mc)->__ss.__x[0]) #define MCREG_X1(mc) ((mc)->__ss.__x[1]) @@ -842,7 +842,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex return GetNativeSigSimdContext(const_cast(mc)); } -#endif // TARGET_APPLE +#endif // __APPLE__ #elif defined(HOST_LOONGARCH64) @@ -882,7 +882,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex #else // HOST_ARM64 -#ifdef TARGET_APPLE +#ifdef __APPLE__ #define MCREG_Rbp(mc) ((mc)->__ss.__rbp) #define MCREG_Rip(mc) ((mc)->__ss.__rip) @@ -1002,7 +1002,7 @@ inline void *FPREG_Xstate_Hi16Zmm(const ucontext_t *uc, uint32_t *featureSize) #define FPREG_Xmm(uc, index) *(M128A*) &(FPSTATE(uc).fp_fxsave.xmm[index]) #define FPREG_St(uc, index) *(M128A*) &(FPSTATE(uc).fp_fxsave.fp[index].value) -#else //TARGET_APPLE +#else //__APPLE__ // For FreeBSD, as found in x86/ucontext.h #define MCREG_Rbp(mc) ((mc).mc_rbp) @@ -1039,7 +1039,7 @@ inline void *FPREG_Xstate_Hi16Zmm(const ucontext_t *uc, uint32_t *featureSize) #define FPREG_Xmm(uc, index) *(M128A*) &(FPSTATE(uc)->sv_xmm[index]) #define FPREG_St(uc, index) *(M128A*) &(FPSTATE(uc)->sv_fp[index].fp_acc) -#endif // TARGET_APPLE +#endif // __APPLE__ #endif // HOST_ARM64 #else // HOST_64BIT diff --git a/src/coreclr/pal/src/misc/sysinfo.cpp b/src/coreclr/pal/src/misc/sysinfo.cpp index e0f8af8c6e7c23..f4fef6977f3d62 100644 --- a/src/coreclr/pal/src/misc/sysinfo.cpp +++ b/src/coreclr/pal/src/misc/sysinfo.cpp @@ -58,12 +58,12 @@ Revision History: #include #endif // HAVE_MACHINE_VMPARAM_H -#if defined(TARGET_APPLE) +#if defined(__APPLE__) #include #include #include #include -#endif // defined(TARGET_APPLE) +#endif // defined(__APPLE__) #ifdef __HAIKU__ #include diff --git a/src/coreclr/pal/src/thread/context.cpp b/src/coreclr/pal/src/thread/context.cpp index e3c33c7468673a..feff4b8915f7fd 100644 --- a/src/coreclr/pal/src/thread/context.cpp +++ b/src/coreclr/pal/src/thread/context.cpp @@ -725,7 +725,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) #endif // (HAVE_GREGSET_T || HAVE___GREGSET_T) && !HOST_S390X && !HOST_LOONGARCH64 && !HOST_RISCV64 && !HOST_POWERPC64 #endif // !HAVE_FPREGS_WITH_CW -#if defined(HOST_ARM64) && !defined(TARGET_APPLE) && !defined(TARGET_FREEBSD) +#if defined(HOST_ARM64) && !defined(__APPLE__) && !defined(TARGET_FREEBSD) sve_context* sve = nullptr; fpsimd_context* fp = nullptr; if (((lpContext->ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) || @@ -733,7 +733,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) { GetNativeSigSimdContext(native, &fp, &sve); } -#endif // HOST_ARM64 && !TARGET_APPLE && !TARGET_FREEBSD +#endif // HOST_ARM64 && !__APPLE__ && !TARGET_FREEBSD if ((lpContext->ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) { @@ -763,7 +763,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) FPREG_Xmm(native, i) = lpContext->FltSave.XmmRegisters[i]; } #elif defined(HOST_ARM64) -#ifdef TARGET_APPLE +#ifdef __APPLE__ _STRUCT_ARM_NEON_STATE64* fp = GetNativeSigSimdContext(native); fp->__fpsr = lpContext->Fpsr; fp->__fpcr = lpContext->Fpcr; @@ -782,7 +782,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->fp_q[i] = lpContext->V[i]; } } -#else // TARGET_APPLE +#else // __APPLE__ if (fp) { fp->fpsr = lpContext->Fpsr; @@ -792,7 +792,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->vregs[i] = lpContext->V[i]; } } -#endif // TARGET_APPLE +#endif // __APPLE__ #elif defined(HOST_ARM) VfpSigFrame* fp = GetNativeSigSimdContext(native); if (fp) @@ -920,7 +920,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) } -#if defined(HOST_64BIT) && defined(HOST_ARM64) && !defined(TARGET_FREEBSD) && !defined(TARGET_APPLE) +#if defined(HOST_64BIT) && defined(HOST_ARM64) && !defined(TARGET_FREEBSD) && !defined(__APPLE__) /*++ Function : _GetNativeSigSimdContext @@ -1010,7 +1010,7 @@ void _GetNativeSigSimdContext(uint8_t *data, uint32_t size, fpsimd_context **fp_ *sve_ptr = sve; } } -#endif // HOST_64BIT && HOST_ARM64 && !TARGET_FREEBSD && !TARGET_APPLE +#endif // HOST_64BIT && HOST_ARM64 && !TARGET_FREEBSD && !__APPLE__ /*++ Function : @@ -1077,7 +1077,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex #endif // (HAVE_GREGSET_T || HAVE___GREGSET_T) && !HOST_S390X && !HOST_LOONGARCH64 && !HOST_RISCV64 && !HOST_POWERPC64 && !HOST_POWERPC64 #endif // !HAVE_FPREGS_WITH_CW -#if defined(HOST_ARM64) && !defined(TARGET_APPLE) && !defined(TARGET_FREEBSD) +#if defined(HOST_ARM64) && !defined(__APPLE__) && !defined(TARGET_FREEBSD) const fpsimd_context* fp = nullptr; const sve_context* sve = nullptr; if (((lpContext->ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) || @@ -1085,7 +1085,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex { GetConstNativeSigSimdContext(native, &fp, &sve); } -#endif // HOST_ARM64 && !TARGET_APPLE && !TARGET_FREEBSD +#endif // HOST_ARM64 && !__APPLE__ && !TARGET_FREEBSD if ((contextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) { @@ -1114,7 +1114,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->FltSave.XmmRegisters[i] = FPREG_Xmm(native, i); } #elif defined(HOST_ARM64) -#ifdef TARGET_APPLE +#ifdef __APPLE__ const _STRUCT_ARM_NEON_STATE64* fp = GetConstNativeSigSimdContext(native); lpContext->Fpsr = fp->__fpsr; lpContext->Fpcr = fp->__fpcr; @@ -1133,7 +1133,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->fp_q[i]; } } -#else // TARGET_APPLE +#else // __APPLE__ if (fp) { lpContext->Fpsr = fp->fpsr; @@ -1143,7 +1143,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->vregs[i]; } } -#endif // TARGET_APPLE +#endif // __APPLE__ #elif defined(HOST_ARM) const VfpSigFrame* fp = GetConstNativeSigSimdContext(native); if (fp) From e3b4af9fc48b5f17a8e763ec71424972c6e4bb33 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 30 Nov 2024 13:42:18 +0100 Subject: [PATCH 09/15] Revert changes to native libs and exclude singlefilehost --- src/coreclr/CMakeLists.txt | 2 +- src/native/libs/System.Native/CMakeLists.txt | 2 +- src/native/libs/System.Native/entrypoints.c | 2 - .../System.Net.Security.Native/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../entrypoints.c | 46 ++++++++----------- 6 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index cfae08b84ecb28..d6923d3a7dc8fb 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -59,7 +59,7 @@ include(components.cmake) #--------------------------- # Build the single file host #--------------------------- -if(NOT CLR_CROSS_COMPONENTS_BUILD) +if(NOT CLR_CROSS_COMPONENTS_BUILD AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(CLR_SINGLE_FILE_HOST_ONLY 1) add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) add_dependencies(runtime singlefilehost) diff --git a/src/native/libs/System.Native/CMakeLists.txt b/src/native/libs/System.Native/CMakeLists.txt index 8dbbf14d90f53d..7712f255602028 100644 --- a/src/native/libs/System.Native/CMakeLists.txt +++ b/src/native/libs/System.Native/CMakeLists.txt @@ -126,7 +126,7 @@ if (GEN_SHARED_LIB) install_with_stripped_symbols (System.Native PROGRAMS .) endif () -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVE_SOURCES ${NATIVE_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.Native/entrypoints.c b/src/native/libs/System.Native/entrypoints.c index 67586dd86317f0..a133f59b179e2d 100644 --- a/src/native/libs/System.Native/entrypoints.c +++ b/src/native/libs/System.Native/entrypoints.c @@ -34,7 +34,6 @@ static const Entry s_sysNative[] = { DllImportEntry(SystemNative_FStat) -#if !defined(TARGET_APPLE) || defined(TARGET_OSX) DllImportEntry(SystemNative_GetWindowSize) DllImportEntry(SystemNative_IsATty) DllImportEntry(SystemNative_InitializeTerminalAndSignalHandling) @@ -48,7 +47,6 @@ static const Entry s_sysNative[] = DllImportEntry(SystemNative_ReadStdin) DllImportEntry(SystemNative_GetSignalForBreak) DllImportEntry(SystemNative_SetSignalForBreak) -#endif // !defined(TARGET_APPLE) || defined(TARGET_OSX) DllImportEntry(SystemNative_GetSystemTimeAsTicks) DllImportEntry(SystemNative_GetDefaultTimeZone) DllImportEntry(SystemNative_GetTimeZoneData) diff --git a/src/native/libs/System.Net.Security.Native/CMakeLists.txt b/src/native/libs/System.Net.Security.Native/CMakeLists.txt index e8efae3d33a795..b0e02f41509b58 100644 --- a/src/native/libs/System.Net.Security.Native/CMakeLists.txt +++ b/src/native/libs/System.Net.Security.Native/CMakeLists.txt @@ -19,7 +19,7 @@ if (GEN_SHARED_LIB) ) endif() -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVEGSS_SOURCES ${NATIVEGSS_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt b/src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt index daba219facad9c..84615493f4495c 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt @@ -105,7 +105,7 @@ if (GEN_SHARED_LIB) ) endif() -if (NOT GEN_SHARED_LIB) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(NATIVECRYPTO_SOURCES ${NATIVECRYPTO_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c b/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c index 9be3ea855a82a7..5163aa5b121236 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c @@ -8,6 +8,7 @@ #include "pal_ecc.h" #include "pal_hmac.h" #include "pal_keyagree.h" +#include "pal_keychain_macos.h" #include "pal_keyderivation.h" #include "pal_random.h" #include "pal_rsa.h" @@ -18,16 +19,10 @@ #include "pal_ssl.h" #include "pal_swiftbindings.h" #include "pal_symmetric.h" -#include "pal_x509.h" -#include "pal_x509chain.h" -#if defined(TARGET_OSX) #include "pal_trust_macos.h" -#include "pal_keychain_macos.h" +#include "pal_x509.h" #include "pal_x509_macos.h" -#else -#include "pal_keychain_ios.h" -#include "pal_x509_ios.h" -#endif // defined(TARGET_OSX) +#include "pal_x509chain.h" static const Entry s_cryptoAppleNative[] = { @@ -36,7 +31,6 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_ChaCha20Poly1305Encrypt) DllImportEntry(AppleCryptoNative_ChaCha20Poly1305Decrypt) DllImportEntry(AppleCryptoNative_DigestClone) - DllImportEntry(AppleCryptoNative_DigestFree) DllImportEntry(AppleCryptoNative_DigestCreate) DllImportEntry(AppleCryptoNative_DigestCurrent) DllImportEntry(AppleCryptoNative_DigestFinal) @@ -57,8 +51,15 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_HmacOneShot) DllImportEntry(AppleCryptoNative_HmacUpdate) DllImportEntry(AppleCryptoNative_IsAuthenticationFailure) + DllImportEntry(AppleCryptoNative_SecKeychainItemCopyKeychain) + DllImportEntry(AppleCryptoNative_SecKeychainCopyDefault) + DllImportEntry(AppleCryptoNative_SecKeychainCreate) + DllImportEntry(AppleCryptoNative_SecKeychainDelete) DllImportEntry(AppleCryptoNative_SecKeychainEnumerateCerts) + DllImportEntry(AppleCryptoNative_SecKeychainOpen) + DllImportEntry(AppleCryptoNative_SecKeychainUnlock) DllImportEntry(AppleCryptoNative_SecKeychainEnumerateIdentities) + DllImportEntry(AppleCryptoNative_SetKeychainNeverLock) DllImportEntry(AppleCryptoNative_SslCopyCADistinguishedNames) DllImportEntry(AppleCryptoNative_SslCopyCertChain) DllImportEntry(AppleCryptoNative_SslIsHostnameMatch) @@ -79,6 +80,8 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_RsaEncryptionPrimitive) DllImportEntry(AppleCryptoNative_RsaVerificationPrimitive) DllImportEntry(AppleCryptoNative_SecCopyErrorMessageString) + DllImportEntry(AppleCryptoNative_SecKeyExport) + DllImportEntry(AppleCryptoNative_SecKeyImportEphemeral) DllImportEntry(AppleCryptoNative_SecKeyGetSimpleKeySizeInBytes) DllImportEntry(AppleCryptoNative_SecKeyCreateSignature) DllImportEntry(AppleCryptoNative_SecKeyVerifySignature) @@ -105,6 +108,10 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_CryptorCreate) DllImportEntry(AppleCryptoNative_CryptorUpdate) DllImportEntry(AppleCryptoNative_CryptorReset) + DllImportEntry(AppleCryptoNative_StoreEnumerateUserRoot) + DllImportEntry(AppleCryptoNative_StoreEnumerateMachineRoot) + DllImportEntry(AppleCryptoNative_StoreEnumerateUserDisallowed) + DllImportEntry(AppleCryptoNative_StoreEnumerateMachineDisallowed) DllImportEntry(AppleCryptoNative_X509ChainCreate) DllImportEntry(AppleCryptoNative_X509DemuxAndRetainHandle) DllImportEntry(AppleCryptoNative_X509GetContentType) @@ -113,7 +120,10 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_X509CopyPrivateKeyFromIdentity) DllImportEntry(AppleCryptoNative_X509ImportCollection) DllImportEntry(AppleCryptoNative_X509ImportCertificate) + DllImportEntry(AppleCryptoNative_X509ExportData) DllImportEntry(AppleCryptoNative_X509GetRawData) + DllImportEntry(AppleCryptoNative_X509CopyWithPrivateKey) + DllImportEntry(AppleCryptoNative_X509MoveToKeychain) DllImportEntry(AppleCryptoNative_X509ChainCreateDefaultPolicy) DllImportEntry(AppleCryptoNative_X509ChainCreateRevocationPolicy) DllImportEntry(AppleCryptoNative_X509ChainEvaluate) @@ -127,24 +137,6 @@ static const Entry s_cryptoAppleNative[] = DllImportEntry(AppleCryptoNative_X509StoreRemoveCertificate) DllImportEntry(AppleCryptoNative_Pbkdf2) DllImportEntry(AppleCryptoNative_X509GetSubjectSummary) -#ifdef TARGET_OSX - DllImportEntry(AppleCryptoNative_SecKeychainItemCopyKeychain) - DllImportEntry(AppleCryptoNative_SecKeychainCopyDefault) - DllImportEntry(AppleCryptoNative_SecKeychainCreate) - DllImportEntry(AppleCryptoNative_SecKeychainDelete) - DllImportEntry(AppleCryptoNative_SecKeychainOpen) - DllImportEntry(AppleCryptoNative_SecKeychainUnlock) - DllImportEntry(AppleCryptoNative_SetKeychainNeverLock) - DllImportEntry(AppleCryptoNative_SecKeyExport) - DllImportEntry(AppleCryptoNative_SecKeyImportEphemeral) - DllImportEntry(AppleCryptoNative_StoreEnumerateUserRoot) - DllImportEntry(AppleCryptoNative_StoreEnumerateMachineRoot) - DllImportEntry(AppleCryptoNative_StoreEnumerateUserDisallowed) - DllImportEntry(AppleCryptoNative_StoreEnumerateMachineDisallowed) - DllImportEntry(AppleCryptoNative_X509ExportData) - DllImportEntry(AppleCryptoNative_X509CopyWithPrivateKey) - DllImportEntry(AppleCryptoNative_X509MoveToKeychain) -#endif // defined(TARGET_OSX) }; EXTERN_C const void* CryptoAppleResolveDllImport(const char* name); From 02389e7513b2baeed8b843c510977164d49c3ceb Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 30 Nov 2024 13:49:01 +0100 Subject: [PATCH 10/15] Revert more singlefilehost changes --- src/native/corehost/apphost/static/CMakeLists.txt | 8 ++++---- src/native/corehost/hostmisc/pal.h | 2 +- src/native/corehost/hostpolicy/hostpolicy_context.cpp | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 18952ba9cb7b1a..25c1d55e7360cd 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -171,6 +171,7 @@ else() System.IO.Compression.Native-Static System.Net.Security.Native-Static System.Native-Static + System.Security.Cryptography.Native.OpenSsl-Static coreclrpal_dac corguids @@ -179,10 +180,6 @@ else() nativeresourcestring ) - if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_HOST_ANDROID) - LIST(APPEND NATIVE_LIBS System.Security.Cryptography.Native.OpenSsl-Static) - endif() - # additional requirements for System.IO.Compression.Native include(${CLR_SRC_NATIVE_DIR}/libs/System.IO.Compression.Native/extra_libs.cmake) append_extra_compression_libs(NATIVE_LIBS) @@ -204,6 +201,7 @@ else() endif() set(RUNTIMEINFO_LIB runtimeinfo) + endif() if(CLR_CMAKE_TARGET_APPLE) @@ -221,11 +219,13 @@ endif() # if(CLR_CMAKE_TARGET_APPLE) find_library(COREFOUNDATION CoreFoundation) + find_library(CORESERVICES CoreServices) find_library(SECURITY Security) find_library(SYSTEM System) LIST(APPEND NATIVE_LIBS ${COREFOUNDATION} + ${CORESERVICES} ${SECURITY} ${SYSTEM} ) diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index 0c1f1b2d787c54..bde8446cc22cdf 100644 --- a/src/native/corehost/hostmisc/pal.h +++ b/src/native/corehost/hostmisc/pal.h @@ -71,7 +71,7 @@ #if defined(TARGET_WINDOWS) #define LIB_PREFIX "" #define LIB_FILE_EXT ".dll" -#elif defined(TARGET_APPLE) +#elif defined(TARGET_OSX) #define LIB_PREFIX "lib" #define LIB_FILE_EXT ".dylib" #else diff --git a/src/native/corehost/hostpolicy/hostpolicy_context.cpp b/src/native/corehost/hostpolicy/hostpolicy_context.cpp index 351fc02377c74f..63ef9cdbc0d32f 100644 --- a/src/native/corehost/hostpolicy/hostpolicy_context.cpp +++ b/src/native/corehost/hostpolicy/hostpolicy_context.cpp @@ -70,12 +70,10 @@ namespace return SystemResolveDllImport(entry_point_name); } -#if !defined(TARGET_APPLE) || defined(TARGET_OSX) if (strcmp(library_name, LIB_NAME("System.Security.Cryptography.Native.OpenSsl")) == 0) { return CryptoResolveDllImport(entry_point_name); } -#endif // !defined(TARGET_APPLE) || defined(TARGET_OSX) #endif if (strcmp(library_name, LIB_NAME("System.IO.Compression.Native")) == 0) @@ -97,7 +95,7 @@ namespace } } -#if defined(TARGET_APPLE) +#if defined(TARGET_OSX) if (strcmp(library_name, LIB_NAME("System.Security.Cryptography.Native.Apple")) == 0) { return CryptoAppleResolveDllImport(entry_point_name); From e4251b17f1e768f550a94e43c66bc8ce7fe3e9d8 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 30 Nov 2024 17:48:34 +0100 Subject: [PATCH 11/15] Remove excessive -D_XOPEN_SOURCE --- src/coreclr/pal/src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 7781249b8b8c4b..a46316b56413ee 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -73,7 +73,6 @@ if(CLR_CMAKE_TARGET_OSX) endif() if(CLR_CMAKE_TARGET_APPLE) - add_definitions(-D_XOPEN_SOURCE) set(PLATFORM_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/context.S arch/${PAL_ARCH_SOURCES_DIR}/dispatchexceptionwrapper.S From 3ff9213df6c93e5f227818f39c75123d423dcb07 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 7 Jan 2025 11:57:52 +0100 Subject: [PATCH 12/15] Fix build with FEATURE_PERFTRACING_STANDALONE_PAL (debug libs) --- src/native/eventpipe/ds-ipc-pal-socket.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/native/eventpipe/ds-ipc-pal-socket.c b/src/native/eventpipe/ds-ipc-pal-socket.c index 7ad0b0f5d4859c..104879298e92af 100644 --- a/src/native/eventpipe/ds-ipc-pal-socket.c +++ b/src/native/eventpipe/ds-ipc-pal-socket.c @@ -123,6 +123,27 @@ ep_rt_object_array_free (void *ptr) if (ptr) free (ptr); } + +static +inline +ep_char8_t * +ep_rt_utf8_string_dup (const ep_char8_t *str) +{ + if (!str) + return NULL; + + return strdup (str); +} + +static +inline +void +ep_rt_utf8_string_free (ep_char8_t *str) +{ + if (str) + free (str); +} + #endif static bool _ipc_pal_socket_init = false; From d2fcf8270a99619b687f128f002d473fbaa1bfb0 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 15 Jan 2025 12:32:23 +0100 Subject: [PATCH 13/15] Build with FEATURE_STANDALONE_GC=0 --- src/coreclr/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index d6923d3a7dc8fb..badc19040fcadb 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -29,7 +29,7 @@ if(CORECLR_SET_RPATH) set(MACOSX_RPATH ON) endif(CORECLR_SET_RPATH) -if(CLR_CMAKE_HOST_TVOS) +if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) set(FEATURE_STANDALONE_GC 0) endif() From 5098d4718e13cbe018a2042428da66492127aabe Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 22 Jan 2025 22:13:41 +0100 Subject: [PATCH 14/15] Remove extra NativeDependencies property (bad merge) --- src/tests/build.proj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tests/build.proj b/src/tests/build.proj index 12aaff5466a8d9..289fd39e04b073 100644 --- a/src/tests/build.proj +++ b/src/tests/build.proj @@ -456,10 +456,6 @@ - - $(IntermediateOutputPath)\..\$(TestRelativePath)\$(TestName)\native\$(TestName).o - - From f6aae308cd9be41f3b06e7940d084aacae640765 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 23 Jan 2025 11:56:33 +0100 Subject: [PATCH 15/15] Add back the UseNativeAOTRuntime property to unblock CI --- src/tests/Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props index ec537c61c5d9cd..136b5db5ae4eb0 100644 --- a/src/tests/Directory.Build.props +++ b/src/tests/Directory.Build.props @@ -223,6 +223,7 @@ <_targetOS>$(TargetOS) <_targetArchitecture>$(TargetArchitecture) + true NativeAOT CoreCLR static