From 268e28129bf93da1285fd28da6d4b20d56a3738a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 7 Feb 2023 19:51:24 +0100 Subject: [PATCH 01/14] Enable building NativeAOT for Apple mobile platforms These changes allow the NativeAOT runtime to compile for and run on iOS, tvOS and MacCatalyst. Contributes to https://github.com/dotnet/runtime/issues/81024 --- eng/Subsets.props | 8 +-- eng/native/build-commons.sh | 52 +++++++++++++++++++ eng/native/configurecompiler.cmake | 32 +++++++++++- eng/native/tryrun_ios_tvos.cmake | 50 ++++++++++++++++++ src/coreclr/clrdefinitions.cmake | 4 +- src/coreclr/crosscomponents.cmake | 2 +- src/coreclr/debug/dbgutil/CMakeLists.txt | 8 +-- src/coreclr/dlls/mscordac/CMakeLists.txt | 8 +-- src/coreclr/dlls/mscordbi/CMakeLists.txt | 4 +- .../dlls/mscoree/coreclr/CMakeLists.txt | 6 +-- src/coreclr/gc/CMakeLists.txt | 6 +-- src/coreclr/gc/gc.cpp | 4 +- src/coreclr/gc/unix/gcenv.unix.cpp | 37 +++++++++---- src/coreclr/inc/crosscomp.h | 14 ++++- src/coreclr/inc/executableallocator.h | 4 +- .../Microsoft.NETCore.Native.targets | 1 + src/coreclr/nativeaot/CMakeLists.txt | 4 +- src/coreclr/nativeaot/Directory.Build.props | 2 +- .../src/System/Runtime/ThunkPool.cs | 2 +- src/coreclr/nativeaot/Runtime/CMakeLists.txt | 8 +-- src/coreclr/nativeaot/Runtime/CommonMacros.h | 2 +- .../nativeaot/Runtime/ThunksMapping.cpp | 16 +++++- .../Runtime/unix/HardwareExceptions.cpp | 6 ++- .../nativeaot/Runtime/unix/PalRedhawkUnix.cpp | 12 +++-- .../NativeLibrary.NativeAot.Unix.cs | 2 +- src/coreclr/pal/inc/pal.h | 4 +- src/coreclr/pal/inc/rt/palrt.h | 2 - src/coreclr/pal/src/CMakeLists.txt | 35 ++++++++----- src/coreclr/pal/src/configure.cmake | 10 ++-- src/coreclr/pal/src/exception/seh-unwind.cpp | 14 ++--- src/coreclr/pal/src/exception/signal.cpp | 4 +- src/coreclr/pal/src/include/pal/context.h | 12 ++--- src/coreclr/pal/src/include/pal/mutex.hpp | 4 +- src/coreclr/pal/src/map/virtual.cpp | 10 +++- src/coreclr/pal/src/misc/sysinfo.cpp | 8 +-- src/coreclr/pal/src/thread/context.cpp | 18 ++++--- src/coreclr/pal/src/thread/process.cpp | 33 +++++++++--- src/coreclr/pal/src/thread/thread.cpp | 8 +-- .../pal_sxs/test1/CMakeLists.txt | 4 +- .../tools/Common/CommandLineHelpers.cs | 3 ++ .../Common/TypeSystem/Common/TargetDetails.cs | 16 ++++-- .../DependencyAnalysis/ObjectWriter.cs | 15 ++++++ .../aot/ILCompiler/ILCompilerRootCommand.cs | 2 +- src/coreclr/utilcode/executableallocator.cpp | 4 +- .../Common/src/Interop/Interop.ICU.iOS.cs | 3 ++ .../GlobalizationMode.LoadICU.iOS.cs | 6 ++- src/mono/Directory.Build.props | 2 +- .../apphost/standalone/CMakeLists.txt | 2 +- .../corehost/apphost/static/CMakeLists.txt | 30 ++++++----- src/native/external/llvm-libunwind.cmake | 2 +- .../System.Globalization.Native/pal_icushim.h | 4 ++ .../System.Globalization.Native/pal_locale.m | 7 +++ src/native/libs/build-native.sh | 16 +++--- 53 files changed, 421 insertions(+), 151 deletions(-) create mode 100644 eng/native/tryrun_ios_tvos.cmake diff --git a/eng/Subsets.props b/eng/Subsets.props index 047cbeddf7b1a..cc366a3d4c3a2 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -45,7 +45,8 @@ - Mono + Mono + CoreCLR Mono $(PrimaryRuntimeFlavor) @@ -71,7 +72,8 @@ libs.native+ - $(DefaultLibrariesSubsets)libs.sfx+libs.oob+libs.pretest + $(DefaultLibrariesSubsets)libs.sfx+libs.oob+ + $(DefaultLibrariesSubsets)+libs.pretest tools.illink @@ -105,7 +107,7 @@ - true + true true diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 7246b091e331c..da1d10bf5ca84 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -102,6 +102,58 @@ build_native() echo "Error: Unknown Android architecture $hostArch." exit 1 fi + elif [[ "$__TargetOS" == iossimulator ]]; then + cmakeArgs="-C $__RepoRootDir/eng/native/tryrun_ios_tvos.cmake $cmakeArgs" + + # set default iOS simulator deployment target + # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh + cmakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $cmakeArgs" + if [[ "$__TargetArch" == x64 ]]; then + cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $cmakeArgs" + elif [[ "$__TargetArch" == arm64 ]]; then + cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $cmakeArgs" + else + echo "Error: Unknown iOS Simulator architecture $__TargetArch." + exit 1 + fi + elif [[ "$__TargetOS" == ios ]]; then + cmakeArgs="-C $__RepoRootDir/eng/native/tryrun_ios_tvos.cmake $cmakeArgs" + + # set default iOS device deployment target + # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh + cmakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $cmakeArgs" + if [[ "$__TargetArch" == arm64 ]]; then + cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $cmakeArgs" + else + echo "Error: Unknown iOS architecture $__TargetArch." + exit 1 + fi + elif [[ "$__TargetOS" == tvossimulator ]]; then + cmakeArgs="-C $__RepoRootDir/eng/native/tryrun_ios_tvos.cmake $cmakeArgs" + + # set default tvOS simulator deployment target + # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh + cmakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $cmakeArgs" + if [[ "$__TargetArch" == x64 ]]; then + cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $cmakeArgs" + elif [[ "$__TargetArch" == arm64 ]]; then + cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $cmakeArgs" + else + echo "Error: Unknown tvOS Simulator architecture $__TargetArch." + exit 1 + fi + elif [[ "$__TargetOS" == tvos ]]; then + cmakeArgs="-C $__RepoRootDir/eng/native/tryrun_ios_tvos.cmake $cmakeArgs" + + # set default tvOS device deployment target + # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh + cmakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $cmakeArgs" + if [[ "$__TargetArch" == arm64 ]]; then + cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $cmakeArgs" + else + echo "Error: Unknown tvOS architecture $__TargetArch." + exit 1 + fi fi if [[ "$__UseNinja" == 1 ]]; then diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 34fb9a51a7055..d0b6f850a13b4 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -276,7 +276,11 @@ if (CLR_CMAKE_HOST_UNIX) add_definitions(-DHOST_UNIX) if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST) - add_definitions(-DHOST_OSX) + if(CLR_CMAKE_HOST_MACCATALYST) + add_definitions(-DHOST_MACCATALYST) + else() + add_definitions(-DHOST_OSX) + endif() if(CLR_CMAKE_HOST_UNIX_AMD64) message("Detected OSX x86_64") elseif(CLR_CMAKE_HOST_UNIX_ARM64) @@ -284,6 +288,24 @@ if (CLR_CMAKE_HOST_UNIX) else() clr_unknown_arch() endif() + elseif (CLR_CMAKE_HOST_IOS) + add_definitions(-DHOST_IOS) + if(CLR_CMAKE_HOST_UNIX_AMD64) + message("Detected iOS x86_64") + elseif(CLR_CMAKE_HOST_UNIX_ARM64) + message("Detected iOS ARM64") + else() + clr_unknown_arch() + endif() + elseif (CLR_CMAKE_HOST_TVOS) + add_definitions(-DHOST_TVOS) + if(CLR_CMAKE_HOST_UNIX_AMD64) + message("Detected tvOS x86_64") + elseif(CLR_CMAKE_HOST_UNIX_ARM64) + message("Detected tvOS ARM64") + else() + clr_unknown_arch() + endif() elseif(CLR_CMAKE_HOST_FREEBSD) if(CLR_CMAKE_HOST_UNIX_ARM64) message("Detected FreeBSD aarch64") @@ -540,8 +562,14 @@ if(CLR_CMAKE_TARGET_UNIX) add_compile_definitions($<$>>:TARGET_UNIX>) # Contracts are disabled on UNIX. add_definitions(-DDISABLE_CONTRACTS) - if(CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + if(CLR_CMAKE_TARGET_OSX) add_compile_definitions($<$>>:TARGET_OSX>) + elseif(CLR_CMAKE_TARGET_MACCATALYST) + add_compile_definitions($<$>>:TARGET_MACCATALYST>) + elseif(CLR_CMAKE_TARGET_IOS) + add_compile_definitions($<$>>:TARGET_IOS>) + elseif(CLR_CMAKE_TARGET_TVOS) + add_compile_definitions($<$>>:TARGET_TVOS>) elseif(CLR_CMAKE_TARGET_FREEBSD) add_compile_definitions($<$>>:TARGET_FREEBSD>) elseif(CLR_CMAKE_TARGET_ANDROID) diff --git a/eng/native/tryrun_ios_tvos.cmake b/eng/native/tryrun_ios_tvos.cmake new file mode 100644 index 0000000000000..46769ca69daa3 --- /dev/null +++ b/eng/native/tryrun_ios_tvos.cmake @@ -0,0 +1,50 @@ +macro(set_cache_value) + set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE) + set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE) +endmacro() + +set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 1) +set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 1) +set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0) + + +# TODO: these are taken from macOS, check these whether they're correct for iOS +# some of them are probably not used by what we use from NativeAOT so could be reduced +set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1) +set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 1) +set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 1) +set_cache_value(HAVE_BROKEN_FIFO_KEVENT_EXITCODE 1) +set_cache_value(HAVE_BROKEN_FIFO_SELECT_EXITCODE 1) +set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0) +set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0) +set_cache_value(HAVE_CLOCK_GETTIME_NSEC_NP_EXITCODE 0) +set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0) +set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0) +set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0) +set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 1) +set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0) +set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1) +set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0) +set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0) +set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0) +set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 1) +set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0) +set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 1) +set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1) +set_cache_value(HAVE_PROCFS_MAPS_EXITCODE 1) +set_cache_value(HAVE_PROCFS_STATUS_EXITCODE 1) +set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1) +set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0) +set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0) +set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0) +set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0) +set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0) +set_cache_value(MMAP_ANON_IGNORES_PROTECTION_EXITCODE 1) +set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1) +set_cache_value(PTHREAD_CREATE_MODIFIES_ERRNO_EXITCODE 1) +set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1) +set_cache_value(SEM_INIT_MODIFIES_ERRNO_EXITCODE 1) +set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1) +set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 0) +set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 1) +set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 1) diff --git a/src/coreclr/clrdefinitions.cmake b/src/coreclr/clrdefinitions.cmake index fad480f2aea95..fab835ef7600f 100644 --- a/src/coreclr/clrdefinitions.cmake +++ b/src/coreclr/clrdefinitions.cmake @@ -29,9 +29,9 @@ if (CLR_CMAKE_TARGET_UNIX) endif(CLR_CMAKE_TARGET_UNIX) -if (CLR_CMAKE_TARGET_OSX AND CLR_CMAKE_TARGET_ARCH_ARM64) +if ((CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND CLR_CMAKE_TARGET_ARCH_ARM64) add_compile_definitions($<$>>:OSX_ARM64_ABI>) -endif(CLR_CMAKE_TARGET_OSX AND CLR_CMAKE_TARGET_ARCH_ARM64) +endif((CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND CLR_CMAKE_TARGET_ARCH_ARM64) if(CLR_CMAKE_TARGET_ALPINE_LINUX) # Alpine Linux doesn't have fixed stack limit, this define disables some stack pointer diff --git a/src/coreclr/crosscomponents.cmake b/src/coreclr/crosscomponents.cmake index 7c74eef9c5753..49f40db14bb29 100644 --- a/src/coreclr/crosscomponents.cmake +++ b/src/coreclr/crosscomponents.cmake @@ -33,7 +33,7 @@ if (CLR_CMAKE_HOST_OS STREQUAL CLR_CMAKE_TARGET_OS) endif() endif() -if(NOT CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_OSX AND NOT FEATURE_CROSSBITNESS) +if(NOT CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_OSX AND NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS AND NOT FEATURE_CROSSBITNESS) install_clr (TARGETS mscordaccore mscordbi diff --git a/src/coreclr/debug/dbgutil/CMakeLists.txt b/src/coreclr/debug/dbgutil/CMakeLists.txt index 91f41404221df..31cb4703dd6fe 100644 --- a/src/coreclr/debug/dbgutil/CMakeLists.txt +++ b/src/coreclr/debug/dbgutil/CMakeLists.txt @@ -5,9 +5,9 @@ if(CLR_CMAKE_HOST_WIN32) set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded) endif(CLR_CMAKE_HOST_WIN32) -if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX) +if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) include_directories(${CLR_DIR}/inc/llvm) -endif(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX) +endif(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) add_definitions(-DPAL_STDCPP_COMPAT) @@ -25,10 +25,10 @@ if(CLR_CMAKE_TARGET_LINUX) ) endif(CLR_CMAKE_TARGET_LINUX) -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) list(APPEND DBGUTIL_SOURCES machoreader.cpp ) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) add_library_clr(dbgutil STATIC ${DBGUTIL_SOURCES}) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 25c2532358774..8c680e189afc8 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -31,14 +31,14 @@ 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) + if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) 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) + endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) - if(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_OSX AND CLR_CMAKE_HOST_ARCH_ARM64) + if(CORECLR_SET_RPATH AND (CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) AND CLR_CMAKE_HOST_ARCH_ARM64) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) set(CMAKE_INSTALL_NAME_DIR "@rpath") - endif(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_OSX AND CLR_CMAKE_HOST_ARCH_ARM64) + endif(CORECLR_SET_RPATH AND (CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) AND CLR_CMAKE_HOST_ARCH_ARM64) if(CLR_CMAKE_HOST_LINUX) diff --git a/src/coreclr/dlls/mscordbi/CMakeLists.txt b/src/coreclr/dlls/mscordbi/CMakeLists.txt index 95e92034e238f..04634a279fdba 100644 --- a/src/coreclr/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/dlls/mscordbi/CMakeLists.txt @@ -2,7 +2,7 @@ # Set the RPATH of mscordbi so that it can find dependencies without needing to set LD_LIBRARY_PATH # For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling. if(CORECLR_SET_RPATH) - if(CLR_CMAKE_HOST_OSX) + if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) set(CMAKE_INSTALL_NAME_DIR "@rpath") set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) @@ -10,7 +10,7 @@ if(CORECLR_SET_RPATH) else() set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN") - endif(CLR_CMAKE_HOST_OSX) + endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) endif(CORECLR_SET_RPATH) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index cc23c118a0ce3..c02a494fbfee1 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -50,11 +50,11 @@ else(CLR_CMAKE_HOST_WIN32) set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) - if(CLR_CMAKE_TARGET_OSX) + if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) # These options are used to force every object to be included even if it's unused. set(START_WHOLE_ARCHIVE -force_load) set(END_WHOLE_ARCHIVE ) - endif(CLR_CMAKE_TARGET_OSX) + endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) set_exports_linker_option(${EXPORTS_FILE}) @@ -167,7 +167,7 @@ if(FEATURE_MERGE_JIT_AND_ENGINE) set(CLRJIT_STATIC clrjit_static) endif(FEATURE_MERGE_JIT_AND_ENGINE) -if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST) +if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS) include(CMakeFindFrameworks) find_library(FOUNDATION Foundation REQUIRED) endif() diff --git a/src/coreclr/gc/CMakeLists.txt b/src/coreclr/gc/CMakeLists.txt index e2ef118ca0637..d4a96e27b51b6 100644 --- a/src/coreclr/gc/CMakeLists.txt +++ b/src/coreclr/gc/CMakeLists.txt @@ -112,12 +112,12 @@ install_clr(TARGETS clrgc DESTINATIONS . COMPONENT runtime) add_definitions(-DBUILD_AS_STANDALONE) add_definitions(-DFX_VER_INTERNALNAME_STR=clrgc.dll) add_definitions(-DVERIFY_HEAP) -if(CLR_CMAKE_HOST_OSX) - # The implementation of GCToOSInterface on MacOS makes use of non-POSIX +if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) + # The implementation of GCToOSInterface on Apple platforms makes use of non-POSIX # pthreads APIs, which by default are not included in the pthreads header # unless we define this macro. add_definitions(-D_DARWIN_C_SOURCE) -endif(CLR_CMAKE_HOST_OSX) +endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/env) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index d1bd2a9510a9f..895221930898d 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -24072,9 +24072,9 @@ inline void Prefetch(void* addr) __prefetch((const char*)addr); #endif //defined(TARGET_AMD64) || defined(TARGET_X86) -#elif defined(TARGET_UNIX) || defined(TARGET_OSX) +#elif defined(TARGET_UNIX) __builtin_prefetch(addr); -#else //!(TARGET_WINDOWS || TARGET_UNIX || TARGET_OSX) +#else //!(TARGET_WINDOWS || TARGET_UNIX) UNREFERENCED_PARAMETER(addr); #endif //TARGET_WINDOWS } diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index b25194a6173bc..7fdabf92fb037 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -235,7 +235,7 @@ bool GCToOSInterface::Initialize() { s_flushUsingMemBarrier = TRUE; } -#ifndef TARGET_OSX +#if !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) else { assert(g_helperPage == 0); @@ -267,7 +267,7 @@ bool GCToOSInterface::Initialize() return false; } } -#endif // !TARGET_OSX +#endif // !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) InitializeCGroup(); @@ -407,7 +407,7 @@ void GCToOSInterface::FlushProcessWriteBuffers() status = pthread_mutex_unlock(&g_flushProcessWriteBuffersMutex); assert(status == 0 && "Failed to unlock the flushProcessWriteBuffersMutex lock"); } -#ifdef TARGET_OSX +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) else { mach_msg_type_number_t cThreads; @@ -421,9 +421,28 @@ void GCToOSInterface::FlushProcessWriteBuffers() // Iterate through each of the threads in the list. for (mach_msg_type_number_t i = 0; i < cThreads; i++) { - // Request the threads pointer values to force the thread to emit a memory barrier - size_t registers = 128; - machret = thread_get_register_pointer_values(pThreads[i], &sp, ®isters, registerValues); + if (__builtin_available (macOS 10.14, iOS 12, tvOS 9, *)) + { + // Request the threads pointer values to force the thread to emit a memory barrier + size_t registers = 128; + machret = thread_get_register_pointer_values(pThreads[i], &sp, ®isters, registerValues); + } + else + { + // fallback implementation for older OS versions +#if defined(HOST_AMD64) + x86_thread_state64_t threadState; + mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; + machret = thread_get_state(pThreads[i], x86_THREAD_STATE64, (thread_state_t)&threadState, &count); +#elif defined(HOST_ARM64) + arm_thread_state64_t threadState; + mach_msg_type_number_t count = ARM_THREAD_STATE64_COUNT; + machret = thread_get_state(pThreads[i], ARM_THREAD_STATE64, (thread_state_t)&threadState, &count); +#else + #error Unexpected architecture +#endif + } + if (machret == KERN_INSUFFICIENT_BUFFER_SIZE) { CHECK_MACH("thread_get_register_pointer_values()", machret); @@ -436,7 +455,7 @@ void GCToOSInterface::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 // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) } // Break into a debugger. Uses a compiler intrinsic if one is available, @@ -824,7 +843,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_OSX) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) if (cacheSize == 0) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info @@ -874,7 +893,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_OSX) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) if (cacheLevel != 3) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info diff --git a/src/coreclr/inc/crosscomp.h b/src/coreclr/inc/crosscomp.h index 7353e8cc6b770..97d92e0091898 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 +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #define MAKE_TARGET_DLLNAME_W(name) W("lib") name W(".dylib") #define MAKE_TARGET_DLLNAME_A(name) "lib" name ".dylib" #else @@ -547,6 +547,18 @@ typedef struct _T_KNONVOLATILE_CONTEXT_POINTERS { #define DAC_CS_NATIVE_DATA_SIZE 120 #elif defined(TARGET_OSX) && defined(TARGET_ARM64) #define DAC_CS_NATIVE_DATA_SIZE 120 +#elif defined(TARGET_MACCATALYST) && defined(TARGET_AMD64) +#define DAC_CS_NATIVE_DATA_SIZE 120 +#elif defined(TARGET_MACCATALYST) && defined(TARGET_ARM64) +#define DAC_CS_NATIVE_DATA_SIZE 120 +#elif defined(TARGET_IOS) && defined(TARGET_AMD64) +#define DAC_CS_NATIVE_DATA_SIZE 120 +#elif defined(TARGET_IOS) && defined(TARGET_ARM64) +#define DAC_CS_NATIVE_DATA_SIZE 120 +#elif defined(TARGET_TVOS) && defined(TARGET_AMD64) +#define DAC_CS_NATIVE_DATA_SIZE 120 +#elif defined(TARGET_TVOS) && defined(TARGET_ARM64) +#define DAC_CS_NATIVE_DATA_SIZE 120 #elif defined(TARGET_FREEBSD) && defined(TARGET_X86) #define DAC_CS_NATIVE_DATA_SIZE 12 #elif defined(TARGET_FREEBSD) && defined(TARGET_AMD64) diff --git a/src/coreclr/inc/executableallocator.h b/src/coreclr/inc/executableallocator.h index c229f5546aa7f..e604e5ddcf5af 100644 --- a/src/coreclr/inc/executableallocator.h +++ b/src/coreclr/inc/executableallocator.h @@ -254,7 +254,7 @@ class ExecutableWriterHolder void Unmap() { -#if defined(HOST_OSX) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) +#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) if (m_addressRX != NULL) { PAL_JitWriteProtect(false); @@ -290,7 +290,7 @@ class ExecutableWriterHolder ExecutableWriterHolder(T* addressRX, size_t size) { m_addressRX = addressRX; -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) m_addressRW = addressRX; PAL_JitWriteProtect(true); #else diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index 5caefcd10b26f..f6a9b892e03ff 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -195,6 +195,7 @@ The .NET Foundation licenses this file to you under the MIT license. + diff --git a/src/coreclr/nativeaot/CMakeLists.txt b/src/coreclr/nativeaot/CMakeLists.txt index a593a2f586b76..b0e4a57845c6f 100644 --- a/src/coreclr/nativeaot/CMakeLists.txt +++ b/src/coreclr/nativeaot/CMakeLists.txt @@ -32,10 +32,10 @@ if(CLR_CMAKE_HOST_UNIX) add_compile_options(-fno-exceptions) # Native AOT runtime doesn't use C++ exception handling add_compile_options(-nostdlib) - if(CLR_CMAKE_TARGET_OSX) + if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) add_definitions(-D_XOPEN_SOURCE) add_definitions(-DFEATURE_OBJCMARSHAL) - endif(CLR_CMAKE_TARGET_OSX) + endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386) # Allow 16 byte compare-exchange diff --git a/src/coreclr/nativeaot/Directory.Build.props b/src/coreclr/nativeaot/Directory.Build.props index 275f0398185b3..5b2d8a1454b58 100644 --- a/src/coreclr/nativeaot/Directory.Build.props +++ b/src/coreclr/nativeaot/Directory.Build.props @@ -60,7 +60,7 @@ false - true + true FEATURE_OBJCMARSHAL;$(DefineConstants) diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ThunkPool.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ThunkPool.cs index 73bc32ffe3654..7204c3fa9d011 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ThunkPool.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ThunkPool.cs @@ -40,7 +40,7 @@ namespace System.Runtime { internal static class Constants { -#if TARGET_ARM64 && TARGET_OSX +#if TARGET_ARM64 && (TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS) public const uint PageSize = 0x4000; // 16k public const nuint PageSizeMask = 0x3FFF; #else diff --git a/src/coreclr/nativeaot/Runtime/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/CMakeLists.txt index 69441fd7f5881..0e078b5640a10 100644 --- a/src/coreclr/nativeaot/Runtime/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/CMakeLists.txt @@ -169,11 +169,11 @@ else() set(ASM_SUFFIX S) endif() -if (CLR_CMAKE_TARGET_OSX) +if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) list(APPEND COMMON_RUNTIME_SOURCES interoplibinterface_objc.cpp ) -endif (CLR_CMAKE_TARGET_OSX) +endif (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) if (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32) list(APPEND COMMON_RUNTIME_SOURCES @@ -230,7 +230,9 @@ if(WIN32) add_definitions(-DFEATURE_SUSPEND_REDIRECTION) add_definitions(-DFEATURE_SPECIAL_USER_MODE_APC) else() - add_definitions(-DFEATURE_READONLY_GS_COOKIE) + if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + add_definitions(-DFEATURE_READONLY_GS_COOKIE) + endif() add_definitions(-DNO_UI_ASSERT) include(unix/configure.cmake) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/coreclr/nativeaot/Runtime/CommonMacros.h b/src/coreclr/nativeaot/Runtime/CommonMacros.h index a4a82be3753e5..8542b8db97661 100644 --- a/src/coreclr/nativeaot/Runtime/CommonMacros.h +++ b/src/coreclr/nativeaot/Runtime/CommonMacros.h @@ -155,7 +155,7 @@ inline bool IS_ALIGNED(T* val, uintptr_t alignment); #define DATA_ALIGNMENT 8 #ifndef OS_PAGE_SIZE -#ifdef HOST_OSX +#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) #define OS_PAGE_SIZE 0x4000 #else #define OS_PAGE_SIZE 0x1000 diff --git a/src/coreclr/nativeaot/Runtime/ThunksMapping.cpp b/src/coreclr/nativeaot/Runtime/ThunksMapping.cpp index d105f79506aca..62c3a157d87bd 100644 --- a/src/coreclr/nativeaot/Runtime/ThunksMapping.cpp +++ b/src/coreclr/nativeaot/Runtime/ThunksMapping.cpp @@ -121,8 +121,14 @@ EXTERN_C NATIVEAOT_API void* __cdecl RhAllocateThunksMapping() return NULL; } -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if defined(HOST_ARM64) +#if defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) + RhFailFast(); // TODO: add pthread_jit_write_protect_np workaround +#elif defined(HOST_OSX) pthread_jit_write_protect_np(0); +#else + #error "Unknown OS" +#endif #endif #endif @@ -226,8 +232,14 @@ EXTERN_C NATIVEAOT_API void* __cdecl RhAllocateThunksMapping() } } -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if defined(HOST_ARM64) +#if defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) + RhFailFast(); // TODO: add pthread_jit_write_protect_np workaround +#elif defined(HOST_OSX) pthread_jit_write_protect_np(1); +#else + #error "Unknown OS" +#endif #else if (!PalVirtualProtect(pThunksSection, THUNKS_MAP_SIZE, PAGE_EXECUTE_READ)) { diff --git a/src/coreclr/nativeaot/Runtime/unix/HardwareExceptions.cpp b/src/coreclr/nativeaot/Runtime/unix/HardwareExceptions.cpp index d9becd8a1ecfe..57725354321c9 100644 --- a/src/coreclr/nativeaot/Runtime/unix/HardwareExceptions.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/HardwareExceptions.cpp @@ -11,7 +11,7 @@ #include "HardwareExceptions.h" #include "UnixSignals.h" -#if defined(HOST_OSX) +#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) #include #include #include @@ -594,7 +594,8 @@ bool InitializeHardwareExceptionHandling() return false; } -#if defined(HOST_OSX) +#ifndef HOST_TVOS // task_set_exception_ports is not supported on tvOS +#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) // LLDB installs task-wide Mach exception handlers. XNU dispatches Mach // exceptions first to any registered "activation" handler and then to // any registered task handler before dispatching the exception to a @@ -613,6 +614,7 @@ bool InitializeHardwareExceptionHandling() EXCEPTION_STATE_IDENTITY, MACHINE_THREAD_STATE); ASSERT(kr == KERN_SUCCESS); +#endif #endif return true; diff --git a/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp b/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp index 4750908eb8d85..3e172454679d0 100644 --- a/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp @@ -728,7 +728,7 @@ REDHAWK_PALEXPORT _Ret_maybenull_ _Post_writable_byte_size_(size) void* REDHAWK_ size_t alignedSize = size + (Alignment - OS_PAGE_SIZE); int flags = MAP_ANON | MAP_PRIVATE; -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) if (unixProtect & PROT_EXEC) { flags |= MAP_JIT; @@ -790,6 +790,10 @@ REDHAWK_PALEXPORT UInt32_BOOL REDHAWK_PALAPI PalVirtualProtect(_In_ void* pAddre return mprotect(pPageStart, memSize, unixProtect) == 0; } +#if (defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) +extern "C" void sys_icache_invalidate(const void* start, size_t len); +#endif + REDHAWK_PALEXPORT void PalFlushInstructionCache(_In_ void* pAddress, size_t size) { #if defined(__linux__) && defined(HOST_ARM) @@ -812,6 +816,8 @@ REDHAWK_PALEXPORT void PalFlushInstructionCache(_In_ void* pAddress, size_t size __builtin___clear_cache((char *)begin, (char *)endOrNextPageBegin); begin = endOrNextPageBegin; } +#elif (defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) + sys_icache_invalidate (pAddress, size); #else __builtin___clear_cache((char *)pAddress, (char *)pAddress + size); #endif @@ -956,8 +962,8 @@ static void ActivationHandler(int code, siginfo_t* siginfo, void* context) { // Only accept activations from the current process if (g_pHijackCallback != NULL && (siginfo->si_pid == getpid() -#ifdef HOST_OSX - // On OSX si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple +#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) + // On Apple platforms si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple // signals are in flight in the same process at the same time, it may be overwritten / zeroed. || siginfo->si_pid == 0 #endif diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.Unix.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.Unix.cs index 91203aff615c5..6ef45a2475095 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.Unix.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.Unix.cs @@ -39,7 +39,7 @@ internal struct LoadLibErrorTracker public void Throw(string libraryName) { -#if TARGET_OSX +#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS throw new DllNotFoundException(SR.Format(SR.DllNotFound_Mac, libraryName, _errorMessage)); #else throw new DllNotFoundException(SR.Format(SR.DllNotFound_Linux, libraryName, _errorMessage)); diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 88dcd4e8d77f7..8bda376262580 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -2940,14 +2940,14 @@ VirtualFree( IN DWORD dwFreeType); -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) PALIMPORT VOID PALAPI PAL_JitWriteProtect(bool writeEnable); -#endif // defined(HOST_OSX) && defined(HOST_ARM64) +#endif // (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) PALIMPORT diff --git a/src/coreclr/pal/inc/rt/palrt.h b/src/coreclr/pal/inc/rt/palrt.h index ee73da2dc00fc..fffc116766f9c 100644 --- a/src/coreclr/pal/inc/rt/palrt.h +++ b/src/coreclr/pal/inc/rt/palrt.h @@ -1079,8 +1079,6 @@ typedef struct _DISPATCHER_CONTEXT { #endif -// #endif // !defined(TARGET_OSX) - typedef DISPATCHER_CONTEXT *PDISPATCHER_CONTEXT; #define ExceptionContinueSearch EXCEPTION_CONTINUE_SEARCH diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 74fc5d3bc5cd5..9df28851ce306 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -1,7 +1,7 @@ -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD) - # On OSX and *BSD, we use the libunwind that's part of the OS +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_FREEBSD) + # On Apple platforms and *BSD, we use the libunwind that's part of the OS set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) -endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD) +endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_FREEBSD) if(NOT DEFINED ENV{ROOTFS_DIR}) include_directories(SYSTEM /usr/local/include) @@ -16,7 +16,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_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) find_unwind_libs(UNWIND_LIBS) else() add_subdirectory(${CLR_SRC_NATIVE_DIR}/external/libunwind_extras ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind) @@ -66,8 +66,17 @@ if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) add_definitions(-DFEATURE_USE_SYSTEM_LIBUNWIND) endif(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) -if(CLR_CMAKE_TARGET_OSX) - add_definitions(-DTARGET_OSX) +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if(CLR_CMAKE_TARGET_OSX) + add_definitions(-DTARGET_OSX) + elseif(CLR_CMAKE_TARGET_MACCATALYST) + add_definitions(-DTARGET_MACCATALYST) + elseif(CLR_CMAKE_TARGET_IOS) + add_definitions(-DTARGET_IOS) + elseif(CLR_CMAKE_TARGET_TVOS) + add_definitions(-DTARGET_TVOS) + endif() + if(CLR_CMAKE_TARGET_ARCH_AMD64) add_definitions(-DXSTATE_SUPPORTED) endif() @@ -77,7 +86,7 @@ if(CLR_CMAKE_TARGET_OSX) exception/machexception.cpp exception/machmessage.cpp ) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) if (FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) add_definitions(-DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) @@ -109,12 +118,12 @@ set(ARCH_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/processor.cpp ) -if(NOT CLR_CMAKE_TARGET_OSX) +if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) 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_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) if(CLR_CMAKE_HOST_ARCH_ARM) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -226,7 +235,7 @@ add_library(coreclrpal ) # Build separate pal library for DAC (addition to regular pal library) -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(LIBUNWIND_DAC_OBJECTS $) add_library(coreclrpal_dac STATIC @@ -241,7 +250,7 @@ else() exception/remote-unwind.cpp ) endif(NOT FEATURE_CROSSBITNESS) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) if(NOT FEATURE_CROSSBITNESS) target_include_directories(coreclrpal_dac PUBLIC @@ -267,7 +276,7 @@ if(CLR_CMAKE_TARGET_LINUX) target_sources(tracepointprovider INTERFACE $) endif(CLR_CMAKE_TARGET_LINUX) -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) find_library(COREFOUNDATION CoreFoundation) find_library(CORESERVICES CoreServices) find_library(SECURITY Security) @@ -278,7 +287,7 @@ if(CLR_CMAKE_TARGET_OSX) ${SECURITY} ${SYSTEM} ) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) if(CLR_CMAKE_TARGET_FREEBSD) target_link_libraries(coreclrpal diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake index 114e88409c473..4c44d85a8d441 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_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) 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") @@ -1307,8 +1307,10 @@ if(NOT CLR_CMAKE_HOST_ARCH_ARM AND NOT CLR_CMAKE_HOST_ARCH_ARM64) set(CMAKE_REQUIRED_LIBRARIES) endif() -if(CLR_CMAKE_TARGET_OSX) - set(HAVE__NSGETENVIRON 1) +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + set(HAVE__NSGETENVIRON 1) + endif() set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 1) set(PAL_PTRACE "ptrace((cmd), (pid), (caddr_t)(addr), (data))") set(PAL_PT_ATTACH PT_ATTACH) @@ -1366,7 +1368,7 @@ else() # Anything else is Linux set(PAL_PT_WRITE_D PTRACE_POKEDATA) set(HAS_FTRUNCATE_LENGTH_ISSUE 0) set(HAVE_SCHED_OTHER_ASSIGNABLE 1) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) check_struct_has_member( "struct statfs" diff --git a/src/coreclr/pal/src/exception/seh-unwind.cpp b/src/coreclr/pal/src/exception/seh-unwind.cpp index b3a4ca23726bb..faee10b4648c3 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -54,8 +54,8 @@ Module Name: #endif // HOST_UNIX -#if defined(TARGET_OSX) && defined(HOST_ARM64) -// MacOS uses ARM64 instead of AARCH64 to describe these registers +#if (defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) && defined(HOST_ARM64) +// Apple platforms use ARM64 instead of AARCH64 to describe these registers // Create aliases to reuse more code enum { @@ -96,7 +96,7 @@ enum UNW_AARCH64_V30 = UNW_ARM64_D30, UNW_AARCH64_V31 = UNW_ARM64_D31 }; -#endif // defined(TARGET_OSX) && defined(HOST_ARM64) +#endif // (defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) && defined(HOST_ARM64) //---------------------------------------------------------------------- @@ -273,7 +273,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_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) unwContext->uc_mcontext.pc = winContext->Pc; unwContext->uc_mcontext.sp = winContext->Sp; unwContext->uc_mcontext.regs[29] = winContext->Fp; @@ -315,7 +315,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_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) // 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. @@ -439,12 +439,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_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) && 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_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) && 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/exception/signal.cpp b/src/coreclr/pal/src/exception/signal.cpp index 7d299212db641..ddd667fd894d8 100644 --- a/src/coreclr/pal/src/exception/signal.cpp +++ b/src/coreclr/pal/src/exception/signal.cpp @@ -799,8 +799,8 @@ static void inject_activation_handler(int code, siginfo_t *siginfo, void *contex { // Only accept activations from the current process if (g_activationFunction != NULL && (siginfo->si_pid == getpid() -#ifdef HOST_OSX - // On OSX si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple +#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) + // On Apple platforms si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple // signals are in flight in the same process at the same time, it may be overwritten / zeroed. || siginfo->si_pid == 0 #endif diff --git a/src/coreclr/pal/src/include/pal/context.h b/src/coreclr/pal/src/include/pal/context.h index c702ae272a76b..9fc094f50acaf 100644 --- a/src/coreclr/pal/src/include/pal/context.h +++ b/src/coreclr/pal/src/include/pal/context.h @@ -498,7 +498,7 @@ const struct fpregs* GetConstNativeSigSimdContext(const native_context_t *mc) return GetNativeSigSimdContext(const_cast(mc)); } -#elif !defined(TARGET_OSX) // TARGET_FREEBSD +#elif !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) // TARGET_FREEBSD #define MCREG_X0(mc) ((mc).regs[0]) #define MCREG_X1(mc) ((mc).regs[1]) @@ -573,7 +573,7 @@ const fpsimd_context* GetConstNativeSigSimdContext(const native_context_t *mc) return GetNativeSigSimdContext(const_cast(mc)); } -#else // TARGET_OSX +#else // !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) #define MCREG_X0(mc) ((mc)->__ss.__x[0]) #define MCREG_X1(mc) ((mc)->__ss.__x[1]) @@ -623,7 +623,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex return GetNativeSigSimdContext(const_cast(mc)); } -#endif // TARGET_OSX +#endif // !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) #elif defined(HOST_LOONGARCH64) @@ -663,7 +663,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex #else // HOST_ARM64 -#ifdef TARGET_OSX +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #define MCREG_Rbp(mc) ((mc)->__ss.__rbp) #define MCREG_Rip(mc) ((mc)->__ss.__rip) @@ -711,7 +711,7 @@ inline void *FPREG_Xstate_Ymmh(const ucontext_t *uc) return reinterpret_cast(&((_STRUCT_X86_AVX_STATE64&)FPSTATE(uc)).__fpu_ymmh0); } -#else //TARGET_OSX +#else // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) // For FreeBSD, as found in x86/ucontext.h #define MCREG_Rbp(mc) ((mc).mc_rbp) @@ -748,7 +748,7 @@ inline void *FPREG_Xstate_Ymmh(const ucontext_t *uc) #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 // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #endif // HOST_ARM64 #else // HOST_64BIT diff --git a/src/coreclr/pal/src/include/pal/mutex.hpp b/src/coreclr/pal/src/include/pal/mutex.hpp index 464f0f72afb45..5ebb14adb6f73 100644 --- a/src/coreclr/pal/src/include/pal/mutex.hpp +++ b/src/coreclr/pal/src/include/pal/mutex.hpp @@ -122,11 +122,11 @@ Miscellaneous // - On FreeBSD, pthread process-shared robust mutexes cannot be placed in shared memory mapped independently by the processes // involved. See https://github.com/dotnet/runtime/issues/10519. -// - On OSX, pthread robust mutexes were/are not available at the time of this writing. In case they are made available in the +// - On Apple platforms, pthread robust mutexes were/are not available at the time of this writing. In case they are made available in the // future, their use is disabled for compatibility. #if HAVE_FULLY_FEATURED_PTHREAD_MUTEXES && \ HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES && \ - !(defined(__FreeBSD__) || defined(TARGET_OSX)) + !(defined(__FreeBSD__) || defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) #define NAMED_MUTEX_USE_PTHREAD_MUTEX 1 #else diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index aa9b30b5b960b..992e680c7f782 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -1287,9 +1287,12 @@ VirtualProtect( return bRetVal; } -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) PALAPI VOID PAL_JitWriteProtect(bool writeEnable) { +#if defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) + RhFailFast(); // TODO: add pthread_jit_write_protect_np workaround +#elif defined(HOST_OSX) thread_local int enabledCount = 0; if (writeEnable) { @@ -1306,8 +1309,11 @@ PALAPI VOID PAL_JitWriteProtect(bool writeEnable) } _ASSERTE(enabledCount >= 0); } +#else + #error "Unknown OS" +#endif } -#endif // HOST_OSX && HOST_ARM64 +#endif // (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) #if HAVE_VM_ALLOCATE //--------------------------------------------------------------------------------------- diff --git a/src/coreclr/pal/src/misc/sysinfo.cpp b/src/coreclr/pal/src/misc/sysinfo.cpp index 829100f0c53bb..3d4d84015c163 100644 --- a/src/coreclr/pal/src/misc/sysinfo.cpp +++ b/src/coreclr/pal/src/misc/sysinfo.cpp @@ -66,12 +66,12 @@ Revision History: #include #endif // HAVE_MACHINE_VMPARAM_H -#if defined(TARGET_OSX) +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #include #include #include -#endif // defined(TARGET_OSX) +#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) // On some platforms sys/user.h ends up defining _DEBUG; if so // remove the definition before including the header and put @@ -583,7 +583,7 @@ PAL_GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_OSX) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) if (cacheSize == 0) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info @@ -633,7 +633,7 @@ PAL_GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_OSX) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) if (cacheLevel != 3) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info diff --git a/src/coreclr/pal/src/thread/context.cpp b/src/coreclr/pal/src/thread/context.cpp index a17c6c077da3b..3a25fafd7e092 100644 --- a/src/coreclr/pal/src/thread/context.cpp +++ b/src/coreclr/pal/src/thread/context.cpp @@ -618,7 +618,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 +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) _STRUCT_ARM_NEON_STATE64* fp = GetNativeSigSimdContext(native); fp->__fpsr = lpContext->Fpsr; fp->__fpcr = lpContext->Fpcr; @@ -637,7 +637,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->fp_q[i] = lpContext->V[i]; } } -#else // TARGET_OSX +#else // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) fpsimd_context* fp = GetNativeSigSimdContext(native); if (fp) { @@ -648,7 +648,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->vregs[i] = lpContext->V[i]; } } -#endif // TARGET_OSX +#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #elif defined(HOST_ARM) VfpSigFrame* fp = GetNativeSigSimdContext(native); if (fp) @@ -780,7 +780,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 +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) const _STRUCT_ARM_NEON_STATE64* fp = GetConstNativeSigSimdContext(native); lpContext->Fpsr = fp->__fpsr; lpContext->Fpcr = fp->__fpcr; @@ -799,7 +799,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->fp_q[i]; } } -#else // TARGET_OSX +#else // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) const fpsimd_context* fp = GetConstNativeSigSimdContext(native); if (fp) { @@ -810,7 +810,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->vregs[i]; } } -#endif // TARGET_OSX +#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #elif defined(HOST_ARM) const VfpSigFrame* fp = GetConstNativeSigSimdContext(native); if (fp) @@ -1655,6 +1655,10 @@ CONTEXT_SetThreadContext( #endif // !HAVE_MACH_EXCEPTIONS +#if (defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) +extern "C" void sys_icache_invalidate(const void* start, size_t len); +#endif + /*++ Function: DBG_FlushInstructionCache: processor-specific portion of @@ -1687,6 +1691,8 @@ DBG_FlushInstructionCache( __builtin___clear_cache((char *)begin, (char *)endOrNextPageBegin); begin = endOrNextPageBegin; } +#elif (defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) + sys_icache_invalidate (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 3f4402214959f..f338f4b139a7e 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -2473,7 +2473,7 @@ InitializeFlushProcessWriteBuffers() } } -#ifdef TARGET_OSX +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) return TRUE; #else s_helperPage = static_cast(mmap(0, GetVirtualPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); @@ -2503,7 +2503,7 @@ InitializeFlushProcessWriteBuffers() } return status == 0; -#endif // TARGET_OSX +#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) } #define FATAL_ASSERT(e, msg) \ @@ -2553,7 +2553,7 @@ FlushProcessWriteBuffers() status = pthread_mutex_unlock(&flushProcessWriteBuffersMutex); FATAL_ASSERT(status == 0, "Failed to unlock the flushProcessWriteBuffersMutex lock"); } -#ifdef TARGET_OSX +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) else { mach_msg_type_number_t cThreads; @@ -2567,9 +2567,28 @@ FlushProcessWriteBuffers() // Iterate through each of the threads in the list. for (mach_msg_type_number_t i = 0; i < cThreads; i++) { - // Request the threads pointer values to force the thread to emit a memory barrier - size_t registers = 128; - machret = thread_get_register_pointer_values(pThreads[i], &sp, ®isters, registerValues); + if (__builtin_available (macOS 10.14, iOS 12, tvOS 9, *)) + { + // Request the threads pointer values to force the thread to emit a memory barrier + size_t registers = 128; + machret = thread_get_register_pointer_values(pThreads[i], &sp, ®isters, registerValues); + } + else + { + // fallback implementation for older OS versions +#if defined(HOST_AMD64) + x86_thread_state64_t threadState; + mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; + machret = thread_get_state(pThreads[i], x86_THREAD_STATE64, (thread_state_t)&threadState, &count); +#elif defined(HOST_ARM64) + arm_thread_state64_t threadState; + mach_msg_type_number_t count = ARM_THREAD_STATE64_COUNT; + machret = thread_get_state(pThreads[i], ARM_THREAD_STATE64, (thread_state_t)&threadState, &count); +#else + #error Unexpected architecture +#endif + } + if (machret == KERN_INSUFFICIENT_BUFFER_SIZE) { CHECK_MACH("thread_get_register_pointer_values()", machret); @@ -2582,7 +2601,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 // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) } /*++ diff --git a/src/coreclr/pal/src/thread/thread.cpp b/src/coreclr/pal/src/thread/thread.cpp index 0daa011e6fc63..82848c11f7734 100644 --- a/src/coreclr/pal/src/thread/thread.cpp +++ b/src/coreclr/pal/src/thread/thread.cpp @@ -2596,8 +2596,8 @@ void * CPalThread::GetStackBase() { void* stackBase; -#ifdef TARGET_OSX - // This is a Mac specific method +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) + // This is an Apple specific method stackBase = pthread_get_stackaddr_np(pthread_self()); #else pthread_attr_t attr; @@ -2636,8 +2636,8 @@ void * CPalThread::GetStackLimit() { void* stackLimit; -#ifdef TARGET_OSX - // This is a Mac specific method +#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) + // This is an Apple specific method stackLimit = ((BYTE *)pthread_get_stackaddr_np(pthread_self()) - pthread_get_stacksize_np(pthread_self())); #else diff --git a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt index f9b5f0175caa3..74eb62d8d260e 100644 --- a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt @@ -5,12 +5,12 @@ endif(CLR_CMAKE_HOST_UNIX) # Set the RPATH of paltest_pal_sxs_test1 so that it can find dependencies without needing to set LD_LIBRARY # For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling. if(CORECLR_SET_RPATH) - if(CLR_CMAKE_HOST_OSX) + if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) set(CMAKE_INSTALL_NAME_DIR "@rpath") set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "@loader_path") - endif(CLR_CMAKE_HOST_OSX) + endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) if(CLR_CMAKE_HOST_LINUX) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN") diff --git a/src/coreclr/tools/Common/CommandLineHelpers.cs b/src/coreclr/tools/Common/CommandLineHelpers.cs index 39161e2c753b0..8ee9a79260d1e 100644 --- a/src/coreclr/tools/Common/CommandLineHelpers.cs +++ b/src/coreclr/tools/Common/CommandLineHelpers.cs @@ -77,8 +77,11 @@ public static TargetOS GetTargetOS(string token) "linux" => TargetOS.Linux, "freebsd" => TargetOS.FreeBSD, "osx" => TargetOS.OSX, + "maccatalyst" => TargetOS.MacCatalyst, "ios" => TargetOS.iOS, "iossimulator" => TargetOS.iOSSimulator, + "tvos" => TargetOS.tvOS, + "tvossimulator" => TargetOS.tvOSSimulator, _ => throw new CommandLineException($"Target OS '{token}' is not supported") }; } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs b/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs index 39a3c20f45a20..38eb48be32215 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs @@ -15,12 +15,15 @@ public enum TargetOS Windows, Linux, OSX, + MacCatalyst, + iOS, + iOSSimulator, + tvOS, + tvOSSimulator, FreeBSD, NetBSD, SunOS, - WebAssembly, - iOS, - iOSSimulator + WebAssembly } public enum TargetAbi @@ -306,15 +309,18 @@ public bool IsWindows /// /// Returns True if compiling for OSX family of operating systems. - /// Currently including OSX, iOS and iOSSimulator + /// Currently including OSX, MacCatalyst, iOS, iOSSimulator, tvOS and tvOSSimulator /// public bool IsOSXLike { get { return OperatingSystem == TargetOS.OSX || + OperatingSystem == TargetOS.MacCatalyst || OperatingSystem == TargetOS.iOS || - OperatingSystem == TargetOS.iOSSimulator; + OperatingSystem == TargetOS.iOSSimulator || + OperatingSystem == TargetOS.tvOS || + OperatingSystem == TargetOS.tvOSSimulator; } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs index 120e9a81692ca..b42db28d6f244 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs @@ -1250,6 +1250,11 @@ private static string GetLLVMTripleFromTarget(TargetDetails target) sys = "darwin16"; abi = "macho"; break; + case TargetOS.MacCatalyst: + vendor = "apple"; + sys = target.Architecture == TargetArchitecture.X64 ? "ios13.5" :"ios14.2"; + abi = "macabi"; + break; case TargetOS.iOS: vendor = "apple"; sys = "ios11.0"; @@ -1260,6 +1265,16 @@ private static string GetLLVMTripleFromTarget(TargetDetails target) sys = "ios11.0"; abi = "simulator"; break; + case TargetOS.tvOS: + vendor = "apple"; + sys = "tvos11.0"; + abi = "macho"; + break; + case TargetOS.tvOSSimulator: + vendor = "apple"; + sys = "tvos11.0"; + abi = "simulator"; + break; case TargetOS.WebAssembly: vendor = "unknown"; sys = "unknown"; diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs index 235b7443e5548..b852cbecf10f2 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs +++ b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs @@ -306,7 +306,7 @@ public static IEnumerable> GetExtendedHelp(HelpContext _) "considered to be input files. If no input files begin with '--' then this option is not necessary.\n"); string[] ValidArchitectures = new string[] { "arm", "arm64", "x86", "x64" }; - string[] ValidOS = new string[] { "windows", "linux", "freebsd", "osx", "ios", "iossimulator" }; + string[] ValidOS = new string[] { "windows", "linux", "freebsd", "osx", "maccatalyst", "ios", "iossimulator", "tvos", "tvossimulator" }; Console.WriteLine("Valid switches for {0} are: '{1}'. The default value is '{2}'\n", "--targetos", string.Join("', '", ValidOS), Helpers.GetTargetOS(null).ToString().ToLowerInvariant()); diff --git a/src/coreclr/utilcode/executableallocator.cpp b/src/coreclr/utilcode/executableallocator.cpp index dbaf2f52ebac2..13bc97b1ab7c0 100644 --- a/src/coreclr/utilcode/executableallocator.cpp +++ b/src/coreclr/utilcode/executableallocator.cpp @@ -105,7 +105,7 @@ bool ExecutableAllocator::IsDoubleMappingEnabled() { LIMITED_METHOD_CONTRACT; -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) return false; #else return g_isWXorXEnabled; @@ -116,7 +116,7 @@ bool ExecutableAllocator::IsWXORXEnabled() { LIMITED_METHOD_CONTRACT; -#if defined(HOST_OSX) && defined(HOST_ARM64) +#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) return true; #else return g_isWXorXEnabled; diff --git a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs index 42df7e7f97cee..b4c2955580464 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs @@ -10,5 +10,8 @@ internal static partial class Globalization { [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICUData", StringMarshalling = StringMarshalling.Utf8)] internal static partial int LoadICUData(string path); + + [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUDataPathFallback", StringMarshalling = StringMarshalling.Utf8)] + internal static partial string GetICUDataPathFallback(); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs index 08c5feb8ad189..68e832546f6af 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs @@ -7,8 +7,10 @@ internal static partial class GlobalizationMode { private static int LoadICU() { - object? datPath = AppContext.GetData("ICU_DAT_FILE_PATH"); - return (datPath != null) ? Interop.Globalization.LoadICUData(datPath!.ToString()!) : Interop.Globalization.LoadICU(); + // NativeAOT doesn't set ICU_DAT_FILE_PATH so we fallback to icudt.dat in the app bundle root in that case + string datPath = AppContext.GetData("ICU_DAT_FILE_PATH")?.ToString() ?? Interop.Globalization.GetICUDataPathFallback(); + + return Interop.Globalization.LoadICUData(datPath); } } } diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index 9f8a0058e0335..05f1929ff5f09 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -12,7 +12,7 @@ - + 10.0 10.0 2.0 diff --git a/src/native/corehost/apphost/standalone/CMakeLists.txt b/src/native/corehost/apphost/standalone/CMakeLists.txt index ecd5ca0ca3596..af19f493fd516 100644 --- a/src/native/corehost/apphost/standalone/CMakeLists.txt +++ b/src/native/corehost/apphost/standalone/CMakeLists.txt @@ -9,7 +9,7 @@ set(DOTNET_PROJECT_NAME "apphost") # dependencies is not possible for some reason. # This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way, # doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive. -if (NOT CLR_CMAKE_TARGET_OSX) +if (NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") endif() diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 89c51af5645dd..d7a815c146f80 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -9,7 +9,7 @@ set(DOTNET_PROJECT_NAME "singlefilehost") # dependencies is not possible for some reason. # This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way, # doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive. -if (NOT CLR_CMAKE_TARGET_OSX) +if (NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") endif() @@ -151,23 +151,27 @@ else() include(${CLR_SRC_NATIVE_DIR}/libs/System.IO.Compression.Native/extra_libs.cmake) append_extra_compression_libs(NATIVE_LIBS) - # Additional requirements for System.Net.Security.Native - include(${CLR_SRC_NATIVE_DIR}/libs/System.Net.Security.Native/extra_libs.cmake) - append_extra_security_libs(NATIVE_LIBS) + if (NOT CLR_CMAKE_TARGET_TVOS) # no gssapi on tvOS, see https://developer.apple.com/documentation/gss + # Additional requirements for System.Net.Security.Native + include(${CLR_SRC_NATIVE_DIR}/libs/System.Net.Security.Native/extra_libs.cmake) + append_extra_security_libs(NATIVE_LIBS) + endif() # Additional requirements for System.Native include(${CLR_SRC_NATIVE_DIR}/libs/System.Native/extra_libs.cmake) append_extra_system_libs(NATIVE_LIBS) - # Additional requirements for System.Security.Cryptography.Native.OpenSsl - include(${CLR_SRC_NATIVE_DIR}/libs/System.Security.Cryptography.Native/extra_libs.cmake) - append_extra_cryptography_libs(NATIVE_LIBS) + if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + # Additional requirements for System.Security.Cryptography.Native.OpenSsl + include(${CLR_SRC_NATIVE_DIR}/libs/System.Security.Cryptography.Native/extra_libs.cmake) + append_extra_cryptography_libs(NATIVE_LIBS) + endif() set(RUNTIMEINFO_LIB runtimeinfo) endif() -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) LIST(APPEND NATIVE_LIBS System.Security.Cryptography.Native.Apple-Static ) @@ -180,7 +184,7 @@ endif() # # Additional requirements for coreclr # -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) find_library(COREFOUNDATION CoreFoundation) find_library(CORESERVICES CoreServices) find_library(SECURITY Security) @@ -202,14 +206,14 @@ elseif (CLR_CMAKE_TARGET_SUNOS) LIST(APPEND NATIVE_LIBS socket ) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) # On *BSD, we always use the libunwind that's part of the OS if(CLR_CMAKE_TARGET_FREEBSD) set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) endif() -if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) find_unwind_libs(UNWIND_LIBS) LIST(APPEND NATIVE_LIBS @@ -223,11 +227,11 @@ if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) # These options are used to force every object to be included even if it's unused. set(START_WHOLE_ARCHIVE -force_load) set(END_WHOLE_ARCHIVE ) -endif(CLR_CMAKE_TARGET_OSX) +endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) set_property(TARGET singlefilehost PROPERTY ENABLE_EXPORTS 1) diff --git a/src/native/external/llvm-libunwind.cmake b/src/native/external/llvm-libunwind.cmake index a30f03027f8c7..5d4b670f782d1 100644 --- a/src/native/external/llvm-libunwind.cmake +++ b/src/native/external/llvm-libunwind.cmake @@ -7,7 +7,7 @@ set (LLVM_LIBUNWIND_SOURCES_BASE src/libunwind.cpp ) -if(CLR_CMAKE_TARGET_OSX) +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) set(LLVM_LIBUNWIND_SOURCES_BASE ${LLVM_LIBUNWIND_SOURCES_BASE} src/Unwind_AppleExtras.cpp diff --git a/src/native/libs/System.Globalization.Native/pal_icushim.h b/src/native/libs/System.Globalization.Native/pal_icushim.h index 51e117113de1c..d64b708eded18 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim.h @@ -15,4 +15,8 @@ PALEXPORT int32_t GlobalizationNative_LoadICUData(const char* path); PALEXPORT const char* GlobalizationNative_GetICUDTName(const char* culture); +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +PALEXPORT const char* GlobalizationNative_GetICUDataPathFallback(void); +#endif + #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index f574b9d14797e..2968735694fc4 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -28,3 +28,10 @@ return strdup([localeName UTF8String]); } +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +const char* GlobalizationNative_GetICUDataPathFallback(void) +{ + NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"icudt" ofType:@"dat"]; + return strdup([bundlePath UTF8String]); +} +#endif diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 2cc4a850be65c..a8ea013adfa15 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -93,7 +93,7 @@ elif [[ "$__TargetOS" == linux-bionic && -z "$ROOTFS_DIR" ]]; then __CMakeArgs="-DFORCE_ANDROID_OPENSSL=1 -DANDROID_STL=none $__CMakeArgs" elif [[ "$__TargetOS" == iossimulator ]]; then # set default iOS simulator deployment target - # keep in sync with src/mono/Directory.Build.props + # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 $__CMakeArgs" if [[ "$__TargetArch" == x64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $__CMakeArgs" @@ -102,41 +102,41 @@ elif [[ "$__TargetOS" == iossimulator ]]; then elif [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" else - echo "Error: Unknown iossimulator architecture $__TargetArch." + echo "Error: Unknown iOS Simulator architecture $__TargetArch." exit 1 fi elif [[ "$__TargetOS" == ios ]]; then # set default iOS device deployment target - # keep in sync with src/mono/Directory.Build.props + # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 $__CMakeArgs" if [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" elif [[ "$__TargetArch" == arm ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"armv7;armv7s\" $__CMakeArgs" else - echo "Error: Unknown ios architecture $__TargetArch." + echo "Error: Unknown iOS architecture $__TargetArch." exit 1 fi elif [[ "$__TargetOS" == tvossimulator ]]; then # set default tvOS simulator deployment target - # keep in sync with src/mono/Directory.Build.props + # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 $__CMakeArgs" if [[ "$__TargetArch" == x64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $__CMakeArgs" elif [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" else - echo "Error: Unknown tvossimulator architecture $__TargetArch." + echo "Error: Unknown tvOS Simulator architecture $__TargetArch." exit 1 fi elif [[ "$__TargetOS" == tvos ]]; then # set default tvOS device deployment target - # keep in sync with src/mono/Directory.Build.props + # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 $__CMakeArgs" if [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" else - echo "Error: Unknown tvos architecture $__TargetArch." + echo "Error: Unknown tvOS architecture $__TargetArch." exit 1 fi fi From 414bda66828da7ba0ae5bb8fc4d6e6129a7f95c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 13 Feb 2023 19:09:03 +0100 Subject: [PATCH 02/14] PR feedback: introduce TARGET_APPLE and HOST_APPLE --- eng/native/configurecompiler.cmake | 8 ++++++- eng/native/configureplatform.cmake | 8 ++++++- eng/native/configuretools.cmake | 2 +- eng/native/functions.cmake | 12 +++++----- src/coreclr/clrdefinitions.cmake | 6 +++-- src/coreclr/clrfeatures.cmake | 2 +- src/coreclr/crosscomponents.cmake | 2 +- src/coreclr/debug/dbgutil/CMakeLists.txt | 8 +++---- src/coreclr/dlls/mscordac/CMakeLists.txt | 8 +++---- src/coreclr/dlls/mscordbi/CMakeLists.txt | 4 ++-- .../dlls/mscoree/coreclr/CMakeLists.txt | 6 ++--- src/coreclr/gc/CMakeLists.txt | 4 ++-- src/coreclr/gc/unix/gcenv.unix.cpp | 12 +++++----- src/coreclr/inc/crosscomp.h | 2 +- src/coreclr/inc/executableallocator.h | 4 ++-- src/coreclr/jit/target.h | 4 ++++ src/coreclr/nativeaot/CMakeLists.txt | 4 ++-- src/coreclr/nativeaot/Runtime/CMakeLists.txt | 4 ++-- src/coreclr/nativeaot/Runtime/CommonMacros.h | 2 +- .../nativeaot/Runtime/ThunksMapping.cpp | 8 +++---- .../Runtime/unix/HardwareExceptions.cpp | 4 ++-- .../nativeaot/Runtime/unix/PalRedhawkUnix.cpp | 4 ++-- src/coreclr/pal/inc/pal.h | 4 ++-- src/coreclr/pal/src/CMakeLists.txt | 23 ++++++++++--------- src/coreclr/pal/src/configure.cmake | 6 ++--- src/coreclr/pal/src/exception/seh-unwind.cpp | 12 +++++----- src/coreclr/pal/src/exception/signal.cpp | 2 +- src/coreclr/pal/src/include/pal/context.h | 12 +++++----- src/coreclr/pal/src/include/pal/mutex.hpp | 2 +- src/coreclr/pal/src/map/virtual.cpp | 6 ++--- src/coreclr/pal/src/misc/sysinfo.cpp | 8 +++---- src/coreclr/pal/src/thread/context.cpp | 12 +++++----- src/coreclr/pal/src/thread/process.cpp | 8 +++---- src/coreclr/pal/src/thread/thread.cpp | 4 ++-- .../pal_sxs/test1/CMakeLists.txt | 4 ++-- src/coreclr/utilcode/executableallocator.cpp | 4 ++-- .../corehost/apphost/static/CMakeLists.txt | 14 +++++------ src/native/external/llvm-libunwind.cmake | 2 +- src/native/libs/CMakeLists.txt | 4 ++-- .../CMakeLists.txt | 6 ++--- src/native/libs/System.Native/CMakeLists.txt | 2 +- .../libs/System.Native/extra_libs.cmake | 2 +- src/tests/Interop/CMakeLists.txt | 2 +- 43 files changed, 138 insertions(+), 119 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 4c1d16d658c93..0930fc03e274f 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -200,7 +200,7 @@ elseif(CLR_CMAKE_HOST_SUNOS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector") add_definitions(-D__EXTENSIONS__ -D_XPG4_2 -D_POSIX_PTHREAD_SEMANTICS) -elseif(CLR_CMAKE_HOST_OSX AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) +elseif(CLR_CMAKE_HOST_OSX AND NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) add_definitions(-D_XOPEN_SOURCE) add_linker_flag("-Wl,-bind_at_load") endif() @@ -276,6 +276,7 @@ if (CLR_CMAKE_HOST_UNIX) add_definitions(-DHOST_UNIX) if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST) + add_definitions(-DHOST_APPLE) if(CLR_CMAKE_HOST_MACCATALYST) add_definitions(-DHOST_MACCATALYST) else() @@ -289,6 +290,7 @@ if (CLR_CMAKE_HOST_UNIX) clr_unknown_arch() endif() elseif (CLR_CMAKE_HOST_IOS) + add_definitions(-DHOST_APPLE) add_definitions(-DHOST_IOS) if(CLR_CMAKE_HOST_UNIX_AMD64) message("Detected iOS x86_64") @@ -298,6 +300,7 @@ if (CLR_CMAKE_HOST_UNIX) clr_unknown_arch() endif() elseif (CLR_CMAKE_HOST_TVOS) + add_definitions(-DHOST_APPLE) add_definitions(-DHOST_TVOS) if(CLR_CMAKE_HOST_UNIX_AMD64) message("Detected tvOS x86_64") @@ -564,6 +567,9 @@ if(CLR_CMAKE_TARGET_UNIX) add_compile_definitions($<$>>:TARGET_UNIX>) # Contracts are disabled on UNIX. add_definitions(-DDISABLE_CONTRACTS) + if(CLR_CMAKE_TARGET_APPLE) + add_compile_definitions($<$>>:TARGET_APPLE>) + endif() if(CLR_CMAKE_TARGET_OSX) add_compile_definitions($<$>>:TARGET_OSX>) elseif(CLR_CMAKE_TARGET_MACCATALYST) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 9907cd09e80e1..192e3a302974a 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -99,6 +99,7 @@ endif(CLR_CMAKE_HOST_OS STREQUAL linux) if(CLR_CMAKE_HOST_OS STREQUAL darwin) set(CLR_CMAKE_HOST_UNIX 1) + set(CLR_CMAKE_HOST_APPLE 1) if(CMAKE_SYSTEM_VARIANT STREQUAL maccatalyst) set(CLR_CMAKE_HOST_MACCATALYST 1) @@ -118,6 +119,7 @@ endif(CLR_CMAKE_HOST_OS STREQUAL darwin) if(CLR_CMAKE_HOST_OS STREQUAL ios OR CLR_CMAKE_HOST_OS STREQUAL iossimulator) set(CLR_CMAKE_HOST_UNIX 1) + set(CLR_CMAKE_HOST_APPLE 1) set(CLR_CMAKE_HOST_IOS 1) if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") set(CLR_CMAKE_HOST_UNIX_AMD64 1) @@ -134,6 +136,7 @@ endif(CLR_CMAKE_HOST_OS STREQUAL ios OR CLR_CMAKE_HOST_OS STREQUAL iossimulator) if(CLR_CMAKE_HOST_OS STREQUAL tvos OR CLR_CMAKE_HOST_OS STREQUAL tvossimulator) set(CLR_CMAKE_HOST_UNIX 1) + set(CLR_CMAKE_HOST_APPLE 1) set(CLR_CMAKE_HOST_TVOS 1) if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") set(CLR_CMAKE_HOST_UNIX_AMD64 1) @@ -374,6 +377,7 @@ endif(CLR_CMAKE_TARGET_OS STREQUAL android) if(CLR_CMAKE_TARGET_OS STREQUAL darwin) set(CLR_CMAKE_TARGET_UNIX 1) + set(CLR_CMAKE_TARGET_APPLE 1) if(CMAKE_SYSTEM_VARIANT STREQUAL maccatalyst) set(CLR_CMAKE_TARGET_MACCATALYST 1) @@ -384,11 +388,13 @@ endif(CLR_CMAKE_TARGET_OS STREQUAL darwin) if(CLR_CMAKE_TARGET_OS STREQUAL ios OR CLR_CMAKE_TARGET_OS STREQUAL iossimulator) set(CLR_CMAKE_TARGET_UNIX 1) + set(CLR_CMAKE_TARGET_APPLE 1) set(CLR_CMAKE_TARGET_IOS 1) endif(CLR_CMAKE_TARGET_OS STREQUAL ios OR CLR_CMAKE_TARGET_OS STREQUAL iossimulator) if(CLR_CMAKE_TARGET_OS STREQUAL tvos OR CLR_CMAKE_TARGET_OS STREQUAL tvossimulator) set(CLR_CMAKE_TARGET_UNIX 1) + set(CLR_CMAKE_TARGET_APPLE 1) set(CLR_CMAKE_TARGET_TVOS 1) endif(CLR_CMAKE_TARGET_OS STREQUAL tvos OR CLR_CMAKE_TARGET_OS STREQUAL tvossimulator) @@ -474,7 +480,7 @@ endif() if(NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) # The default linker on Solaris also does not support PIE. - if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_IOS AND NOT MSVC) + if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_APPLE AND NOT MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") add_compile_options($<$,EXECUTABLE>:-fPIE>) add_compile_options($<$,SHARED_LIBRARY>:-fPIC>) diff --git a/eng/native/configuretools.cmake b/eng/native/configuretools.cmake index 1f800b0f89789..7624b31ac46c4 100644 --- a/eng/native/configuretools.cmake +++ b/eng/native/configuretools.cmake @@ -51,7 +51,7 @@ if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) locate_toolchain_exec(link CMAKE_LINKER YES) endif() - if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND (NOT CLR_CMAKE_TARGET_ANDROID OR CROSS_ROOTFS)) + if(NOT CLR_CMAKE_TARGET_APPLE AND (NOT CLR_CMAKE_TARGET_ANDROID OR CROSS_ROOTFS)) locate_toolchain_exec(objdump CMAKE_OBJDUMP YES) unset(CMAKE_OBJCOPY CACHE) diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index 8e03f566cf7c1..3ca4678871604 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -327,7 +327,7 @@ function(generate_exports_file) list(GET INPUT_LIST -1 outputFilename) list(REMOVE_AT INPUT_LIST -1) - if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if(CLR_CMAKE_TARGET_APPLE) set(SCRIPT_NAME generateexportedsymbols.sh) else() set(SCRIPT_NAME generateversionscript.sh) @@ -366,7 +366,7 @@ endfunction() function (get_symbol_file_name targetName outputSymbolFilename) if (CLR_CMAKE_HOST_UNIX) - if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if (CLR_CMAKE_TARGET_APPLE) set(strip_destination_file $.dwarf) else () set(strip_destination_file $.dbg) @@ -386,7 +386,7 @@ function(strip_symbols targetName outputFilename) if (CLR_CMAKE_HOST_UNIX) set(strip_source_file $) - if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if (CLR_CMAKE_TARGET_APPLE) # Ensure that dsymutil and strip are present find_program(DSYMUTIL dsymutil) @@ -425,7 +425,7 @@ function(strip_symbols targetName outputFilename) COMMAND ${strip_command} COMMENT "Stripping symbols from ${strip_source_file} into file ${strip_destination_file}" ) - else (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + else (CLR_CMAKE_TARGET_APPLE) add_custom_command( TARGET ${targetName} @@ -436,7 +436,7 @@ function(strip_symbols targetName outputFilename) COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file} COMMENT "Stripping symbols from ${strip_source_file} into file ${strip_destination_file}" ) - endif (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + endif (CLR_CMAKE_TARGET_APPLE) endif(CLR_CMAKE_HOST_UNIX) endfunction() @@ -446,7 +446,7 @@ function(install_with_stripped_symbols targetName kind destination) install_symbol_file(${symbol_file} ${destination} ${ARGN}) endif() - if ((CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND ("${kind}" STREQUAL "TARGETS")) + if (CLR_CMAKE_TARGET_APPLE AND ("${kind}" STREQUAL "TARGETS")) # We want to avoid the kind=TARGET install behaviors which corrupt code signatures on osx-arm64 set(kind PROGRAMS) endif() diff --git a/src/coreclr/clrdefinitions.cmake b/src/coreclr/clrdefinitions.cmake index fab835ef7600f..052791529d614 100644 --- a/src/coreclr/clrdefinitions.cmake +++ b/src/coreclr/clrdefinitions.cmake @@ -29,9 +29,9 @@ if (CLR_CMAKE_TARGET_UNIX) endif(CLR_CMAKE_TARGET_UNIX) -if ((CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND CLR_CMAKE_TARGET_ARCH_ARM64) +if ((CLR_CMAKE_TARGET_APPLE) AND CLR_CMAKE_TARGET_ARCH_ARM64) add_compile_definitions($<$>>:OSX_ARM64_ABI>) -endif((CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND CLR_CMAKE_TARGET_ARCH_ARM64) +endif((CLR_CMAKE_TARGET_APPLE) AND CLR_CMAKE_TARGET_ARCH_ARM64) if(CLR_CMAKE_TARGET_ALPINE_LINUX) # Alpine Linux doesn't have fixed stack limit, this define disables some stack pointer @@ -249,9 +249,11 @@ function(set_target_definitions_to_custom_os_and_arch) elseif (TARGETDETAILS_ARCH STREQUAL "loongarch64") endif() if ((TARGETDETAILS_ARCH STREQUAL "arm64") AND (TARGETDETAILS_OS STREQUAL "unix_osx")) + target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_APPLE) target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE OSX_ARM64_ABI) endif() if (TARGETDETAILS_OS STREQUAL "unix_osx") + target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_APPLE) target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_OSX) endif() elseif (TARGETDETAILS_OS STREQUAL "win") diff --git a/src/coreclr/clrfeatures.cmake b/src/coreclr/clrfeatures.cmake index f82ff1aa4e73e..85752b0d59795 100644 --- a/src/coreclr/clrfeatures.cmake +++ b/src/coreclr/clrfeatures.cmake @@ -36,6 +36,6 @@ if (CLR_CMAKE_TARGET_WIN32 OR CLR_CMAKE_TARGET_UNIX) set(FEATURE_COMWRAPPERS 1) endif() -if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if (CLR_CMAKE_TARGET_APPLE) set(FEATURE_OBJCMARSHAL 1) endif() diff --git a/src/coreclr/crosscomponents.cmake b/src/coreclr/crosscomponents.cmake index 49f40db14bb29..2bd288221192f 100644 --- a/src/coreclr/crosscomponents.cmake +++ b/src/coreclr/crosscomponents.cmake @@ -33,7 +33,7 @@ if (CLR_CMAKE_HOST_OS STREQUAL CLR_CMAKE_TARGET_OS) endif() endif() -if(NOT CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_OSX AND NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS AND NOT FEATURE_CROSSBITNESS) +if(NOT CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_APPLE AND NOT FEATURE_CROSSBITNESS) install_clr (TARGETS mscordaccore mscordbi diff --git a/src/coreclr/debug/dbgutil/CMakeLists.txt b/src/coreclr/debug/dbgutil/CMakeLists.txt index 31cb4703dd6fe..89c1588246df6 100644 --- a/src/coreclr/debug/dbgutil/CMakeLists.txt +++ b/src/coreclr/debug/dbgutil/CMakeLists.txt @@ -5,9 +5,9 @@ if(CLR_CMAKE_HOST_WIN32) set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded) endif(CLR_CMAKE_HOST_WIN32) -if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) +if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_APPLE) include_directories(${CLR_DIR}/inc/llvm) -endif(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) +endif(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_APPLE) add_definitions(-DPAL_STDCPP_COMPAT) @@ -25,10 +25,10 @@ if(CLR_CMAKE_TARGET_LINUX) ) endif(CLR_CMAKE_TARGET_LINUX) -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) +if(CLR_CMAKE_HOST_APPLE) list(APPEND DBGUTIL_SOURCES machoreader.cpp ) -endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) +endif(CLR_CMAKE_HOST_APPLE) add_library_clr(dbgutil STATIC ${DBGUTIL_SOURCES}) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 8c680e189afc8..ee3c1fb2b1b48 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -31,14 +31,14 @@ 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_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + if(CLR_CMAKE_HOST_APPLE OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + endif(CLR_CMAKE_HOST_APPLE OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) - if(CORECLR_SET_RPATH AND (CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) AND CLR_CMAKE_HOST_ARCH_ARM64) + if(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_APPLE AND CLR_CMAKE_HOST_ARCH_ARM64) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) set(CMAKE_INSTALL_NAME_DIR "@rpath") - endif(CORECLR_SET_RPATH AND (CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) AND CLR_CMAKE_HOST_ARCH_ARM64) + endif(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_APPLE AND CLR_CMAKE_HOST_ARCH_ARM64) if(CLR_CMAKE_HOST_LINUX) diff --git a/src/coreclr/dlls/mscordbi/CMakeLists.txt b/src/coreclr/dlls/mscordbi/CMakeLists.txt index 04634a279fdba..d026e09b9c377 100644 --- a/src/coreclr/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/dlls/mscordbi/CMakeLists.txt @@ -2,7 +2,7 @@ # Set the RPATH of mscordbi so that it can find dependencies without needing to set LD_LIBRARY_PATH # For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling. if(CORECLR_SET_RPATH) - if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) + if(CLR_CMAKE_HOST_APPLE) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) set(CMAKE_INSTALL_NAME_DIR "@rpath") set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) @@ -10,7 +10,7 @@ if(CORECLR_SET_RPATH) else() set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN") - endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) + endif(CLR_CMAKE_HOST_APPLE) endif(CORECLR_SET_RPATH) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index c02a494fbfee1..08cff16606731 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -50,11 +50,11 @@ else(CLR_CMAKE_HOST_WIN32) set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) - if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) + if(CLR_CMAKE_TARGET_APPLE) # These options are used to force every object to be included even if it's unused. set(START_WHOLE_ARCHIVE -force_load) set(END_WHOLE_ARCHIVE ) - endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) + endif(CLR_CMAKE_TARGET_APPLE) set_exports_linker_option(${EXPORTS_FILE}) @@ -167,7 +167,7 @@ if(FEATURE_MERGE_JIT_AND_ENGINE) set(CLRJIT_STATIC clrjit_static) endif(FEATURE_MERGE_JIT_AND_ENGINE) -if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS) +if (CLR_CMAKE_TARGET_APPLE) include(CMakeFindFrameworks) find_library(FOUNDATION Foundation REQUIRED) endif() diff --git a/src/coreclr/gc/CMakeLists.txt b/src/coreclr/gc/CMakeLists.txt index d4a96e27b51b6..b4e203606d543 100644 --- a/src/coreclr/gc/CMakeLists.txt +++ b/src/coreclr/gc/CMakeLists.txt @@ -112,12 +112,12 @@ install_clr(TARGETS clrgc DESTINATIONS . COMPONENT runtime) add_definitions(-DBUILD_AS_STANDALONE) add_definitions(-DFX_VER_INTERNALNAME_STR=clrgc.dll) add_definitions(-DVERIFY_HEAP) -if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) +if(CLR_CMAKE_HOST_APPLE) # The implementation of GCToOSInterface on Apple platforms makes use of non-POSIX # pthreads APIs, which by default are not included in the pthreads header # unless we define this macro. add_definitions(-D_DARWIN_C_SOURCE) -endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) +endif(CLR_CMAKE_HOST_APPLE) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/env) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 7fdabf92fb037..cb32959c4ef34 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -235,7 +235,7 @@ bool GCToOSInterface::Initialize() { s_flushUsingMemBarrier = TRUE; } -#if !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#ifndef TARGET_APPLE else { assert(g_helperPage == 0); @@ -267,7 +267,7 @@ bool GCToOSInterface::Initialize() return false; } } -#endif // !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#endif // !TARGET_APPLE InitializeCGroup(); @@ -407,7 +407,7 @@ void GCToOSInterface::FlushProcessWriteBuffers() status = pthread_mutex_unlock(&g_flushProcessWriteBuffersMutex); assert(status == 0 && "Failed to unlock the flushProcessWriteBuffersMutex lock"); } -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#ifdef TARGET_APPLE else { mach_msg_type_number_t cThreads; @@ -455,7 +455,7 @@ void GCToOSInterface::FlushProcessWriteBuffers() machret = vm_deallocate(mach_task_self(), (vm_address_t)pThreads, cThreads * sizeof(thread_act_t)); CHECK_MACH("vm_deallocate()", machret); } -#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#endif // TARGET_APPLE } // Break into a debugger. Uses a compiler intrinsic if one is available, @@ -843,7 +843,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_APPLE) if (cacheSize == 0) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info @@ -893,7 +893,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_APPLE) if (cacheLevel != 3) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info diff --git a/src/coreclr/inc/crosscomp.h b/src/coreclr/inc/crosscomp.h index 97d92e0091898..c89a7a35a40fa 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 -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#ifdef TARGET_APPLE #define MAKE_TARGET_DLLNAME_W(name) W("lib") name W(".dylib") #define MAKE_TARGET_DLLNAME_A(name) "lib" name ".dylib" #else diff --git a/src/coreclr/inc/executableallocator.h b/src/coreclr/inc/executableallocator.h index e604e5ddcf5af..6a45dcc8189cd 100644 --- a/src/coreclr/inc/executableallocator.h +++ b/src/coreclr/inc/executableallocator.h @@ -254,7 +254,7 @@ class ExecutableWriterHolder void Unmap() { -#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) +#if defined(HOST_APPLE) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) if (m_addressRX != NULL) { PAL_JitWriteProtect(false); @@ -290,7 +290,7 @@ class ExecutableWriterHolder ExecutableWriterHolder(T* addressRX, size_t size) { m_addressRX = addressRX; -#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) m_addressRW = addressRX; PAL_JitWriteProtect(true); #else diff --git a/src/coreclr/jit/target.h b/src/coreclr/jit/target.h index cc97831c9f528..8baf645453adf 100644 --- a/src/coreclr/jit/target.h +++ b/src/coreclr/jit/target.h @@ -19,6 +19,10 @@ #undef TARGET_OSX #endif +#ifdef TARGET_APPLE +#undef TARGET_APPLE +#endif + #ifdef TARGET_WINDOWS #undef TARGET_WINDOWS #endif diff --git a/src/coreclr/nativeaot/CMakeLists.txt b/src/coreclr/nativeaot/CMakeLists.txt index db423590a79dd..91fa37cfad090 100644 --- a/src/coreclr/nativeaot/CMakeLists.txt +++ b/src/coreclr/nativeaot/CMakeLists.txt @@ -26,10 +26,10 @@ if(CLR_CMAKE_HOST_UNIX) add_compile_options(-fno-exceptions) # Native AOT runtime doesn't use C++ exception handling add_compile_options(-nostdlib) - if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if(CLR_CMAKE_TARGET_APPLE) add_definitions(-D_XOPEN_SOURCE) add_definitions(-DFEATURE_OBJCMARSHAL) - endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + endif(CLR_CMAKE_TARGET_APPLE) if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386) # Allow 16 byte compare-exchange diff --git a/src/coreclr/nativeaot/Runtime/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/CMakeLists.txt index 9794c14b4198f..8d4e163c1a81e 100644 --- a/src/coreclr/nativeaot/Runtime/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/CMakeLists.txt @@ -169,11 +169,11 @@ else() set(ASM_SUFFIX S) endif() -if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if (CLR_CMAKE_TARGET_APPLE) list(APPEND COMMON_RUNTIME_SOURCES interoplibinterface_objc.cpp ) -endif (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +endif (CLR_CMAKE_TARGET_APPLE) if (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32) list(APPEND COMMON_RUNTIME_SOURCES diff --git a/src/coreclr/nativeaot/Runtime/CommonMacros.h b/src/coreclr/nativeaot/Runtime/CommonMacros.h index 8542b8db97661..45e741134b541 100644 --- a/src/coreclr/nativeaot/Runtime/CommonMacros.h +++ b/src/coreclr/nativeaot/Runtime/CommonMacros.h @@ -155,7 +155,7 @@ inline bool IS_ALIGNED(T* val, uintptr_t alignment); #define DATA_ALIGNMENT 8 #ifndef OS_PAGE_SIZE -#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) +#if defined(HOST_APPLE) #define OS_PAGE_SIZE 0x4000 #else #define OS_PAGE_SIZE 0x1000 diff --git a/src/coreclr/nativeaot/Runtime/ThunksMapping.cpp b/src/coreclr/nativeaot/Runtime/ThunksMapping.cpp index 62c3a157d87bd..30d3c4722e8a4 100644 --- a/src/coreclr/nativeaot/Runtime/ThunksMapping.cpp +++ b/src/coreclr/nativeaot/Runtime/ThunksMapping.cpp @@ -121,9 +121,9 @@ EXTERN_C NATIVEAOT_API void* __cdecl RhAllocateThunksMapping() return NULL; } -#if defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) #if defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) - RhFailFast(); // TODO: add pthread_jit_write_protect_np workaround + RhFailFast(); // we don't expect to get here on these platforms #elif defined(HOST_OSX) pthread_jit_write_protect_np(0); #else @@ -232,9 +232,9 @@ EXTERN_C NATIVEAOT_API void* __cdecl RhAllocateThunksMapping() } } -#if defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) #if defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) - RhFailFast(); // TODO: add pthread_jit_write_protect_np workaround + RhFailFast(); // we don't expect to get here on these platforms #elif defined(HOST_OSX) pthread_jit_write_protect_np(1); #else diff --git a/src/coreclr/nativeaot/Runtime/unix/HardwareExceptions.cpp b/src/coreclr/nativeaot/Runtime/unix/HardwareExceptions.cpp index 57725354321c9..5aecfc0c33211 100644 --- a/src/coreclr/nativeaot/Runtime/unix/HardwareExceptions.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/HardwareExceptions.cpp @@ -11,7 +11,7 @@ #include "HardwareExceptions.h" #include "UnixSignals.h" -#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) +#if defined(HOST_APPLE) #include #include #include @@ -594,8 +594,8 @@ bool InitializeHardwareExceptionHandling() return false; } +#if defined(HOST_APPLE) #ifndef HOST_TVOS // task_set_exception_ports is not supported on tvOS -#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) // LLDB installs task-wide Mach exception handlers. XNU dispatches Mach // exceptions first to any registered "activation" handler and then to // any registered task handler before dispatching the exception to a diff --git a/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp b/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp index 22b07026d9c42..622c503476a97 100644 --- a/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp @@ -733,7 +733,7 @@ REDHAWK_PALEXPORT _Ret_maybenull_ _Post_writable_byte_size_(size) void* REDHAWK_ size_t alignedSize = size + (Alignment - OS_PAGE_SIZE); int flags = MAP_ANON | MAP_PRIVATE; -#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) if (unixProtect & PROT_EXEC) { flags |= MAP_JIT; @@ -967,7 +967,7 @@ static void ActivationHandler(int code, siginfo_t* siginfo, void* context) { // Only accept activations from the current process if (g_pHijackCallback != NULL && (siginfo->si_pid == getpid() -#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) +#if defined(HOST_APPLE) // On Apple platforms si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple // signals are in flight in the same process at the same time, it may be overwritten / zeroed. || siginfo->si_pid == 0 diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 8bda376262580..eaa02c5a70ac6 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -2940,14 +2940,14 @@ VirtualFree( IN DWORD dwFreeType); -#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) PALIMPORT VOID PALAPI PAL_JitWriteProtect(bool writeEnable); -#endif // (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && 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 9df28851ce306..df4b4b9dfe4e4 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -1,7 +1,7 @@ -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_FREEBSD) +if(CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_FREEBSD) # On Apple platforms and *BSD, we use the libunwind that's part of the OS set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) -endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_FREEBSD) +endif(CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_FREEBSD) if(NOT DEFINED ENV{ROOTFS_DIR}) include_directories(SYSTEM /usr/local/include) @@ -16,7 +16,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 AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +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) @@ -66,7 +66,8 @@ if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) add_definitions(-DFEATURE_USE_SYSTEM_LIBUNWIND) endif(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_TARGET_APPLE) + add_definitions(-DTARGET_APPLE) if(CLR_CMAKE_TARGET_OSX) add_definitions(-DTARGET_OSX) elseif(CLR_CMAKE_TARGET_MACCATALYST) @@ -86,7 +87,7 @@ if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS exception/machexception.cpp exception/machmessage.cpp ) -endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +endif(CLR_CMAKE_TARGET_APPLE) if (FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) add_definitions(-DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) @@ -118,12 +119,12 @@ set(ARCH_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/processor.cpp ) -if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +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 AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +endif(NOT CLR_CMAKE_TARGET_APPLE) if(CLR_CMAKE_HOST_ARCH_ARM) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -235,7 +236,7 @@ add_library(coreclrpal ) # Build separate pal library for DAC (addition to regular pal library) -if(CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_TARGET_OSX) set(LIBUNWIND_DAC_OBJECTS $) add_library(coreclrpal_dac STATIC @@ -250,7 +251,7 @@ else() exception/remote-unwind.cpp ) endif(NOT FEATURE_CROSSBITNESS) -endif(CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +endif(CLR_CMAKE_TARGET_OSX) if(NOT FEATURE_CROSSBITNESS) target_include_directories(coreclrpal_dac PUBLIC @@ -276,7 +277,7 @@ if(CLR_CMAKE_TARGET_LINUX) target_sources(tracepointprovider INTERFACE $) endif(CLR_CMAKE_TARGET_LINUX) -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_TARGET_APPLE) find_library(COREFOUNDATION CoreFoundation) find_library(CORESERVICES CoreServices) find_library(SECURITY Security) @@ -287,7 +288,7 @@ if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS ${SECURITY} ${SYSTEM} ) -endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +endif(CLR_CMAKE_TARGET_APPLE) if(CLR_CMAKE_TARGET_FREEBSD) target_link_libraries(coreclrpal diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake index 4c44d85a8d441..a8979bbe51014 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 OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +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") @@ -1307,7 +1307,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 OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_TARGET_APPLE) if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(HAVE__NSGETENVIRON 1) endif() @@ -1368,7 +1368,7 @@ else() # Anything else is Linux set(PAL_PT_WRITE_D PTRACE_POKEDATA) set(HAS_FTRUNCATE_LENGTH_ISSUE 0) set(HAVE_SCHED_OTHER_ASSIGNABLE 1) -endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +endif(CLR_CMAKE_TARGET_APPLE) check_struct_has_member( "struct statfs" diff --git a/src/coreclr/pal/src/exception/seh-unwind.cpp b/src/coreclr/pal/src/exception/seh-unwind.cpp index faee10b4648c3..da1bcccf4e253 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -54,7 +54,7 @@ Module Name: #endif // HOST_UNIX -#if (defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) && defined(HOST_ARM64) +#if defined(TARGET_APPLE) && defined(HOST_ARM64) // Apple platforms use ARM64 instead of AARCH64 to describe these registers // Create aliases to reuse more code enum @@ -96,7 +96,7 @@ enum UNW_AARCH64_V30 = UNW_ARM64_D30, UNW_AARCH64_V31 = UNW_ARM64_D31 }; -#endif // (defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) && defined(HOST_ARM64) +#endif // defined(TARGET_APPLE) && defined(HOST_ARM64) //---------------------------------------------------------------------- @@ -273,7 +273,7 @@ static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwCon { unwContext->fpregs[i] = winContext->D[i]; } -#elif defined(HOST_ARM64) && !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#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; @@ -315,7 +315,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) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#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. @@ -439,12 +439,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_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) && 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_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) && 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/exception/signal.cpp b/src/coreclr/pal/src/exception/signal.cpp index ddd667fd894d8..a440f9aa7211b 100644 --- a/src/coreclr/pal/src/exception/signal.cpp +++ b/src/coreclr/pal/src/exception/signal.cpp @@ -799,7 +799,7 @@ static void inject_activation_handler(int code, siginfo_t *siginfo, void *contex { // Only accept activations from the current process if (g_activationFunction != NULL && (siginfo->si_pid == getpid() -#if defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) +#if defined(HOST_APPLE) // On Apple platforms si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple // signals are in flight in the same process at the same time, it may be overwritten / zeroed. || siginfo->si_pid == 0 diff --git a/src/coreclr/pal/src/include/pal/context.h b/src/coreclr/pal/src/include/pal/context.h index 9fc094f50acaf..21396afcdc191 100644 --- a/src/coreclr/pal/src/include/pal/context.h +++ b/src/coreclr/pal/src/include/pal/context.h @@ -498,7 +498,7 @@ const struct fpregs* GetConstNativeSigSimdContext(const native_context_t *mc) return GetNativeSigSimdContext(const_cast(mc)); } -#elif !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) // TARGET_FREEBSD +#elif !defined(TARGET_APPLE) // TARGET_FREEBSD #define MCREG_X0(mc) ((mc).regs[0]) #define MCREG_X1(mc) ((mc).regs[1]) @@ -573,7 +573,7 @@ const fpsimd_context* GetConstNativeSigSimdContext(const native_context_t *mc) return GetNativeSigSimdContext(const_cast(mc)); } -#else // !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#else // !defined(TARGET_APPLE) #define MCREG_X0(mc) ((mc)->__ss.__x[0]) #define MCREG_X1(mc) ((mc)->__ss.__x[1]) @@ -623,7 +623,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex return GetNativeSigSimdContext(const_cast(mc)); } -#endif // !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#endif // !defined(TARGET_APPLE) #elif defined(HOST_LOONGARCH64) @@ -663,7 +663,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex #else // HOST_ARM64 -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_APPLE) #define MCREG_Rbp(mc) ((mc)->__ss.__rbp) #define MCREG_Rip(mc) ((mc)->__ss.__rip) @@ -711,7 +711,7 @@ inline void *FPREG_Xstate_Ymmh(const ucontext_t *uc) return reinterpret_cast(&((_STRUCT_X86_AVX_STATE64&)FPSTATE(uc)).__fpu_ymmh0); } -#else // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#else // defined(TARGET_APPLE) // For FreeBSD, as found in x86/ucontext.h #define MCREG_Rbp(mc) ((mc).mc_rbp) @@ -748,7 +748,7 @@ inline void *FPREG_Xstate_Ymmh(const ucontext_t *uc) #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 // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#endif // defined(TARGET_APPLE) #endif // HOST_ARM64 #else // HOST_64BIT diff --git a/src/coreclr/pal/src/include/pal/mutex.hpp b/src/coreclr/pal/src/include/pal/mutex.hpp index 5ebb14adb6f73..d3f73f63b37da 100644 --- a/src/coreclr/pal/src/include/pal/mutex.hpp +++ b/src/coreclr/pal/src/include/pal/mutex.hpp @@ -126,7 +126,7 @@ Miscellaneous // future, their use is disabled for compatibility. #if HAVE_FULLY_FEATURED_PTHREAD_MUTEXES && \ HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES && \ - !(defined(__FreeBSD__) || defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) + !(defined(__FreeBSD__) || defined(TARGET_APPLE)) #define NAMED_MUTEX_USE_PTHREAD_MUTEX 1 #else diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 992e680c7f782..bad67bc7f5549 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -1287,11 +1287,11 @@ VirtualProtect( return bRetVal; } -#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) PALAPI VOID PAL_JitWriteProtect(bool writeEnable) { #if defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) - RhFailFast(); // TODO: add pthread_jit_write_protect_np workaround + RhFailFast(); // we don't expect to get here on these platforms #elif defined(HOST_OSX) thread_local int enabledCount = 0; if (writeEnable) @@ -1313,7 +1313,7 @@ PALAPI VOID PAL_JitWriteProtect(bool writeEnable) #error "Unknown OS" #endif } -#endif // (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) +#endif // defined(HOST_APPLE) && defined(HOST_ARM64) #if HAVE_VM_ALLOCATE //--------------------------------------------------------------------------------------- diff --git a/src/coreclr/pal/src/misc/sysinfo.cpp b/src/coreclr/pal/src/misc/sysinfo.cpp index 3d4d84015c163..439a1dc7a9978 100644 --- a/src/coreclr/pal/src/misc/sysinfo.cpp +++ b/src/coreclr/pal/src/misc/sysinfo.cpp @@ -66,12 +66,12 @@ Revision History: #include #endif // HAVE_MACHINE_VMPARAM_H -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_APPLE) #include #include #include #include -#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#endif // defined(TARGET_APPLE) // On some platforms sys/user.h ends up defining _DEBUG; if so // remove the definition before including the header and put @@ -583,7 +583,7 @@ PAL_GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_APPLE) if (cacheSize == 0) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info @@ -633,7 +633,7 @@ PAL_GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !(defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_APPLE) if (cacheLevel != 3) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info diff --git a/src/coreclr/pal/src/thread/context.cpp b/src/coreclr/pal/src/thread/context.cpp index 3a25fafd7e092..dda0b4a45acc4 100644 --- a/src/coreclr/pal/src/thread/context.cpp +++ b/src/coreclr/pal/src/thread/context.cpp @@ -618,7 +618,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) FPREG_Xmm(native, i) = lpContext->FltSave.XmmRegisters[i]; } #elif defined(HOST_ARM64) -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_APPLE) _STRUCT_ARM_NEON_STATE64* fp = GetNativeSigSimdContext(native); fp->__fpsr = lpContext->Fpsr; fp->__fpcr = lpContext->Fpcr; @@ -637,7 +637,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->fp_q[i] = lpContext->V[i]; } } -#else // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#else // defined(TARGET_APPLE) fpsimd_context* fp = GetNativeSigSimdContext(native); if (fp) { @@ -648,7 +648,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->vregs[i] = lpContext->V[i]; } } -#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#endif // defined(TARGET_APPLE) #elif defined(HOST_ARM) VfpSigFrame* fp = GetNativeSigSimdContext(native); if (fp) @@ -780,7 +780,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->FltSave.XmmRegisters[i] = FPREG_Xmm(native, i); } #elif defined(HOST_ARM64) -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_APPLE) const _STRUCT_ARM_NEON_STATE64* fp = GetConstNativeSigSimdContext(native); lpContext->Fpsr = fp->__fpsr; lpContext->Fpcr = fp->__fpcr; @@ -799,7 +799,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->fp_q[i]; } } -#else // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#else // defined(TARGET_APPLE) const fpsimd_context* fp = GetConstNativeSigSimdContext(native); if (fp) { @@ -810,7 +810,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->vregs[i]; } } -#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#endif // defined(TARGET_APPLE) #elif defined(HOST_ARM) const VfpSigFrame* fp = GetConstNativeSigSimdContext(native); if (fp) diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index f338f4b139a7e..7a251cee82cc7 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -2473,7 +2473,7 @@ InitializeFlushProcessWriteBuffers() } } -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_APPLE) return TRUE; #else s_helperPage = static_cast(mmap(0, GetVirtualPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); @@ -2503,7 +2503,7 @@ InitializeFlushProcessWriteBuffers() } return status == 0; -#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#endif // defined(TARGET_APPLE) } #define FATAL_ASSERT(e, msg) \ @@ -2553,7 +2553,7 @@ FlushProcessWriteBuffers() status = pthread_mutex_unlock(&flushProcessWriteBuffersMutex); FATAL_ASSERT(status == 0, "Failed to unlock the flushProcessWriteBuffersMutex lock"); } -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_APPLE) else { mach_msg_type_number_t cThreads; @@ -2601,7 +2601,7 @@ FlushProcessWriteBuffers() machret = vm_deallocate(mach_task_self(), (vm_address_t)pThreads, cThreads * sizeof(thread_act_t)); CHECK_MACH("vm_deallocate()", machret); } -#endif // defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#endif // defined(TARGET_APPLE) } /*++ diff --git a/src/coreclr/pal/src/thread/thread.cpp b/src/coreclr/pal/src/thread/thread.cpp index 82848c11f7734..6ca22436c3655 100644 --- a/src/coreclr/pal/src/thread/thread.cpp +++ b/src/coreclr/pal/src/thread/thread.cpp @@ -2596,7 +2596,7 @@ void * CPalThread::GetStackBase() { void* stackBase; -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_APPLE) // This is an Apple specific method stackBase = pthread_get_stackaddr_np(pthread_self()); #else @@ -2636,7 +2636,7 @@ void * CPalThread::GetStackLimit() { void* stackLimit; -#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_APPLE) // This is an Apple specific method stackLimit = ((BYTE *)pthread_get_stackaddr_np(pthread_self()) - pthread_get_stacksize_np(pthread_self())); diff --git a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt index 74eb62d8d260e..77101684beb2b 100644 --- a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt @@ -5,12 +5,12 @@ endif(CLR_CMAKE_HOST_UNIX) # Set the RPATH of paltest_pal_sxs_test1 so that it can find dependencies without needing to set LD_LIBRARY # For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling. if(CORECLR_SET_RPATH) - if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) + if(CLR_CMAKE_HOST_APPLE) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) set(CMAKE_INSTALL_NAME_DIR "@rpath") set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "@loader_path") - endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) + endif(CLR_CMAKE_HOST_APPLE) if(CLR_CMAKE_HOST_LINUX) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN") diff --git a/src/coreclr/utilcode/executableallocator.cpp b/src/coreclr/utilcode/executableallocator.cpp index 13bc97b1ab7c0..789b033535c1f 100644 --- a/src/coreclr/utilcode/executableallocator.cpp +++ b/src/coreclr/utilcode/executableallocator.cpp @@ -105,7 +105,7 @@ bool ExecutableAllocator::IsDoubleMappingEnabled() { LIMITED_METHOD_CONTRACT; -#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) return false; #else return g_isWXorXEnabled; @@ -116,7 +116,7 @@ bool ExecutableAllocator::IsWXORXEnabled() { LIMITED_METHOD_CONTRACT; -#if (defined(HOST_OSX) || defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) +#if defined(HOST_APPLE) && defined(HOST_ARM64) return true; #else return g_isWXorXEnabled; diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index d7a815c146f80..aefd461500bd3 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -9,7 +9,7 @@ set(DOTNET_PROJECT_NAME "singlefilehost") # dependencies is not possible for some reason. # This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way, # doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive. -if (NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if (NOT CLR_CMAKE_TARGET_APPLE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") endif() @@ -171,7 +171,7 @@ else() endif() -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_TARGET_APPLE) LIST(APPEND NATIVE_LIBS System.Security.Cryptography.Native.Apple-Static ) @@ -184,7 +184,7 @@ endif() # # Additional requirements for coreclr # -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_TARGET_APPLE) find_library(COREFOUNDATION CoreFoundation) find_library(CORESERVICES CoreServices) find_library(SECURITY Security) @@ -206,14 +206,14 @@ elseif (CLR_CMAKE_TARGET_SUNOS) LIST(APPEND NATIVE_LIBS socket ) -endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +endif(CLR_CMAKE_TARGET_APPLE) # On *BSD, we always use the libunwind that's part of the OS if(CLR_CMAKE_TARGET_FREEBSD) set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) endif() -if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_APPLE) find_unwind_libs(UNWIND_LIBS) LIST(APPEND NATIVE_LIBS @@ -227,11 +227,11 @@ if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_TARGET_APPLE) # These options are used to force every object to be included even if it's unused. set(START_WHOLE_ARCHIVE -force_load) set(END_WHOLE_ARCHIVE ) -endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +endif(CLR_CMAKE_TARGET_APPLE) set_property(TARGET singlefilehost PROPERTY ENABLE_EXPORTS 1) diff --git a/src/native/external/llvm-libunwind.cmake b/src/native/external/llvm-libunwind.cmake index 5d4b670f782d1..a6f7ddf8cb5ba 100644 --- a/src/native/external/llvm-libunwind.cmake +++ b/src/native/external/llvm-libunwind.cmake @@ -7,7 +7,7 @@ set (LLVM_LIBUNWIND_SOURCES_BASE src/libunwind.cpp ) -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_TARGET_APPLE) set(LLVM_LIBUNWIND_SOURCES_BASE ${LLVM_LIBUNWIND_SOURCES_BASE} src/Unwind_AppleExtras.cpp diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 6dde2f698bda7..f72e04b400532 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -121,7 +121,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) message(FATAL_ERROR "Unknown build type. Set CMAKE_BUILD_TYPE to DEBUG or RELEASE.") endif () - if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if (CLR_CMAKE_TARGET_APPLE) add_definitions(-D__APPLE_USE_RFC_3542) endif () @@ -184,7 +184,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) add_subdirectory(System.Security.Cryptography.Native) endif () - if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if (CLR_CMAKE_TARGET_APPLE) add_subdirectory(System.Security.Cryptography.Native.Apple) endif () endif () diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index bbf9737d6e135..60a547b001e55 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -73,7 +73,7 @@ else() set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim.c) endif() -if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if (CLR_CMAKE_TARGET_APPLE) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_locale.m) endif() @@ -93,7 +93,7 @@ endif() include_directories("../Common") if (GEN_SHARED_LIB) - if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if (CLR_CMAKE_TARGET_APPLE) include(CMakeFindFrameworks) find_library(FOUNDATION Foundation REQUIRED) endif() @@ -123,7 +123,7 @@ endif() install (TARGETS System.Globalization.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) -if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID) +if(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_ANDROID) if (GEN_SHARED_LIB) add_custom_command(TARGET System.Globalization.Native POST_BUILD COMMENT "Verifying System.Globalization.Native.so dependencies" diff --git a/src/native/libs/System.Native/CMakeLists.txt b/src/native/libs/System.Native/CMakeLists.txt index d44823c951354..eb3853a81c1cd 100644 --- a/src/native/libs/System.Native/CMakeLists.txt +++ b/src/native/libs/System.Native/CMakeLists.txt @@ -52,7 +52,7 @@ else() ) endif() -if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if (CLR_CMAKE_TARGET_APPLE) list (APPEND NATIVE_SOURCES pal_autoreleasepool.m) set_source_files_properties(pal_autoreleasepool.m PROPERTIES COMPILE_FLAGS -fno-objc-arc) else() diff --git a/src/native/libs/System.Native/extra_libs.cmake b/src/native/libs/System.Native/extra_libs.cmake index 2edc74bde7aaf..b0fe86b69f4cc 100644 --- a/src/native/libs/System.Native/extra_libs.cmake +++ b/src/native/libs/System.Native/extra_libs.cmake @@ -10,7 +10,7 @@ macro(append_extra_system_libs NativeLibsExtra) list(APPEND ${NativeLibsExtra} socket) endif () - if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + if (CLR_CMAKE_TARGET_APPLE) include(CMakeFindFrameworks) find_library(FOUNDATION Foundation REQUIRED) list(APPEND ${NativeLibsExtra} ${FOUNDATION}) diff --git a/src/tests/Interop/CMakeLists.txt b/src/tests/Interop/CMakeLists.txt index 2d9e84209b2cf..21e83b1f9f370 100644 --- a/src/tests/Interop/CMakeLists.txt +++ b/src/tests/Interop/CMakeLists.txt @@ -100,7 +100,7 @@ if(CLR_CMAKE_TARGET_UNIX) add_subdirectory(COM/ComWrappers/WeakReference) endif(CLR_CMAKE_TARGET_UNIX) -if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_TARGET_APPLE) add_subdirectory(ObjectiveC/AutoReleaseTest) add_subdirectory(ObjectiveC/ObjectiveCMarshalAPI) endif() From ee102788a8488344d319e6eb8a507d4f625236b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 13 Feb 2023 19:12:38 +0100 Subject: [PATCH 03/14] Fixup --- eng/native/build-commons.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 39336178b57b2..f571bccdcecfd 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -106,7 +106,7 @@ build_native() cmakeArgs="-C $__RepoRootDir/eng/native/tryrun_ios_tvos.cmake $cmakeArgs" # set default iOS simulator deployment target - # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh + # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props cmakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $cmakeArgs" if [[ "$__TargetArch" == x64 ]]; then cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $cmakeArgs" @@ -120,7 +120,7 @@ build_native() cmakeArgs="-C $__RepoRootDir/eng/native/tryrun_ios_tvos.cmake $cmakeArgs" # set default iOS device deployment target - # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh + # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props cmakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $cmakeArgs" if [[ "$__TargetArch" == arm64 ]]; then cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $cmakeArgs" @@ -132,7 +132,7 @@ build_native() cmakeArgs="-C $__RepoRootDir/eng/native/tryrun_ios_tvos.cmake $cmakeArgs" # set default tvOS simulator deployment target - # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh + # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props cmakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $cmakeArgs" if [[ "$__TargetArch" == x64 ]]; then cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $cmakeArgs" @@ -146,7 +146,7 @@ build_native() cmakeArgs="-C $__RepoRootDir/eng/native/tryrun_ios_tvos.cmake $cmakeArgs" # set default tvOS device deployment target - # keep in sync with src/mono/Directory.Build.props, eng/native/build-commons.sh + # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props cmakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $cmakeArgs" if [[ "$__TargetArch" == arm64 ]]; then cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $cmakeArgs" From cef6c242c1e609574c1bbaa43c10292b46fae515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 13 Feb 2023 19:15:25 +0100 Subject: [PATCH 04/14] Fixup --- src/coreclr/clrdefinitions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/clrdefinitions.cmake b/src/coreclr/clrdefinitions.cmake index 052791529d614..9472c5f88ad72 100644 --- a/src/coreclr/clrdefinitions.cmake +++ b/src/coreclr/clrdefinitions.cmake @@ -29,9 +29,9 @@ if (CLR_CMAKE_TARGET_UNIX) endif(CLR_CMAKE_TARGET_UNIX) -if ((CLR_CMAKE_TARGET_APPLE) AND CLR_CMAKE_TARGET_ARCH_ARM64) +if (CLR_CMAKE_TARGET_APPLE AND CLR_CMAKE_TARGET_ARCH_ARM64) add_compile_definitions($<$>>:OSX_ARM64_ABI>) -endif((CLR_CMAKE_TARGET_APPLE) AND CLR_CMAKE_TARGET_ARCH_ARM64) +endif(CLR_CMAKE_TARGET_APPLE AND CLR_CMAKE_TARGET_ARCH_ARM64) if(CLR_CMAKE_TARGET_ALPINE_LINUX) # Alpine Linux doesn't have fixed stack limit, this define disables some stack pointer From a532f5ac84f4ba5c751cfdceedb1ed9d5a8cdab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 13 Feb 2023 19:16:31 +0100 Subject: [PATCH 05/14] Fixup --- src/coreclr/debug/dbgutil/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/debug/dbgutil/CMakeLists.txt b/src/coreclr/debug/dbgutil/CMakeLists.txt index 89c1588246df6..c245c22689838 100644 --- a/src/coreclr/debug/dbgutil/CMakeLists.txt +++ b/src/coreclr/debug/dbgutil/CMakeLists.txt @@ -25,10 +25,10 @@ if(CLR_CMAKE_TARGET_LINUX) ) endif(CLR_CMAKE_TARGET_LINUX) -if(CLR_CMAKE_HOST_APPLE) +if(CLR_CMAKE_TARGET_APPLE) list(APPEND DBGUTIL_SOURCES machoreader.cpp ) -endif(CLR_CMAKE_HOST_APPLE) +endif(CLR_CMAKE_TARGET_APPLE) add_library_clr(dbgutil STATIC ${DBGUTIL_SOURCES}) From 74471828b82731d06c06030bcb653b6a0ee7de51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 13 Feb 2023 19:35:05 +0100 Subject: [PATCH 06/14] Fixup --- src/coreclr/nativeaot/Runtime/CommonMacros.h | 2 +- .../nativeaot/Runtime/unix/PalRedhawkUnix.cpp | 2 +- src/coreclr/pal/src/exception/signal.cpp | 2 +- src/coreclr/pal/src/map/virtual.cpp | 2 +- src/coreclr/pal/src/thread/context.cpp | 12 ++++++------ src/coreclr/pal/src/thread/process.cpp | 8 ++++---- src/coreclr/pal/src/thread/thread.cpp | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/CommonMacros.h b/src/coreclr/nativeaot/Runtime/CommonMacros.h index 45e741134b541..53467c1a130b4 100644 --- a/src/coreclr/nativeaot/Runtime/CommonMacros.h +++ b/src/coreclr/nativeaot/Runtime/CommonMacros.h @@ -155,7 +155,7 @@ inline bool IS_ALIGNED(T* val, uintptr_t alignment); #define DATA_ALIGNMENT 8 #ifndef OS_PAGE_SIZE -#if defined(HOST_APPLE) +#ifdef HOST_APPLE #define OS_PAGE_SIZE 0x4000 #else #define OS_PAGE_SIZE 0x1000 diff --git a/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp b/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp index 622c503476a97..c4f7469d674d8 100644 --- a/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp @@ -967,7 +967,7 @@ static void ActivationHandler(int code, siginfo_t* siginfo, void* context) { // Only accept activations from the current process if (g_pHijackCallback != NULL && (siginfo->si_pid == getpid() -#if defined(HOST_APPLE) +#ifdef HOST_APPLE // On Apple platforms si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple // signals are in flight in the same process at the same time, it may be overwritten / zeroed. || siginfo->si_pid == 0 diff --git a/src/coreclr/pal/src/exception/signal.cpp b/src/coreclr/pal/src/exception/signal.cpp index a440f9aa7211b..01615494bd296 100644 --- a/src/coreclr/pal/src/exception/signal.cpp +++ b/src/coreclr/pal/src/exception/signal.cpp @@ -799,7 +799,7 @@ static void inject_activation_handler(int code, siginfo_t *siginfo, void *contex { // Only accept activations from the current process if (g_activationFunction != NULL && (siginfo->si_pid == getpid() -#if defined(HOST_APPLE) +#ifdef HOST_APPLE // On Apple platforms si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple // signals are in flight in the same process at the same time, it may be overwritten / zeroed. || siginfo->si_pid == 0 diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index bad67bc7f5549..892859211c104 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -1313,7 +1313,7 @@ PALAPI VOID PAL_JitWriteProtect(bool writeEnable) #error "Unknown OS" #endif } -#endif // defined(HOST_APPLE) && defined(HOST_ARM64) +#endif // HOST_APPLE && HOST_ARM64 #if HAVE_VM_ALLOCATE //--------------------------------------------------------------------------------------- diff --git a/src/coreclr/pal/src/thread/context.cpp b/src/coreclr/pal/src/thread/context.cpp index dda0b4a45acc4..d1d050fde2dcd 100644 --- a/src/coreclr/pal/src/thread/context.cpp +++ b/src/coreclr/pal/src/thread/context.cpp @@ -618,7 +618,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) FPREG_Xmm(native, i) = lpContext->FltSave.XmmRegisters[i]; } #elif defined(HOST_ARM64) -#if defined(TARGET_APPLE) +#ifdef TARGET_APPLE _STRUCT_ARM_NEON_STATE64* fp = GetNativeSigSimdContext(native); fp->__fpsr = lpContext->Fpsr; fp->__fpcr = lpContext->Fpcr; @@ -637,7 +637,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->fp_q[i] = lpContext->V[i]; } } -#else // defined(TARGET_APPLE) +#else // TARGET_APPLE fpsimd_context* fp = GetNativeSigSimdContext(native); if (fp) { @@ -648,7 +648,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->vregs[i] = lpContext->V[i]; } } -#endif // defined(TARGET_APPLE) +#endif // TARGET_APPLE #elif defined(HOST_ARM) VfpSigFrame* fp = GetNativeSigSimdContext(native); if (fp) @@ -780,7 +780,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->FltSave.XmmRegisters[i] = FPREG_Xmm(native, i); } #elif defined(HOST_ARM64) -#if defined(TARGET_APPLE) +#ifdef TARGET_APPLE const _STRUCT_ARM_NEON_STATE64* fp = GetConstNativeSigSimdContext(native); lpContext->Fpsr = fp->__fpsr; lpContext->Fpcr = fp->__fpcr; @@ -799,7 +799,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->fp_q[i]; } } -#else // defined(TARGET_APPLE) +#else // TARGET_APPLE const fpsimd_context* fp = GetConstNativeSigSimdContext(native); if (fp) { @@ -810,7 +810,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->vregs[i]; } } -#endif // defined(TARGET_APPLE) +#endif // TARGET_APPLE #elif defined(HOST_ARM) const VfpSigFrame* fp = GetConstNativeSigSimdContext(native); if (fp) diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index 7a251cee82cc7..a5725584cc8d0 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -2473,7 +2473,7 @@ InitializeFlushProcessWriteBuffers() } } -#if defined(TARGET_APPLE) +#ifdef TARGET_APPLE return TRUE; #else s_helperPage = static_cast(mmap(0, GetVirtualPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); @@ -2503,7 +2503,7 @@ InitializeFlushProcessWriteBuffers() } return status == 0; -#endif // defined(TARGET_APPLE) +#endif // TARGET_APPLE } #define FATAL_ASSERT(e, msg) \ @@ -2553,7 +2553,7 @@ FlushProcessWriteBuffers() status = pthread_mutex_unlock(&flushProcessWriteBuffersMutex); FATAL_ASSERT(status == 0, "Failed to unlock the flushProcessWriteBuffersMutex lock"); } -#if defined(TARGET_APPLE) +#ifdef TARGET_APPLE else { mach_msg_type_number_t cThreads; @@ -2601,7 +2601,7 @@ FlushProcessWriteBuffers() machret = vm_deallocate(mach_task_self(), (vm_address_t)pThreads, cThreads * sizeof(thread_act_t)); CHECK_MACH("vm_deallocate()", machret); } -#endif // defined(TARGET_APPLE) +#endif // TARGET_APPLE } /*++ diff --git a/src/coreclr/pal/src/thread/thread.cpp b/src/coreclr/pal/src/thread/thread.cpp index 6ca22436c3655..03bf05a9a5add 100644 --- a/src/coreclr/pal/src/thread/thread.cpp +++ b/src/coreclr/pal/src/thread/thread.cpp @@ -2596,7 +2596,7 @@ void * CPalThread::GetStackBase() { void* stackBase; -#if defined(TARGET_APPLE) +#ifdef TARGET_APPLE // This is an Apple specific method stackBase = pthread_get_stackaddr_np(pthread_self()); #else @@ -2636,7 +2636,7 @@ void * CPalThread::GetStackLimit() { void* stackLimit; -#if defined(TARGET_APPLE) +#ifdef TARGET_APPLE // This is an Apple specific method stackLimit = ((BYTE *)pthread_get_stackaddr_np(pthread_self()) - pthread_get_stacksize_np(pthread_self())); From 26a3cab658a57f226b0c7726cf99188b1a607ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 14 Feb 2023 13:36:50 +0100 Subject: [PATCH 07/14] Fix libs.pretest build --- eng/Subsets.props | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eng/Subsets.props b/eng/Subsets.props index cc366a3d4c3a2..e5315be5c5178 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -72,8 +72,7 @@ libs.native+ - $(DefaultLibrariesSubsets)libs.sfx+libs.oob+ - $(DefaultLibrariesSubsets)+libs.pretest + $(DefaultLibrariesSubsets)libs.sfx+libs.oob+libs.pretest tools.illink @@ -111,6 +110,9 @@ true + + + true From 2cbba748c643ff91ba3710a13f18c278c2ab3950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 14 Feb 2023 17:14:34 +0100 Subject: [PATCH 08/14] Revert unnecessary changes to files not used by NativeAOT --- src/coreclr/CMakeLists.txt | 72 +++++++++++-------- src/coreclr/debug/dbgutil/CMakeLists.txt | 8 +-- src/coreclr/dlls/mscordac/CMakeLists.txt | 8 +-- src/coreclr/dlls/mscordbi/CMakeLists.txt | 4 +- .../dlls/mscoree/coreclr/CMakeLists.txt | 6 +- src/coreclr/gc/unix/configure.cmake | 10 +++ src/coreclr/inc/crosscomp.h | 14 +--- src/coreclr/inc/executableallocator.h | 4 +- src/coreclr/pal/inc/pal.h | 4 +- src/coreclr/pal/src/CMakeLists.txt | 32 +++------ src/coreclr/pal/src/configure.cmake | 8 +-- src/coreclr/pal/src/exception/seh-unwind.cpp | 14 ++-- src/coreclr/pal/src/exception/signal.cpp | 4 +- src/coreclr/pal/src/include/pal/context.h | 12 ++-- src/coreclr/pal/src/include/pal/mutex.hpp | 4 +- src/coreclr/pal/src/map/virtual.cpp | 10 +-- src/coreclr/pal/src/misc/sysinfo.cpp | 8 +-- src/coreclr/pal/src/thread/context.cpp | 18 ++--- src/coreclr/pal/src/thread/process.cpp | 28 ++------ src/coreclr/pal/src/thread/thread.cpp | 8 +-- .../pal_sxs/test1/CMakeLists.txt | 4 +- src/coreclr/utilcode/executableallocator.cpp | 4 +- 22 files changed, 126 insertions(+), 158 deletions(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 9f632a5194eba..597791a70b945 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -40,6 +40,10 @@ if(CORECLR_SET_RPATH) set(MACOSX_RPATH ON) endif(CORECLR_SET_RPATH) +if(CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + set(FEATURE_EVENT_TRACE 0) +endif() + OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF) #---------------------------------------------------- @@ -105,8 +109,10 @@ if(CLR_CMAKE_HOST_UNIX) endif() endif() - add_subdirectory(pal) - add_subdirectory(hosts) + if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + add_subdirectory(pal) + add_subdirectory(hosts) + endif() else() if(CLR_CMAKE_TARGET_UNIX) add_subdirectory(${CLR_SRC_NATIVE_DIR}/external/libunwind_extras ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind) @@ -119,12 +125,16 @@ add_subdirectory(pal/prebuilt/inc) # These need to happen before the VM and debug-pal includes. set(EP_GENERATED_HEADER_PATH "${GENERATED_INCLUDE_DIR}") include (${CLR_SRC_NATIVE_DIR}/eventpipe/configure.cmake) -add_subdirectory(debug/debug-pal) -add_subdirectory(minipal) -if(CLR_CMAKE_TARGET_WIN32) - add_subdirectory(gc/sample) +if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + add_subdirectory(debug/debug-pal) + + add_subdirectory(minipal) + + if(CLR_CMAKE_TARGET_WIN32) + add_subdirectory(gc/sample) + endif() endif() #------------------------------------- @@ -233,30 +243,32 @@ if(CLR_CMAKE_HOST_UNIX) add_subdirectory(nativeresources) endif(CLR_CMAKE_HOST_UNIX) -add_subdirectory(utilcode) -add_subdirectory(inc) - -if(CLR_CMAKE_HOST_UNIX) - add_subdirectory(palrt) -endif(CLR_CMAKE_HOST_UNIX) - -add_subdirectory(ilasm) -add_subdirectory(ildasm) -add_subdirectory(gcinfo) -add_subdirectory(jit) -add_subdirectory(vm) -add_subdirectory(md) -add_subdirectory(debug) -add_subdirectory(binder) -add_subdirectory(classlibnative) -add_subdirectory(dlls) -add_subdirectory(tools) -add_subdirectory(unwinder) -add_subdirectory(interop) - -if(CLR_CMAKE_HOST_WIN32) - add_subdirectory(hosts) -endif(CLR_CMAKE_HOST_WIN32) +if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + add_subdirectory(utilcode) + add_subdirectory(inc) + + if(CLR_CMAKE_HOST_UNIX) + add_subdirectory(palrt) + endif(CLR_CMAKE_HOST_UNIX) + + add_subdirectory(ilasm) + add_subdirectory(ildasm) + add_subdirectory(gcinfo) + add_subdirectory(jit) + add_subdirectory(vm) + add_subdirectory(md) + add_subdirectory(debug) + add_subdirectory(binder) + add_subdirectory(classlibnative) + add_subdirectory(dlls) + add_subdirectory(tools) + add_subdirectory(unwinder) + add_subdirectory(interop) + + if(CLR_CMAKE_HOST_WIN32) + add_subdirectory(hosts) + endif(CLR_CMAKE_HOST_WIN32) +endif(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) #---------------------------------------------------- # Cross target Component install configuration diff --git a/src/coreclr/debug/dbgutil/CMakeLists.txt b/src/coreclr/debug/dbgutil/CMakeLists.txt index c245c22689838..91f41404221df 100644 --- a/src/coreclr/debug/dbgutil/CMakeLists.txt +++ b/src/coreclr/debug/dbgutil/CMakeLists.txt @@ -5,9 +5,9 @@ if(CLR_CMAKE_HOST_WIN32) set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded) endif(CLR_CMAKE_HOST_WIN32) -if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_APPLE) +if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX) include_directories(${CLR_DIR}/inc/llvm) -endif(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_APPLE) +endif(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX) add_definitions(-DPAL_STDCPP_COMPAT) @@ -25,10 +25,10 @@ if(CLR_CMAKE_TARGET_LINUX) ) endif(CLR_CMAKE_TARGET_LINUX) -if(CLR_CMAKE_TARGET_APPLE) +if(CLR_CMAKE_TARGET_OSX) list(APPEND DBGUTIL_SOURCES machoreader.cpp ) -endif(CLR_CMAKE_TARGET_APPLE) +endif(CLR_CMAKE_TARGET_OSX) add_library_clr(dbgutil STATIC ${DBGUTIL_SOURCES}) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index ee3c1fb2b1b48..25c2532358774 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -31,14 +31,14 @@ else(CLR_CMAKE_HOST_WIN32) # Add dependency on export file add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE}) - if(CLR_CMAKE_HOST_APPLE OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_APPLE OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) - if(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_APPLE AND CLR_CMAKE_HOST_ARCH_ARM64) + if(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_OSX AND CLR_CMAKE_HOST_ARCH_ARM64) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) set(CMAKE_INSTALL_NAME_DIR "@rpath") - endif(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_APPLE AND CLR_CMAKE_HOST_ARCH_ARM64) + endif(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_OSX AND CLR_CMAKE_HOST_ARCH_ARM64) if(CLR_CMAKE_HOST_LINUX) diff --git a/src/coreclr/dlls/mscordbi/CMakeLists.txt b/src/coreclr/dlls/mscordbi/CMakeLists.txt index d026e09b9c377..95e92034e238f 100644 --- a/src/coreclr/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/dlls/mscordbi/CMakeLists.txt @@ -2,7 +2,7 @@ # Set the RPATH of mscordbi so that it can find dependencies without needing to set LD_LIBRARY_PATH # For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling. if(CORECLR_SET_RPATH) - if(CLR_CMAKE_HOST_APPLE) + if(CLR_CMAKE_HOST_OSX) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) set(CMAKE_INSTALL_NAME_DIR "@rpath") set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) @@ -10,7 +10,7 @@ if(CORECLR_SET_RPATH) else() set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN") - endif(CLR_CMAKE_HOST_APPLE) + endif(CLR_CMAKE_HOST_OSX) endif(CORECLR_SET_RPATH) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 08cff16606731..3a5de5794ef78 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -50,11 +50,11 @@ else(CLR_CMAKE_HOST_WIN32) set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) - if(CLR_CMAKE_TARGET_APPLE) + if(CLR_CMAKE_TARGET_OSX) # These options are used to force every object to be included even if it's unused. set(START_WHOLE_ARCHIVE -force_load) set(END_WHOLE_ARCHIVE ) - endif(CLR_CMAKE_TARGET_APPLE) + endif(CLR_CMAKE_TARGET_OSX) set_exports_linker_option(${EXPORTS_FILE}) @@ -167,7 +167,7 @@ if(FEATURE_MERGE_JIT_AND_ENGINE) set(CLRJIT_STATIC clrjit_static) endif(FEATURE_MERGE_JIT_AND_ENGINE) -if (CLR_CMAKE_TARGET_APPLE) +if (CLR_CMAKE_TARGET_OSX) include(CMakeFindFrameworks) find_library(FOUNDATION Foundation REQUIRED) endif() diff --git a/src/coreclr/gc/unix/configure.cmake b/src/coreclr/gc/unix/configure.cmake index 06dc8d305c653..7ed3e12211bfb 100644 --- a/src/coreclr/gc/unix/configure.cmake +++ b/src/coreclr/gc/unix/configure.cmake @@ -1,3 +1,13 @@ +include(CheckCXXSourceCompiles) +include(CheckCXXSourceRuns) +include(CheckCXXSymbolExists) +include(CheckFunctionExists) +include(CheckPrototypeDefinition) +include(CheckIncludeFiles) +include(CheckStructHasMember) +include(CheckTypeSize) +include(CheckLibraryExists) + check_include_files(sys/time.h HAVE_SYS_TIME_H) check_include_files(sys/mman.h HAVE_SYS_MMAN_H) check_include_files(numa.h HAVE_NUMA_H) diff --git a/src/coreclr/inc/crosscomp.h b/src/coreclr/inc/crosscomp.h index c89a7a35a40fa..7353e8cc6b770 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_APPLE +#ifdef TARGET_OSX #define MAKE_TARGET_DLLNAME_W(name) W("lib") name W(".dylib") #define MAKE_TARGET_DLLNAME_A(name) "lib" name ".dylib" #else @@ -547,18 +547,6 @@ typedef struct _T_KNONVOLATILE_CONTEXT_POINTERS { #define DAC_CS_NATIVE_DATA_SIZE 120 #elif defined(TARGET_OSX) && defined(TARGET_ARM64) #define DAC_CS_NATIVE_DATA_SIZE 120 -#elif defined(TARGET_MACCATALYST) && defined(TARGET_AMD64) -#define DAC_CS_NATIVE_DATA_SIZE 120 -#elif defined(TARGET_MACCATALYST) && defined(TARGET_ARM64) -#define DAC_CS_NATIVE_DATA_SIZE 120 -#elif defined(TARGET_IOS) && defined(TARGET_AMD64) -#define DAC_CS_NATIVE_DATA_SIZE 120 -#elif defined(TARGET_IOS) && defined(TARGET_ARM64) -#define DAC_CS_NATIVE_DATA_SIZE 120 -#elif defined(TARGET_TVOS) && defined(TARGET_AMD64) -#define DAC_CS_NATIVE_DATA_SIZE 120 -#elif defined(TARGET_TVOS) && defined(TARGET_ARM64) -#define DAC_CS_NATIVE_DATA_SIZE 120 #elif defined(TARGET_FREEBSD) && defined(TARGET_X86) #define DAC_CS_NATIVE_DATA_SIZE 12 #elif defined(TARGET_FREEBSD) && defined(TARGET_AMD64) diff --git a/src/coreclr/inc/executableallocator.h b/src/coreclr/inc/executableallocator.h index 6a45dcc8189cd..c229f5546aa7f 100644 --- a/src/coreclr/inc/executableallocator.h +++ b/src/coreclr/inc/executableallocator.h @@ -254,7 +254,7 @@ class ExecutableWriterHolder void Unmap() { -#if defined(HOST_APPLE) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) +#if defined(HOST_OSX) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) if (m_addressRX != NULL) { PAL_JitWriteProtect(false); @@ -290,7 +290,7 @@ class ExecutableWriterHolder ExecutableWriterHolder(T* addressRX, size_t size) { m_addressRX = addressRX; -#if defined(HOST_APPLE) && defined(HOST_ARM64) +#if defined(HOST_OSX) && defined(HOST_ARM64) m_addressRW = addressRX; PAL_JitWriteProtect(true); #else diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index eaa02c5a70ac6..88dcd4e8d77f7 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -2940,14 +2940,14 @@ VirtualFree( IN DWORD dwFreeType); -#if defined(HOST_APPLE) && defined(HOST_ARM64) +#if defined(HOST_OSX) && defined(HOST_ARM64) PALIMPORT VOID PALAPI PAL_JitWriteProtect(bool writeEnable); -#endif // defined(HOST_APPLE) && defined(HOST_ARM64) +#endif // defined(HOST_OSX) && defined(HOST_ARM64) PALIMPORT diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index df4b4b9dfe4e4..68a688be19c2a 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -1,7 +1,7 @@ -if(CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_FREEBSD) - # On Apple platforms and *BSD, we use the libunwind that's part of the OS +if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD) + # On OSX platforms and *BSD, we use the libunwind that's part of the OS set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) -endif(CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_FREEBSD) +endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD) if(NOT DEFINED ENV{ROOTFS_DIR}) include_directories(SYSTEM /usr/local/include) @@ -16,7 +16,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_APPLE) +elseif(NOT CLR_CMAKE_TARGET_OSX) find_unwind_libs(UNWIND_LIBS) else() add_subdirectory(${CLR_SRC_NATIVE_DIR}/external/libunwind_extras ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind) @@ -66,18 +66,8 @@ if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) add_definitions(-DFEATURE_USE_SYSTEM_LIBUNWIND) endif(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) -if(CLR_CMAKE_TARGET_APPLE) - add_definitions(-DTARGET_APPLE) - if(CLR_CMAKE_TARGET_OSX) - add_definitions(-DTARGET_OSX) - elseif(CLR_CMAKE_TARGET_MACCATALYST) - add_definitions(-DTARGET_MACCATALYST) - elseif(CLR_CMAKE_TARGET_IOS) - add_definitions(-DTARGET_IOS) - elseif(CLR_CMAKE_TARGET_TVOS) - add_definitions(-DTARGET_TVOS) - endif() - +if(CLR_CMAKE_TARGET_OSX) + add_definitions(-DTARGET_OSX) if(CLR_CMAKE_TARGET_ARCH_AMD64) add_definitions(-DXSTATE_SUPPORTED) endif() @@ -87,7 +77,7 @@ if(CLR_CMAKE_TARGET_APPLE) exception/machexception.cpp exception/machmessage.cpp ) -endif(CLR_CMAKE_TARGET_APPLE) +endif(CLR_CMAKE_TARGET_OSX) if (FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) add_definitions(-DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) @@ -119,12 +109,12 @@ set(ARCH_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/processor.cpp ) -if(NOT CLR_CMAKE_TARGET_APPLE) +if(NOT CLR_CMAKE_TARGET_OSX) list(APPEND PLATFORM_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/callsignalhandlerwrapper.S arch/${PAL_ARCH_SOURCES_DIR}/signalhandlerhelper.cpp ) -endif(NOT CLR_CMAKE_TARGET_APPLE) +endif(NOT CLR_CMAKE_TARGET_OSX) if(CLR_CMAKE_HOST_ARCH_ARM) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -277,7 +267,7 @@ if(CLR_CMAKE_TARGET_LINUX) target_sources(tracepointprovider INTERFACE $) endif(CLR_CMAKE_TARGET_LINUX) -if(CLR_CMAKE_TARGET_APPLE) +if(CLR_CMAKE_TARGET_OSX) find_library(COREFOUNDATION CoreFoundation) find_library(CORESERVICES CoreServices) find_library(SECURITY Security) @@ -288,7 +278,7 @@ if(CLR_CMAKE_TARGET_APPLE) ${SECURITY} ${SYSTEM} ) -endif(CLR_CMAKE_TARGET_APPLE) +endif(CLR_CMAKE_TARGET_OSX) if(CLR_CMAKE_TARGET_FREEBSD) target_link_libraries(coreclrpal diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake index a8979bbe51014..1ed51a42b252f 100644 --- a/src/coreclr/pal/src/configure.cmake +++ b/src/coreclr/pal/src/configure.cmake @@ -1307,10 +1307,8 @@ if(NOT CLR_CMAKE_HOST_ARCH_ARM AND NOT CLR_CMAKE_HOST_ARCH_ARM64) set(CMAKE_REQUIRED_LIBRARIES) endif() -if(CLR_CMAKE_TARGET_APPLE) - if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) - set(HAVE__NSGETENVIRON 1) - endif() +if(CLR_CMAKE_TARGET_OSX) + 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))") set(PAL_PT_ATTACH PT_ATTACH) @@ -1368,7 +1366,7 @@ else() # Anything else is Linux set(PAL_PT_WRITE_D PTRACE_POKEDATA) set(HAS_FTRUNCATE_LENGTH_ISSUE 0) set(HAVE_SCHED_OTHER_ASSIGNABLE 1) -endif(CLR_CMAKE_TARGET_APPLE) +endif(CLR_CMAKE_TARGET_OSX) check_struct_has_member( "struct statfs" diff --git a/src/coreclr/pal/src/exception/seh-unwind.cpp b/src/coreclr/pal/src/exception/seh-unwind.cpp index da1bcccf4e253..b3a4ca23726bb 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -54,8 +54,8 @@ Module Name: #endif // HOST_UNIX -#if defined(TARGET_APPLE) && defined(HOST_ARM64) -// Apple platforms use ARM64 instead of AARCH64 to describe these registers +#if defined(TARGET_OSX) && defined(HOST_ARM64) +// MacOS uses ARM64 instead of AARCH64 to describe these registers // Create aliases to reuse more code enum { @@ -96,7 +96,7 @@ enum UNW_AARCH64_V30 = UNW_ARM64_D30, UNW_AARCH64_V31 = UNW_ARM64_D31 }; -#endif // defined(TARGET_APPLE) && defined(HOST_ARM64) +#endif // defined(TARGET_OSX) && defined(HOST_ARM64) //---------------------------------------------------------------------- @@ -273,7 +273,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(TARGET_OSX) unwContext->uc_mcontext.pc = winContext->Pc; unwContext->uc_mcontext.sp = winContext->Sp; unwContext->uc_mcontext.regs[29] = winContext->Fp; @@ -315,7 +315,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(TARGET_OSX) // 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. @@ -439,12 +439,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(TARGET_OSX) && 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(TARGET_OSX) && 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/exception/signal.cpp b/src/coreclr/pal/src/exception/signal.cpp index 01615494bd296..7d299212db641 100644 --- a/src/coreclr/pal/src/exception/signal.cpp +++ b/src/coreclr/pal/src/exception/signal.cpp @@ -799,8 +799,8 @@ static void inject_activation_handler(int code, siginfo_t *siginfo, void *contex { // Only accept activations from the current process if (g_activationFunction != NULL && (siginfo->si_pid == getpid() -#ifdef HOST_APPLE - // On Apple platforms si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple +#ifdef HOST_OSX + // On OSX si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple // signals are in flight in the same process at the same time, it may be overwritten / zeroed. || siginfo->si_pid == 0 #endif diff --git a/src/coreclr/pal/src/include/pal/context.h b/src/coreclr/pal/src/include/pal/context.h index 21396afcdc191..425aea17e32c8 100644 --- a/src/coreclr/pal/src/include/pal/context.h +++ b/src/coreclr/pal/src/include/pal/context.h @@ -498,7 +498,7 @@ const struct fpregs* GetConstNativeSigSimdContext(const native_context_t *mc) return GetNativeSigSimdContext(const_cast(mc)); } -#elif !defined(TARGET_APPLE) // TARGET_FREEBSD +#elif !defined(TARGET_OSX) // TARGET_FREEBSD #define MCREG_X0(mc) ((mc).regs[0]) #define MCREG_X1(mc) ((mc).regs[1]) @@ -573,7 +573,7 @@ const fpsimd_context* GetConstNativeSigSimdContext(const native_context_t *mc) return GetNativeSigSimdContext(const_cast(mc)); } -#else // !defined(TARGET_APPLE) +#else // !defined(TARGET_OSX) #define MCREG_X0(mc) ((mc)->__ss.__x[0]) #define MCREG_X1(mc) ((mc)->__ss.__x[1]) @@ -623,7 +623,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex return GetNativeSigSimdContext(const_cast(mc)); } -#endif // !defined(TARGET_APPLE) +#endif // !defined(TARGET_OSX) #elif defined(HOST_LOONGARCH64) @@ -663,7 +663,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex #else // HOST_ARM64 -#if defined(TARGET_APPLE) +#if defined(TARGET_OSX) #define MCREG_Rbp(mc) ((mc)->__ss.__rbp) #define MCREG_Rip(mc) ((mc)->__ss.__rip) @@ -711,7 +711,7 @@ inline void *FPREG_Xstate_Ymmh(const ucontext_t *uc) return reinterpret_cast(&((_STRUCT_X86_AVX_STATE64&)FPSTATE(uc)).__fpu_ymmh0); } -#else // defined(TARGET_APPLE) +#else // defined(TARGET_OSX) // For FreeBSD, as found in x86/ucontext.h #define MCREG_Rbp(mc) ((mc).mc_rbp) @@ -748,7 +748,7 @@ inline void *FPREG_Xstate_Ymmh(const ucontext_t *uc) #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 // defined(TARGET_APPLE) +#endif // defined(TARGET_OSX) #endif // HOST_ARM64 #else // HOST_64BIT diff --git a/src/coreclr/pal/src/include/pal/mutex.hpp b/src/coreclr/pal/src/include/pal/mutex.hpp index d3f73f63b37da..464f0f72afb45 100644 --- a/src/coreclr/pal/src/include/pal/mutex.hpp +++ b/src/coreclr/pal/src/include/pal/mutex.hpp @@ -122,11 +122,11 @@ Miscellaneous // - On FreeBSD, pthread process-shared robust mutexes cannot be placed in shared memory mapped independently by the processes // involved. See https://github.com/dotnet/runtime/issues/10519. -// - On Apple platforms, pthread robust mutexes were/are not available at the time of this writing. In case they are made available in the +// - On OSX, pthread robust mutexes were/are not available at the time of this writing. In case they are made available in the // future, their use is disabled for compatibility. #if HAVE_FULLY_FEATURED_PTHREAD_MUTEXES && \ HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES && \ - !(defined(__FreeBSD__) || defined(TARGET_APPLE)) + !(defined(__FreeBSD__) || defined(TARGET_OSX)) #define NAMED_MUTEX_USE_PTHREAD_MUTEX 1 #else diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 892859211c104..aa9b30b5b960b 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -1287,12 +1287,9 @@ VirtualProtect( return bRetVal; } -#if defined(HOST_APPLE) && defined(HOST_ARM64) +#if defined(HOST_OSX) && defined(HOST_ARM64) PALAPI VOID PAL_JitWriteProtect(bool writeEnable) { -#if defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS) - RhFailFast(); // we don't expect to get here on these platforms -#elif defined(HOST_OSX) thread_local int enabledCount = 0; if (writeEnable) { @@ -1309,11 +1306,8 @@ PALAPI VOID PAL_JitWriteProtect(bool writeEnable) } _ASSERTE(enabledCount >= 0); } -#else - #error "Unknown OS" -#endif } -#endif // HOST_APPLE && HOST_ARM64 +#endif // HOST_OSX && HOST_ARM64 #if HAVE_VM_ALLOCATE //--------------------------------------------------------------------------------------- diff --git a/src/coreclr/pal/src/misc/sysinfo.cpp b/src/coreclr/pal/src/misc/sysinfo.cpp index 439a1dc7a9978..829100f0c53bb 100644 --- a/src/coreclr/pal/src/misc/sysinfo.cpp +++ b/src/coreclr/pal/src/misc/sysinfo.cpp @@ -66,12 +66,12 @@ Revision History: #include #endif // HAVE_MACHINE_VMPARAM_H -#if defined(TARGET_APPLE) +#if defined(TARGET_OSX) #include #include #include #include -#endif // defined(TARGET_APPLE) +#endif // defined(TARGET_OSX) // On some platforms sys/user.h ends up defining _DEBUG; if so // remove the definition before including the header and put @@ -583,7 +583,7 @@ PAL_GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_APPLE) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_OSX) if (cacheSize == 0) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info @@ -633,7 +633,7 @@ PAL_GetLogicalProcessorCacheSizeFromOS() } #endif -#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_APPLE) +#if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_OSX) if (cacheLevel != 3) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info diff --git a/src/coreclr/pal/src/thread/context.cpp b/src/coreclr/pal/src/thread/context.cpp index d1d050fde2dcd..a17c6c077da3b 100644 --- a/src/coreclr/pal/src/thread/context.cpp +++ b/src/coreclr/pal/src/thread/context.cpp @@ -618,7 +618,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 TARGET_OSX _STRUCT_ARM_NEON_STATE64* fp = GetNativeSigSimdContext(native); fp->__fpsr = lpContext->Fpsr; fp->__fpcr = lpContext->Fpcr; @@ -637,7 +637,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->fp_q[i] = lpContext->V[i]; } } -#else // TARGET_APPLE +#else // TARGET_OSX fpsimd_context* fp = GetNativeSigSimdContext(native); if (fp) { @@ -648,7 +648,7 @@ void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) *(NEON128*) &fp->vregs[i] = lpContext->V[i]; } } -#endif // TARGET_APPLE +#endif // TARGET_OSX #elif defined(HOST_ARM) VfpSigFrame* fp = GetNativeSigSimdContext(native); if (fp) @@ -780,7 +780,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 TARGET_OSX const _STRUCT_ARM_NEON_STATE64* fp = GetConstNativeSigSimdContext(native); lpContext->Fpsr = fp->__fpsr; lpContext->Fpcr = fp->__fpcr; @@ -799,7 +799,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->fp_q[i]; } } -#else // TARGET_APPLE +#else // TARGET_OSX const fpsimd_context* fp = GetConstNativeSigSimdContext(native); if (fp) { @@ -810,7 +810,7 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex lpContext->V[i] = *(NEON128*) &fp->vregs[i]; } } -#endif // TARGET_APPLE +#endif // TARGET_OSX #elif defined(HOST_ARM) const VfpSigFrame* fp = GetConstNativeSigSimdContext(native); if (fp) @@ -1655,10 +1655,6 @@ CONTEXT_SetThreadContext( #endif // !HAVE_MACH_EXCEPTIONS -#if (defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) -extern "C" void sys_icache_invalidate(const void* start, size_t len); -#endif - /*++ Function: DBG_FlushInstructionCache: processor-specific portion of @@ -1691,8 +1687,6 @@ DBG_FlushInstructionCache( __builtin___clear_cache((char *)begin, (char *)endOrNextPageBegin); begin = endOrNextPageBegin; } -#elif (defined(HOST_MACCATALYST) || defined(HOST_IOS) || defined(HOST_TVOS)) && defined(HOST_ARM64) - sys_icache_invalidate (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 a5725584cc8d0..5d2cafb0f3fda 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -2553,7 +2553,7 @@ FlushProcessWriteBuffers() status = pthread_mutex_unlock(&flushProcessWriteBuffersMutex); FATAL_ASSERT(status == 0, "Failed to unlock the flushProcessWriteBuffersMutex lock"); } -#ifdef TARGET_APPLE +#ifdef TARGET_OSX else { mach_msg_type_number_t cThreads; @@ -2567,27 +2567,9 @@ FlushProcessWriteBuffers() // Iterate through each of the threads in the list. for (mach_msg_type_number_t i = 0; i < cThreads; i++) { - if (__builtin_available (macOS 10.14, iOS 12, tvOS 9, *)) - { - // Request the threads pointer values to force the thread to emit a memory barrier - size_t registers = 128; - machret = thread_get_register_pointer_values(pThreads[i], &sp, ®isters, registerValues); - } - else - { - // fallback implementation for older OS versions -#if defined(HOST_AMD64) - x86_thread_state64_t threadState; - mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; - machret = thread_get_state(pThreads[i], x86_THREAD_STATE64, (thread_state_t)&threadState, &count); -#elif defined(HOST_ARM64) - arm_thread_state64_t threadState; - mach_msg_type_number_t count = ARM_THREAD_STATE64_COUNT; - machret = thread_get_state(pThreads[i], ARM_THREAD_STATE64, (thread_state_t)&threadState, &count); -#else - #error Unexpected architecture -#endif - } + // Request the threads pointer values to force the thread to emit a memory barrier + size_t registers = 128; + machret = thread_get_register_pointer_values(pThreads[i], &sp, ®isters, registerValues); if (machret == KERN_INSUFFICIENT_BUFFER_SIZE) { @@ -2601,7 +2583,7 @@ FlushProcessWriteBuffers() machret = vm_deallocate(mach_task_self(), (vm_address_t)pThreads, cThreads * sizeof(thread_act_t)); CHECK_MACH("vm_deallocate()", machret); } -#endif // TARGET_APPLE +#endif // TARGET_OSX } /*++ diff --git a/src/coreclr/pal/src/thread/thread.cpp b/src/coreclr/pal/src/thread/thread.cpp index 03bf05a9a5add..0daa011e6fc63 100644 --- a/src/coreclr/pal/src/thread/thread.cpp +++ b/src/coreclr/pal/src/thread/thread.cpp @@ -2596,8 +2596,8 @@ void * CPalThread::GetStackBase() { void* stackBase; -#ifdef TARGET_APPLE - // This is an Apple specific method +#ifdef TARGET_OSX + // This is a Mac specific method stackBase = pthread_get_stackaddr_np(pthread_self()); #else pthread_attr_t attr; @@ -2636,8 +2636,8 @@ void * CPalThread::GetStackLimit() { void* stackLimit; -#ifdef TARGET_APPLE - // This is an Apple specific method +#ifdef TARGET_OSX + // This is a Mac specific method stackLimit = ((BYTE *)pthread_get_stackaddr_np(pthread_self()) - pthread_get_stacksize_np(pthread_self())); #else diff --git a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt index 77101684beb2b..f9b5f0175caa3 100644 --- a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt @@ -5,12 +5,12 @@ endif(CLR_CMAKE_HOST_UNIX) # Set the RPATH of paltest_pal_sxs_test1 so that it can find dependencies without needing to set LD_LIBRARY # For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling. if(CORECLR_SET_RPATH) - if(CLR_CMAKE_HOST_APPLE) + if(CLR_CMAKE_HOST_OSX) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) set(CMAKE_INSTALL_NAME_DIR "@rpath") set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "@loader_path") - endif(CLR_CMAKE_HOST_APPLE) + endif(CLR_CMAKE_HOST_OSX) if(CLR_CMAKE_HOST_LINUX) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN") diff --git a/src/coreclr/utilcode/executableallocator.cpp b/src/coreclr/utilcode/executableallocator.cpp index 789b033535c1f..dbaf2f52ebac2 100644 --- a/src/coreclr/utilcode/executableallocator.cpp +++ b/src/coreclr/utilcode/executableallocator.cpp @@ -105,7 +105,7 @@ bool ExecutableAllocator::IsDoubleMappingEnabled() { LIMITED_METHOD_CONTRACT; -#if defined(HOST_APPLE) && defined(HOST_ARM64) +#if defined(HOST_OSX) && defined(HOST_ARM64) return false; #else return g_isWXorXEnabled; @@ -116,7 +116,7 @@ bool ExecutableAllocator::IsWXORXEnabled() { LIMITED_METHOD_CONTRACT; -#if defined(HOST_APPLE) && defined(HOST_ARM64) +#if defined(HOST_OSX) && defined(HOST_ARM64) return true; #else return g_isWXorXEnabled; From c28bfd19e41122a7b203f3eebe566afe93248bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 14 Feb 2023 17:39:21 +0100 Subject: [PATCH 09/14] Revert a few more changes --- src/coreclr/pal/src/CMakeLists.txt | 2 +- src/coreclr/pal/src/configure.cmake | 2 +- src/coreclr/pal/src/include/pal/context.h | 10 +++++----- src/coreclr/pal/src/thread/process.cpp | 5 ++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 68a688be19c2a..74fc5d3bc5cd5 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -1,5 +1,5 @@ if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD) - # On OSX platforms and *BSD, we use the libunwind that's part of the OS + # On OSX and *BSD, we use the libunwind that's part of the OS set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD) diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake index 1ed51a42b252f..114e88409c473 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_APPLE) +if(CLR_CMAKE_TARGET_OSX) 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") diff --git a/src/coreclr/pal/src/include/pal/context.h b/src/coreclr/pal/src/include/pal/context.h index 425aea17e32c8..c702ae272a76b 100644 --- a/src/coreclr/pal/src/include/pal/context.h +++ b/src/coreclr/pal/src/include/pal/context.h @@ -573,7 +573,7 @@ const fpsimd_context* GetConstNativeSigSimdContext(const native_context_t *mc) return GetNativeSigSimdContext(const_cast(mc)); } -#else // !defined(TARGET_OSX) +#else // TARGET_OSX #define MCREG_X0(mc) ((mc)->__ss.__x[0]) #define MCREG_X1(mc) ((mc)->__ss.__x[1]) @@ -623,7 +623,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex return GetNativeSigSimdContext(const_cast(mc)); } -#endif // !defined(TARGET_OSX) +#endif // TARGET_OSX #elif defined(HOST_LOONGARCH64) @@ -663,7 +663,7 @@ const _STRUCT_ARM_NEON_STATE64* GetConstNativeSigSimdContext(const native_contex #else // HOST_ARM64 -#if defined(TARGET_OSX) +#ifdef TARGET_OSX #define MCREG_Rbp(mc) ((mc)->__ss.__rbp) #define MCREG_Rip(mc) ((mc)->__ss.__rip) @@ -711,7 +711,7 @@ inline void *FPREG_Xstate_Ymmh(const ucontext_t *uc) return reinterpret_cast(&((_STRUCT_X86_AVX_STATE64&)FPSTATE(uc)).__fpu_ymmh0); } -#else // defined(TARGET_OSX) +#else //TARGET_OSX // For FreeBSD, as found in x86/ucontext.h #define MCREG_Rbp(mc) ((mc).mc_rbp) @@ -748,7 +748,7 @@ inline void *FPREG_Xstate_Ymmh(const ucontext_t *uc) #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 // defined(TARGET_OSX) +#endif // TARGET_OSX #endif // HOST_ARM64 #else // HOST_64BIT diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index 5d2cafb0f3fda..3f4402214959f 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -2473,7 +2473,7 @@ InitializeFlushProcessWriteBuffers() } } -#ifdef TARGET_APPLE +#ifdef TARGET_OSX return TRUE; #else s_helperPage = static_cast(mmap(0, GetVirtualPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); @@ -2503,7 +2503,7 @@ InitializeFlushProcessWriteBuffers() } return status == 0; -#endif // TARGET_APPLE +#endif // TARGET_OSX } #define FATAL_ASSERT(e, msg) \ @@ -2570,7 +2570,6 @@ FlushProcessWriteBuffers() // Request the threads pointer values to force the thread to emit a memory barrier size_t registers = 128; machret = thread_get_register_pointer_values(pThreads[i], &sp, ®isters, registerValues); - if (machret == KERN_INSUFFICIENT_BUFFER_SIZE) { CHECK_MACH("thread_get_register_pointer_values()", machret); From a403f62bd82bae5c67adea6d68e9466edb1f2c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 14 Feb 2023 17:43:03 +0100 Subject: [PATCH 10/14] Add a comment --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index 5658b2109ef24..258bcd499d40a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -52,6 +52,7 @@ - eng/native/configurecompiler.cmake - eng/native/build-commons.sh - src/native/libs/build-native.sh + - src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs - src/installer/pkg/sfx/bundle/shared-framework-distribution-template-x64.xml - src/installer/pkg/sfx/bundle/shared-framework-distribution-template-arm64.xml --> From 51cdabdab06be4e97f3136a3097aa87560fed392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 14 Feb 2023 18:13:10 +0100 Subject: [PATCH 11/14] Revert one more change --- src/native/corehost/apphost/standalone/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/apphost/standalone/CMakeLists.txt b/src/native/corehost/apphost/standalone/CMakeLists.txt index af19f493fd516..ecd5ca0ca3596 100644 --- a/src/native/corehost/apphost/standalone/CMakeLists.txt +++ b/src/native/corehost/apphost/standalone/CMakeLists.txt @@ -9,7 +9,7 @@ set(DOTNET_PROJECT_NAME "apphost") # dependencies is not possible for some reason. # This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way, # doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive. -if (NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if (NOT CLR_CMAKE_TARGET_OSX) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") endif() From 5970ec27540e84c41f1162fe57f5bc5987cd75fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 14 Feb 2023 19:41:19 +0100 Subject: [PATCH 12/14] Revert one more change --- src/coreclr/CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 597791a70b945..d759fce8b826e 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -126,15 +126,14 @@ add_subdirectory(pal/prebuilt/inc) set(EP_GENERATED_HEADER_PATH "${GENERATED_INCLUDE_DIR}") include (${CLR_SRC_NATIVE_DIR}/eventpipe/configure.cmake) - if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) add_subdirectory(debug/debug-pal) +endif() - add_subdirectory(minipal) +add_subdirectory(minipal) - if(CLR_CMAKE_TARGET_WIN32) - add_subdirectory(gc/sample) - endif() +if(CLR_CMAKE_TARGET_WIN32) + add_subdirectory(gc/sample) endif() #------------------------------------- From 44db39d914162c4d939eebeb964d70679c54f4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 15 Feb 2023 18:49:32 +0100 Subject: [PATCH 13/14] Fix TARGET vs HOST --- src/coreclr/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index d759fce8b826e..e7cd64d24922a 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -40,7 +40,7 @@ if(CORECLR_SET_RPATH) set(MACOSX_RPATH ON) endif(CORECLR_SET_RPATH) -if(CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS) set(FEATURE_EVENT_TRACE 0) endif() @@ -109,7 +109,7 @@ if(CLR_CMAKE_HOST_UNIX) endif() endif() - if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) add_subdirectory(pal) add_subdirectory(hosts) endif() @@ -126,7 +126,7 @@ add_subdirectory(pal/prebuilt/inc) set(EP_GENERATED_HEADER_PATH "${GENERATED_INCLUDE_DIR}") include (${CLR_SRC_NATIVE_DIR}/eventpipe/configure.cmake) -if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) add_subdirectory(debug/debug-pal) endif() @@ -242,7 +242,7 @@ if(CLR_CMAKE_HOST_UNIX) add_subdirectory(nativeresources) endif(CLR_CMAKE_HOST_UNIX) -if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) add_subdirectory(utilcode) add_subdirectory(inc) @@ -267,7 +267,7 @@ if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMA if(CLR_CMAKE_HOST_WIN32) add_subdirectory(hosts) endif(CLR_CMAKE_HOST_WIN32) -endif(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +endif(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) #---------------------------------------------------- # Cross target Component install configuration From 9f54bdaa8406625c9a55a1cb1d0ff1102b23936e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 15 Feb 2023 19:20:51 +0100 Subject: [PATCH 14/14] Simplify ICU fallback --- src/libraries/Common/src/Interop/Interop.ICU.iOS.cs | 5 +---- .../System/Globalization/GlobalizationMode.LoadICU.iOS.cs | 5 +---- src/native/libs/System.Globalization.Native/pal_icushim.h | 4 ---- .../System.Globalization.Native/pal_icushim_internal.h | 4 ++++ .../libs/System.Globalization.Native/pal_icushim_static.c | 8 ++++++++ 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs index b4c2955580464..6a20612dc47ee 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs @@ -9,9 +9,6 @@ internal static partial class Interop internal static partial class Globalization { [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICUData", StringMarshalling = StringMarshalling.Utf8)] - internal static partial int LoadICUData(string path); - - [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUDataPathFallback", StringMarshalling = StringMarshalling.Utf8)] - internal static partial string GetICUDataPathFallback(); + internal static partial int LoadICUData(string? path); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs index 68e832546f6af..cf3185101e608 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs @@ -7,10 +7,7 @@ internal static partial class GlobalizationMode { private static int LoadICU() { - // NativeAOT doesn't set ICU_DAT_FILE_PATH so we fallback to icudt.dat in the app bundle root in that case - string datPath = AppContext.GetData("ICU_DAT_FILE_PATH")?.ToString() ?? Interop.Globalization.GetICUDataPathFallback(); - - return Interop.Globalization.LoadICUData(datPath); + return Interop.Globalization.LoadICUData((string?)AppContext.GetData("ICU_DAT_FILE_PATH")); // we handle a null path in the native code } } } diff --git a/src/native/libs/System.Globalization.Native/pal_icushim.h b/src/native/libs/System.Globalization.Native/pal_icushim.h index d64b708eded18..51e117113de1c 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim.h @@ -15,8 +15,4 @@ PALEXPORT int32_t GlobalizationNative_LoadICUData(const char* path); PALEXPORT const char* GlobalizationNative_GetICUDTName(const char* culture); -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -PALEXPORT const char* GlobalizationNative_GetICUDataPathFallback(void); -#endif - #endif diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index e349b47f28802..77f7a82350e26 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -340,4 +340,8 @@ FOR_ALL_ICU_FUNCTIONS #define ucal_getWindowsTimeZoneID_ptr ucal_getWindowsTimeZoneID #define ucal_getTimeZoneIDForWindowsID_ptr ucal_getTimeZoneIDForWindowsID +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +const char* GlobalizationNative_GetICUDataPathFallback(void); +#endif + #endif // !defined(STATIC_ICU) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index cd57172b52329..ce64ca70dac5b 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -169,6 +169,14 @@ cstdlib_load_icu_data(const char *path) int32_t GlobalizationNative_LoadICUData(const char* path) { +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) + if (!path) + { + // fallback to icudt.dat in the app bundle root in case the path isn't set + path = GlobalizationNative_GetICUDataPathFallback(); + } +#endif + const char *icu_data = cstdlib_load_icu_data(path); if (icu_data == NULL)