diff --git a/Directory.Build.props b/Directory.Build.props index 5cc6f25e1d661e..6f490ba352110d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -34,6 +34,7 @@ arm64 loongarch64 s390x + ppc64le wasm x64 x64 diff --git a/eng/Subsets.props b/eng/Subsets.props index f967b3e50ec1e2..9c5dce125f4ae5 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -27,7 +27,7 @@ flavor is used to decide when to build the hosts and installers. --> CoreCLR - Mono + Mono diff --git a/eng/build.sh b/eng/build.sh index 167f8e2014182e..db83c1513e888a 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -17,7 +17,7 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" usage() { echo "Common settings:" - echo " --arch (-a) Target platform: x86, x64, arm, armv6, armel, arm64, loongarch64, s390x or wasm." + echo " --arch (-a) Target platform: x86, x64, arm, armv6, armel, arm64, loongarch64, s390x, ppc64le or wasm." echo " [Default: Your machine's architecture.]" echo " --binaryLog (-bl) Output binary log." echo " --cross Optional argument to signify cross compilation." @@ -206,12 +206,12 @@ while [[ $# > 0 ]]; do fi passedArch="$(echo "$2" | tr "[:upper:]" "[:lower:]")" case "$passedArch" in - x64|x86|arm|armv6|armel|arm64|loongarch64|s390x|wasm) + x64|x86|arm|armv6|armel|arm64|loongarch64|s390x|wasm|ppc64le) arch=$passedArch ;; *) echo "Unsupported target architecture '$2'." - echo "The allowed values are x86, x64, arm, armv6, armel, arm64, loongarch64, s390x, and wasm." + echo "The allowed values are x86, x64, arm, armv6, armel, arm64, loongarch64, s390x, ppc64le and wasm." exit 1 ;; esac diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh old mode 100755 new mode 100644 index ae802f4a04bc75..82d3bc5bcba41d --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -197,7 +197,7 @@ usage() echo "" echo "Common Options:" echo "" - echo "BuildArch can be: -arm, -armv6, -armel, -arm64, -loongarch64, -s390x, x64, x86, -wasm" + echo "BuildArch can be: -arm, -armv6, -armel, -arm64, -loongarch64, -s390x, -ppc64le, x64, x86, -wasm" echo "BuildType can be: -debug, -checked, -release" echo "-os: target OS (defaults to running OS)" echo "-bindir: output directory (defaults to $__ProjectRoot/artifacts)" @@ -388,6 +388,10 @@ while :; do __TargetArch=s390x ;; + ppc64le|-ppc64le) + __TargetArch=ppc64le + ;; + wasm|-wasm) __TargetArch=wasm ;; diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 60d2b2b80296f3..ac7a55b70ea60c 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -236,6 +236,9 @@ elseif (CLR_CMAKE_HOST_ARCH_WASM) elseif (CLR_CMAKE_HOST_ARCH_MIPS64) set(ARCH_HOST_NAME mips64) add_definitions(-DHOST_MIPS64 -DHOST_64BIT=1) +elseif (CLR_CMAKE_HOST_ARCH_POWERPC64) + set(ARCH_HOST_NAME ppc64le) + add_definitions(-DHOST_POWERPC64 -DHOST_64BIT) else () clr_unknown_arch() endif () @@ -256,6 +259,8 @@ if (CLR_CMAKE_HOST_UNIX) message("Detected Linux i686") elseif(CLR_CMAKE_HOST_UNIX_S390X) message("Detected Linux s390x") + elseif(CLR_CMAKE_HOST_UNIX_POWERPC64) + message("Detected Linux ppc64le") else() clr_unknown_arch() endif() @@ -332,6 +337,11 @@ elseif (CLR_CMAKE_TARGET_ARCH_S390X) set(ARCH_SOURCES_DIR s390x) add_compile_definitions($<$>>:TARGET_S390X>) add_compile_definitions($<$>>:TARGET_64BIT>) +elseif (CLR_CMAKE_TARGET_ARCH_POWERPC64) + set(ARCH_TARGET_NAME ppc64le) + set(ARCH_SOURCES_DIR ppc64le) + add_compile_definitions($<$>>:TARGET_POWERPC64>) + add_compile_definitions($<$>>:TARGET_64BIT>) elseif (CLR_CMAKE_TARGET_ARCH_WASM) set(ARCH_TARGET_NAME wasm) set(ARCH_SOURCES_DIR wasm) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 573d57f9ed0ddd..2e2902cc6339a9 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -51,6 +51,8 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux) set(CLR_CMAKE_HOST_UNIX_X86 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL s390x) set(CLR_CMAKE_HOST_UNIX_S390X 1) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le) + set(CLR_CMAKE_HOST_UNIX_POWERPC64 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL mips64) set(CLR_CMAKE_HOST_UNIX_MIPS64 1) else() @@ -250,6 +252,9 @@ elseif(CLR_CMAKE_HOST_UNIX_X86) elseif(CLR_CMAKE_HOST_UNIX_S390X) set(CLR_CMAKE_HOST_ARCH_S390X 1) set(CLR_CMAKE_HOST_ARCH "s390x") +elseif(CLR_CMAKE_HOST_UNIX_POWERPC64) + set(CLR_CMAKE_HOST_ARCH_POWERPC64 1) + set(CLR_CMAKE_HOST_ARCH "ppc64le") elseif(CLR_CMAKE_HOST_BROWSER) set(CLR_CMAKE_HOST_ARCH_WASM 1) set(CLR_CMAKE_HOST_ARCH "wasm") @@ -303,6 +308,8 @@ if (CLR_CMAKE_TARGET_ARCH STREQUAL x64) set(ARM_SOFTFP 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x) set(CLR_CMAKE_TARGET_ARCH_S390X 1) + elseif(CLR_CMAKE_TARGET_ARCH STREQUAL ppc64le) + set(CLR_CMAKE_TARGET_ARCH_POWERPC64 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm) set(CLR_CMAKE_TARGET_ARCH_WASM 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64) @@ -413,6 +420,8 @@ if(CLR_CMAKE_TARGET_UNIX) set(CLR_CMAKE_TARGET_UNIX_X86 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x) set(CLR_CMAKE_TARGET_UNIX_S390X 1) + elseif(CLR_CMAKE_TARGET_ARCH STREQUAL ppc64le) + set(CLR_CMAKE_TARGET_UNIX_POWERPC64 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm) set(CLR_CMAKE_TARGET_UNIX_WASM 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64) diff --git a/eng/native/configuretools.cmake b/eng/native/configuretools.cmake index 3437ce7cdae64a..6697524c6596ae 100644 --- a/eng/native/configuretools.cmake +++ b/eng/native/configuretools.cmake @@ -53,7 +53,7 @@ if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER) if(CLR_CMAKE_TARGET_ANDROID) set(TOOLSET_PREFIX ${ANDROID_TOOLCHAIN_PREFIX}) elseif(CMAKE_CROSSCOMPILING AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD AND - CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv8l|armv7l|armv6l|aarch64|arm|s390x)$") + CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv8l|armv7l|armv6l|aarch64|arm|s390x|ppc64le)$") set(TOOLSET_PREFIX "${TOOLCHAIN}-") else() set(TOOLSET_PREFIX "") diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index d5a28fec536b78..c7a884227f4966 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -175,6 +175,10 @@ function(find_unwind_libs UnwindLibs) find_library(UNWIND_ARCH NAMES unwind-s390x) endif() + if(CLR_CMAKE_HOST_ARCH_POWERPC64) + find_library(UNWIND_ARCH NAMES unwind-ppc64le) + endif() + if(NOT UNWIND_ARCH STREQUAL UNWIND_ARCH-NOTFOUND) set(UNWIND_LIBS ${UNWIND_ARCH}) endif() diff --git a/eng/native/init-os-and-arch.sh b/eng/native/init-os-and-arch.sh index 7a5815081ad2a8..8a0a6c88f9b279 100644 --- a/eng/native/init-os-and-arch.sh +++ b/eng/native/init-os-and-arch.sh @@ -65,6 +65,9 @@ case "$CPUName" in s390x) arch=s390x ;; + ppc64le) + arch=ppc64le + ;; *) echo "Unknown CPU $CPUName detected, configuring as if for x64" diff --git a/eng/native/tryrun.cmake b/eng/native/tryrun.cmake index fca410fcb4b42f..c491422ae7bcec 100644 --- a/eng/native/tryrun.cmake +++ b/eng/native/tryrun.cmake @@ -68,7 +68,7 @@ if(DARWIN) else() message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!") endif() -elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|s390x|x86)$" OR FREEBSD OR ILLUMOS) +elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|s390x|ppc64le|x86)$" OR FREEBSD OR ILLUMOS) set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1) set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 0) set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0) @@ -146,9 +146,9 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|s390x|x86)$ set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0) endif() else() - message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, armv6, arm64, loongarch64, s390x and x86 are supported!") + message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, armv6, arm64, loongarch64, s390x, ppc64le and x86 are supported!") endif() -if(TARGET_ARCH_NAME STREQUAL "x86" OR TARGET_ARCH_NAME STREQUAL "s390x" OR TARGET_ARCH_NAME STREQUAL "armv6" OR TARGET_ARCH_NAME STREQUAL "loongarch64") +if(TARGET_ARCH_NAME STREQUAL "x86" OR TARGET_ARCH_NAME STREQUAL "s390x" OR TARGET_ARCH_NAME STREQUAL "armv6" OR TARGET_ARCH_NAME STREQUAL "loongarch64" OR TARGET_ARCH_NAME STREQUAL "ppc64le") set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0) endif() diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 4bc1693e8dfb7c..1a83e1208c0645 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -48,6 +48,9 @@ function(create_standalone_jit) elseif(TARGETDETAILS_ARCH STREQUAL "s390x") set(JIT_ARCH_SOURCES ${JIT_S390X_SOURCES}) set(JIT_ARCH_HEADERS ${JIT_S390X_HEADERS}) + elseif(TARGETDETAILS_ARCH STREQUAL "ppc64le") + set(JIT_ARCH_SOURCES ${JIT_POWERPC64_SOURCES}) + set(JIT_ARCH_HEADERS ${JIT_POWERPC64_HEADERS}) elseif(TARGETDETAILS_ARCH STREQUAL "loongarch64") set(JIT_ARCH_SOURCES ${JIT_LOONGARCH64_SOURCES}) set(JIT_ARCH_HEADERS ${JIT_LOONGARCH64_HEADERS}) @@ -233,6 +236,10 @@ set( JIT_ARM64_SOURCES hwintrinsiccodegenarm64.cpp ) + +set( JIT_POWERPC64_SOURCES + # Not supported as JIT target +) set( JIT_ARMV6_SOURCES # Not supported as JIT target ) @@ -396,6 +403,9 @@ set ( JIT_S390X_HEADERS # Not supported as JIT target ) +set ( JIT_POWERPC64_HEADERS + # Not supported as JIT target +) set( JIT_LOONGARCH64_HEADERS emitloongarch64.h emitfmtsloongarch64.h @@ -442,6 +452,9 @@ elseif(CLR_CMAKE_TARGET_ARCH_ARM64) elseif(CLR_CMAKE_TARGET_ARCH_S390X) set(JIT_ARCH_SOURCES ${JIT_S390X_SOURCES}) set(JIT_ARCH_HEADERS ${JIT_S390X_HEADERS}) +elseif(CLR_CMAKE_TARGET_ARCH_POWERPC64) + set(JIT_ARCH_SOURCES ${JIT_POWERPC64_SOURCES}) + set(JIT_ARCH_HEADERS ${JIT_POWERPC64_HEADERS}) elseif(CLR_CMAKE_TARGET_ARCH_LOONGARCH64) set(JIT_ARCH_SOURCES ${JIT_LOONGARCH64_SOURCES}) set(JIT_ARCH_HEADERS ${JIT_LOONGARCH64_HEADERS}) @@ -600,13 +613,13 @@ if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX) endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX) if (CLR_CMAKE_TARGET_UNIX) - if (NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6) + if (NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6 AND NOT ARCH_TARGET_NAME STREQUAL ppc64le) if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64) install_clr(TARGETS clrjit_universal_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit) else() install_clr(TARGETS clrjit_unix_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit) endif() - endif(NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6) + endif(NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6 AND NOT ARCH_TARGET_NAME STREQUAL ppc64le) endif() if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_PGO_INSTRUMENT) diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 4e6509c88590ce..933333aba64a26 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -56,6 +56,8 @@ elseif(CLR_CMAKE_HOST_ARCH_I386) set(PAL_ARCH_SOURCES_DIR i386) elseif(CLR_CMAKE_HOST_ARCH_S390X) set(PAL_ARCH_SOURCES_DIR s390x) +elseif(CLR_CMAKE_HOST_ARCH_POWERPC64) + set(PAL_ARCH_SOURCES_DIR ppc64le) endif() if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) diff --git a/src/coreclr/pal/src/misc/perfjitdump.cpp b/src/coreclr/pal/src/misc/perfjitdump.cpp index f0c980a61efab7..df7e97af53087e 100644 --- a/src/coreclr/pal/src/misc/perfjitdump.cpp +++ b/src/coreclr/pal/src/misc/perfjitdump.cpp @@ -50,6 +50,8 @@ namespace ELF_MACHINE = EM_LOONGARCH, #elif defined(HOST_S390X) ELF_MACHINE = EM_S390, +#elif defined(HOST_POWERPC) + ELF_MACHINE = EM_PPC64, #else #error ELF_MACHINE unsupported for target #endif diff --git a/src/installer/pkg/projects/netcoreappRIDs.props b/src/installer/pkg/projects/netcoreappRIDs.props index 6282d87b88a92b..a3fc607664cf07 100644 --- a/src/installer/pkg/projects/netcoreappRIDs.props +++ b/src/installer/pkg/projects/netcoreappRIDs.props @@ -55,5 +55,12 @@ s390x + + ppc64le + + + ppc64le + + diff --git a/src/installer/pkg/sfx/installers/osx_scripts/host/postinstall b/src/installer/pkg/sfx/installers/osx_scripts/host/postinstall old mode 100755 new mode 100644 diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json index 5496b7d5da96d7..13eaeab1571e9d 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json @@ -4009,6 +4009,16 @@ "unix", "any", "base" + ], + "linux-musl-ppc64le": [ + "linux-musl-ppc64le", + "linux-musl", + "linux-ppc64le", + "linux", + "unix-ppc64le", + "unix", + "any", + "base" ], "linux-musl-x64": [ "linux-musl-x64", @@ -4038,6 +4048,14 @@ "any", "base" ], + "linux-ppc64le": [ + "linux-ppc64le", + "linux", + "unix-ppc64le", + "unix", + "any", + "base" + ], "linux-x64": [ "linux-x64", "linux", @@ -8598,6 +8616,12 @@ "any", "base" ], + "unix-ppc64le": [ + "unix-ppc64le", + "unix", + "any", + "base" + ], "unix-x64": [ "unix-x64", "unix", @@ -9240,4 +9264,5 @@ "any", "base" ] -} \ No newline at end of file +} + diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json index 0a4060093a1048..c0df5e08c03f1a 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json @@ -1591,6 +1591,12 @@ "linux-s390x" ] }, + "linux-musl-ppc64le": { + "#import": [ + "linux-musl", + "linux-ppc64le" + ] + }, "linux-musl-x64": { "#import": [ "linux-musl", @@ -1609,6 +1615,12 @@ "unix-s390x" ] }, + "linux-ppc64le": { + "#import": [ + "linux", + "unix-ppc64le" + ] + }, "linux-x64": { "#import": [ "linux", @@ -3577,6 +3589,11 @@ "unix" ] }, + "unix-ppc64le": { + "#import": [ + "unix" + ] + }, "unix-x64": { "#import": [ "unix" @@ -3911,4 +3928,4 @@ ] } } -} \ No newline at end of file +} diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props index 4e2cddd55a48bb..304212da753f01 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props @@ -3,15 +3,15 @@ any - x64;x86;arm;armv6;armel;arm64;loongarch64;mips64;s390x + x64;x86;arm;armv6;armel;arm64;loongarch64;mips64;s390x;ppc64le unix - x64;x86;arm;armv6;armel;arm64;loongarch64;mips64;s390x + x64;x86;arm;armv6;armel;arm64;loongarch64;mips64;s390x;ppc64le linux - x64;x86;arm;armel;arm64;s390x + x64;x86;arm;armel;arm64;s390x;ppc64le diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index b6c8e95fc10d20..3276b0d5eb51fe 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -17,7 +17,7 @@ true $(MSBuildThisFileDirectory)ILLink\ true - true + true true diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs index 4dead88ce4c92f..84be624da5af8e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs @@ -13,5 +13,6 @@ public enum Architecture S390x, LoongArch64, Armv6, + PowerPC64, } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs index 2d24563212bb56..530eb2652f164b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs @@ -68,6 +68,8 @@ public static Architecture ProcessArchitecture => Architecture.S390x; #elif TARGET_LOONGARCH64 => Architecture.LoongArch64; +#elif TARGET_POWERPC64 + => Architecture.PowerPC64; #else #error Unknown Architecture #endif diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs index 50fe5210c91ad5..463f15dfef865f 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs @@ -40,6 +40,10 @@ public void VerifyArchitecture() Assert.Equal(Architecture.S390x, processArch); break; + case Architecture.PowerPC64: + Assert.Equal(Architecture.PowerPC64, processArch); + break; + case Architecture.LoongArch64: Assert.Equal(Architecture.LoongArch64, processArch); break; diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index fce7cdf7c86c7c..f15dd3bbda1f2b 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -12124,6 +12124,7 @@ public enum Architecture S390x = 5, LoongArch64 = 6, Armv6 = 7, + POWERPC64 = 8, } public enum CharSet { diff --git a/src/libraries/externals.csproj b/src/libraries/externals.csproj index fc4a732a1adb39..c04b901ae622ca 100644 --- a/src/libraries/externals.csproj +++ b/src/libraries/externals.csproj @@ -9,7 +9,7 @@ true false true - true + true diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 344e383b58cf84..107fd2fd96a503 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -109,6 +109,12 @@ + + + + + + @@ -371,6 +377,10 @@ + + + + diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index b47e9288dd26d9..d04fc856f07328 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -375,6 +375,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") set(NO_UNALIGNED_ACCESS 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "s390x") set(HOST_S390X 1) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le") + set(HOST_POWERPC64 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "wasm" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "wasm32") set(HOST_WASM 1) else() @@ -444,14 +446,19 @@ elseif(TARGET_ARCH STREQUAL "s390x") set(MONO_ARCHITECTURE "\"s390x\"") set(TARGET_SIZEOF_VOID_P 8) set(SIZEOF_REGISTER 8) +elseif(TARGET_ARCH STREQUAL "ppc64le") + set(TARGET_POWERPC 1) + set(TARGET_POWERPC64 1) + set(MONO_ARCHITECTURE "\"ppc64le\"") + set(TARGET_SIZEOF_VOID_P 8) + set(SIZEOF_REGISTER 8) + add_definitions("-D__mono_ppc__") + add_definitions("-D__mono_ppc64__") elseif(TARGET_ARCH STREQUAL "wasm" OR TARGET_ARCH STREQUAL "wasm32") set(TARGET_WASM 1) set(MONO_ARCHITECTURE "\"wasm\"") set(TARGET_SIZEOF_VOID_P 4) set(SIZEOF_REGISTER 4) -elseif(TARGET_ARCH STREQUAL "ppc64le") - # TODO: not complete - set(__mono_ppc64__ 1) else() message(FATAL_ERROR "TARGET_ARCH='${TARGET_ARCH}' not supported.") endif() diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index 18ec40cc3ca0b2..1bfa4a34424e0a 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -10,7 +10,7 @@ $(RuntimeBinDir)IL/ Debug;Release;Checked - x64;x86;arm;armv6;arm64;s390x;wasm + x64;x86;arm;armv6;arm64;s390x;wasm;ppc64le true @@ -67,6 +67,10 @@ AnyCPU $(DefineConstants);TARGET_ARM64 + + AnyCPU + $(DefineConstants);TARGET_POWERPC64 + AnyCPU $(DefineConstants);TARGET_S390X diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 83c32e6df65cc5..0ee7e27eb61317 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -265,6 +265,13 @@ <_MonoBuildEnv Include="PKG_CONFIG_PATH=$(MonoCrossDir)/usr/lib/s390x-linux-gnu/pkgconfig" /> + + + <_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$(CrossToolchainFile)" /> + <_MonoBuildEnv Include="TARGET_BUILD_ARCH=ppc64le" /> + <_MonoBuildEnv Include="PKG_CONFIG_PATH=$(MonoCrossDir)/usr/lib/powerpc64le-linux-gnu/pkgconfig" /> + + <_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$(CrossToolchainFile)" /> @@ -543,6 +550,7 @@ <_Objcopy Condition="'$(Platform)' == 'armv6'">arm-linux-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy) <_Objcopy Condition="'$(Platform)' == 'arm64'">aarch64-linux-$(_LinuxAbi)-$(_Objcopy) <_Objcopy Condition="'$(Platform)' == 's390x'">s390x-linux-$(_LinuxAbi)-$(_Objcopy) + <_Objcopy Condition="'$(Platform)' == 'ppc64le'">ppc64le-linux-$(_LinuxAbi)-$(_Objcopy) <_Objcopy Condition="'$(Platform)' == 'x64'">x86_64-linux-$(_LinuxAbi)-$(_Objcopy) <_Objcopy Condition="'$(Platform)' == 'x86'">i686-linux-$(_LinuxAbi)-$(_Objcopy) <_Objcopy Condition="'$(TargetsAndroid)' == 'true'">$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/bin/llvm-objcopy diff --git a/src/mono/mono/arch/ppc/ppc-codegen.h b/src/mono/mono/arch/ppc/ppc-codegen.h index a52d17ab767f0c..ca3c13791ffda9 100644 --- a/src/mono/mono/arch/ppc/ppc-codegen.h +++ b/src/mono/mono/arch/ppc/ppc-codegen.h @@ -129,6 +129,7 @@ enum { #define ppc_is_imm16(val) ((((val)>> 15) == 0) || (((val)>> 15) == -1)) #define ppc_is_uimm16(val) ((glong)(val) >= 0L && (glong)(val) <= 65535L) #define ppc_ha(val) (((val >> 16) + ((val & 0x8000) ? 1 : 0)) & 0xffff) +#define ppc_is_dsoffset_valid(offset) (((offset)& 3) == 0) #define ppc_load32(c,D,v) G_STMT_START { \ ppc_lis ((c), (D), (guint32)(v) >> 16); \ diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index e09b23e4380eb9..8460037d7f8f9c 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -209,6 +209,13 @@ set(s390x_sources tramp-s390x.c cpu-s390x.h) +set(powerpc64_sources + mini-ppc.c + mini-ppc.h + exceptions-ppc.c + tramp-ppc.c + cpu-ppc64.h) + set(wasm_sources mini-wasm.c tramp-wasm.c @@ -226,6 +233,8 @@ elseif(TARGET_ARM) set(arch_sources ${arm_sources}) elseif(TARGET_S390X) set(arch_sources ${s390x_sources}) +elseif(TARGET_POWERPC) +set(arch_sources ${powerpc64_sources}) elseif(TARGET_WASM) set(arch_sources ${wasm_sources}) endif() @@ -468,6 +477,12 @@ add_custom_command( VERBATIM ) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cpu-ppc64.h + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/genmdesc.py TARGET_POWERPC ${CMAKE_CURRENT_SOURCE_DIR} cpu-ppc64.h ppc64_cpu_desc ${CMAKE_CURRENT_SOURCE_DIR}/cpu-ppc64.mdesc + VERBATIM +) + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cpu-wasm.h COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/genmdesc.py TARGET_WASM ${CMAKE_CURRENT_SOURCE_DIR} cpu-wasm.h wasm_desc ${CMAKE_CURRENT_SOURCE_DIR}/cpu-wasm.mdesc diff --git a/src/mono/mono/mini/mini-ppc.c b/src/mono/mono/mini/mini-ppc.c index a50ddc6b89cb9d..922092fac23399 100644 --- a/src/mono/mono/mini/mini-ppc.c +++ b/src/mono/mono/mini/mini-ppc.c @@ -1179,23 +1179,35 @@ get_call_info (MonoMethodSignature *sig) } else #endif { - align_size += (sizeof (target_mgreg_t) - 1); - align_size &= ~(sizeof (target_mgreg_t) - 1); - nregs = (align_size + sizeof (target_mgreg_t) -1 ) / sizeof (target_mgreg_t); - n_in_regs = MIN (rest, nregs); - if (n_in_regs < 0) - n_in_regs = 0; + if (is_all_floats && (mbr_cnt > 0)) { + rest = PPC_LAST_ARG_REG - gr + 1; + nregs = mbr_cnt; + n_in_regs = (rest >= mbr_cnt) ? MIN (rest, nregs) : 0; + cinfo->args [n].regtype = RegTypeStructByVal; + cinfo->args [n].vtregs = n_in_regs; + cinfo->args [n].size = mbr_size; + cinfo->args [n].vtsize = nregs - n_in_regs; + cinfo->args [n].reg = gr; + gr += n_in_regs; + } else { + align_size += (sizeof (target_mgreg_t) - 1); + align_size &= ~(sizeof (target_mgreg_t) - 1); + nregs = (align_size + sizeof (target_mgreg_t) -1 ) / sizeof (target_mgreg_t); + n_in_regs = MIN (rest, nregs); + if (n_in_regs < 0) + n_in_regs = 0; #ifdef __APPLE__ - /* FIXME: check this */ - if (size >= 3 && size % 4 != 0) - n_in_regs = 0; + /* FIXME: check this */ + if (size >= 3 && size % 4 != 0) + n_in_regs = 0; #endif - cinfo->args [n].regtype = RegTypeStructByVal; - cinfo->args [n].vtregs = n_in_regs; - cinfo->args [n].size = n_in_regs; - cinfo->args [n].vtsize = nregs - n_in_regs; - cinfo->args [n].reg = gr; - gr += n_in_regs; + cinfo->args [n].regtype = RegTypeStructByVal; + cinfo->args [n].vtregs = n_in_regs; + cinfo->args [n].size = n_in_regs; + cinfo->args [n].vtsize = nregs - n_in_regs; + cinfo->args [n].reg = gr; + gr += n_in_regs; + } } #ifdef __mono_ppc64__ @@ -1824,7 +1836,7 @@ void mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val) { MonoType *ret = mini_get_underlying_type (mono_method_signature_internal (method)->ret); - if (!rm_type_is_byref (ret)) { + if (!m_type_is_byref (ret)) { #ifndef __mono_ppc64__ if (ret->type == MONO_TYPE_I8 || ret->type == MONO_TYPE_U8) { MonoInst *ins; @@ -1963,7 +1975,7 @@ mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb) MONO_DELETE_INS (bb, ins); continue; } - } else if (inst->inst_imm > 0) { + } else if (ins->inst_imm > 0) { int power2 = mono_is_power_of_two (ins->inst_imm); if (power2 > 0) { ins->opcode = OP_SHL_IMM; @@ -3116,7 +3128,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; case OP_STORE_MEMBASE_REG: if (ppc_is_imm16 (ins->inst_offset)) { - ppc_stptr (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg); + if (ppc_is_dsoffset_valid(ins->inst_offset)) { + ppc_stptr (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg); + } else { + ppc_load (code, ppc_r0, ins->inst_offset); + ppc_stptr_indexed(code, ins->sreg1, ins->inst_destbasereg, ppc_r0); + } } else { if (ppc_is_imm32 (ins->inst_offset)) { ppc_addis (code, ppc_r11, ins->inst_destbasereg, ppc_ha(ins->inst_offset)); @@ -3151,7 +3168,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; case OP_LOAD_MEMBASE: if (ppc_is_imm16 (ins->inst_offset)) { - ppc_ldptr (code, ins->dreg, ins->inst_offset, ins->inst_basereg); + if( ppc_is_dsoffset_valid (ins->inst_offset)) { + ppc_ldptr (code, ins->dreg, ins->inst_offset, ins->inst_basereg); + } else { + ppc_load (code, ppc_r0, ins->inst_offset); + ppc_ldptr_indexed (code, ins->dreg, ins->inst_basereg, ppc_r0); + } } else { if (ppc_is_imm32 (ins->inst_offset) && (ins->dreg > 0)) { ppc_addis (code, ins->dreg, ins->inst_basereg, ppc_ha(ins->inst_offset)); @@ -3165,7 +3187,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_LOADI4_MEMBASE: #ifdef __mono_ppc64__ if (ppc_is_imm16 (ins->inst_offset)) { - ppc_lwa (code, ins->dreg, ins->inst_offset, ins->inst_basereg); + if(ppc_is_dsoffset_valid (ins->inst_offset)) { + ppc_lwa (code, ins->dreg, ins->inst_offset, ins->inst_basereg); + } else { + ppc_load (code, ppc_r0, ins->inst_offset); + ppc_lwax (code, ins->dreg, ins->inst_basereg, ppc_r0); + } } else { if (ppc_is_imm32 (ins->inst_offset) && (ins->dreg > 0)) { ppc_addis (code, ins->dreg, ins->inst_basereg, ppc_ha(ins->inst_offset)); @@ -5309,6 +5336,10 @@ exception_id_by_name (const char *name) return MONO_EXC_ARRAY_TYPE_MISMATCH; if (strcmp (name, "ArgumentException") == 0) return MONO_EXC_ARGUMENT; + if (strcmp (name, "ArgumentOutOfRangeException") == 0) + return MONO_EXC_ARGUMENT_OUT_OF_RANGE; + if (strcmp (name, "OutOfMemoryException") == 0) + return MONO_EXC_ARGUMENT_OUT_OF_MEMORY; g_error ("Unknown intrinsic exception %s\n", name); return 0; } @@ -5753,7 +5784,7 @@ host_mgreg_t* mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg) { if (reg == ppc_r1) - return (host_mgreg_t)(gsize)&MONO_CONTEXT_GET_SP (ctx); + return (host_mgreg_t)(gsize)MONO_CONTEXT_GET_SP (ctx); return &ctx->regs [reg]; } diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index d0a01e77935507..d2244c675c0628 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -219,6 +219,8 @@ elseif(TARGET_ARM) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-arm.c") elseif(TARGET_S390X) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-s390x.c") +elseif(TARGET_POWERPC) +set(utils_arch_sources "${utils_arch_sources};mono-hwcap-ppc.c") elseif(TARGET_WASM) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-wasm.c;mono-mmap-wasm.c") else() diff --git a/src/native/corehost/hostmisc/utils.cpp b/src/native/corehost/hostmisc/utils.cpp index 977d3d0e4d53d7..8855d66e4bc04c 100644 --- a/src/native/corehost/hostmisc/utils.cpp +++ b/src/native/corehost/hostmisc/utils.cpp @@ -210,6 +210,8 @@ const pal::char_t* get_arch() return _X("loongarch64"); #elif defined(TARGET_S390X) return _X("s390x"); +#elif defined(TARGET_POWERPC64) + return _X("ppc64le"); #else #error "Unknown target" #endif diff --git a/src/native/eventpipe/ep-event-source.c b/src/native/eventpipe/ep-event-source.c index 2b631205116e7e..5fd07ab77ebd0a 100644 --- a/src/native/eventpipe/ep-event-source.c +++ b/src/native/eventpipe/ep-event-source.c @@ -44,6 +44,8 @@ const ep_char8_t* _ep_arch_info = "arm64"; const ep_char8_t* _ep_arch_info = "s390x"; #elif defined(TARGET_LOONGARCH64) const ep_char8_t* _ep_arch_info = "loongarch64"; +#elif defined(TARGET_POWERPC64) +const ep_char8_t* _ep_arch_info = "ppc64le"; #else const ep_char8_t* _ep_arch_info = "Unknown"; #endif