Skip to content

Commit

Permalink
[LoongArch64] add all the coreclr-build-config files (#62889)
Browse files Browse the repository at this point in the history
  • Loading branch information
shushanhf authored Jan 14, 2022
1 parent 1ba80f6 commit b7e0a85
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 18 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'arm'">arm</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'armel'">armel</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'arm64'">arm64</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'loongarch64'">loongarch64</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 's390x'">s390x</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(TargetOS)' == 'Browser'">wasm</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(TargetsMobile)' == 'true'">x64</TargetArchitecture>
Expand Down
6 changes: 3 additions & 3 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
usage()
{
echo "Common settings:"
echo " --arch (-a) Target platform: x86, x64, arm, armel, arm64, s390x or wasm."
echo " --arch (-a) Target platform: x86, x64, arm, armel, arm64, loongarch64, s390x or wasm."
echo " [Default: Your machine's architecture.]"
echo " --binaryLog (-bl) Output binary log."
echo " --cross Optional argument to signify cross compilation."
Expand Down Expand Up @@ -206,12 +206,12 @@ while [[ $# > 0 ]]; do
fi
passedArch="$(echo "$2" | tr "[:upper:]" "[:lower:]")"
case "$passedArch" in
x64|x86|arm|armel|arm64|s390x|wasm)
x64|x86|arm|armel|arm64|loongarch64|s390x|wasm)
arch=$passedArch
;;
*)
echo "Unsupported target architecture '$2'."
echo "The allowed values are x86, x64, arm, armel, arm64, s390x, and wasm."
echo "The allowed values are x86, x64, arm, armel, arm64, loongarch64, s390x, and wasm."
exit 1
;;
esac
Expand Down
6 changes: 5 additions & 1 deletion eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ usage()
echo ""
echo "Common Options:"
echo ""
echo "BuildArch can be: -arm, -armel, -arm64, -s390x, x64, x86, -wasm"
echo "BuildArch can be: -arm, -armel, -arm64, -loongarch64, -s390x, 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)"
Expand Down Expand Up @@ -377,6 +377,10 @@ while :; do
__BuildArch=x64
;;

loongarch64|-loongarch64)
__BuildArch=loongarch64
;;

s390x|-s390x)
__BuildArch=s390x
;;
Expand Down
10 changes: 10 additions & 0 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ elseif (CLR_CMAKE_HOST_ARCH_ARM)
elseif (CLR_CMAKE_HOST_ARCH_ARM64)
set(ARCH_HOST_NAME arm64)
add_definitions(-DHOST_ARM64 -DHOST_64BIT)
elseif (CLR_CMAKE_HOST_ARCH_LOONGARCH64)
set(ARCH_HOST_NAME loongarch64)
add_definitions(-DHOST_LOONGARCH64 -DHOST_64BIT)
elseif (CLR_CMAKE_HOST_ARCH_S390X)
set(ARCH_HOST_NAME s390x)
add_definitions(-DHOST_S390X -DHOST_64BIT -DBIGENDIAN)
Expand All @@ -237,6 +240,8 @@ if (CLR_CMAKE_HOST_UNIX)
message("Detected Linux ARM")
elseif(CLR_CMAKE_HOST_UNIX_ARM64)
message("Detected Linux ARM64")
elseif(CLR_CMAKE_HOST_UNIX_LOONGARCH64)
message("Detected Linux LOONGARCH64")
elseif(CLR_CMAKE_HOST_UNIX_X86)
message("Detected Linux i686")
elseif(CLR_CMAKE_HOST_UNIX_S390X)
Expand Down Expand Up @@ -301,6 +306,11 @@ elseif (CLR_CMAKE_TARGET_ARCH_I386)
set(ARCH_SOURCES_DIR i386)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_X86>)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_32BIT>)
elseif (CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
set(ARCH_TARGET_NAME loongarch64)
set(ARCH_SOURCES_DIR loongarch64)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_LOONGARCH64>)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>)
elseif (CLR_CMAKE_TARGET_ARCH_S390X)
set(ARCH_TARGET_NAME s390x)
set(ARCH_SOURCES_DIR s390x)
Expand Down
9 changes: 9 additions & 0 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux)
set(CLR_CMAKE_HOST_UNIX_ARM 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
set(CLR_CMAKE_HOST_UNIX_ARM64 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL loongarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL loongarch64)
set(CLR_CMAKE_HOST_UNIX_LOONGARCH64 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686 OR CMAKE_SYSTEM_PROCESSOR STREQUAL x86)
set(CLR_CMAKE_HOST_UNIX_X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL s390x)
Expand Down Expand Up @@ -218,6 +220,9 @@ if(CLR_CMAKE_HOST_UNIX_ARM)
elseif(CLR_CMAKE_HOST_UNIX_ARM64)
set(CLR_CMAKE_HOST_ARCH_ARM64 1)
set(CLR_CMAKE_HOST_ARCH "arm64")
elseif(CLR_CMAKE_HOST_UNIX_LOONGARCH64)
set(CLR_CMAKE_HOST_ARCH_LOONGARCH64 1)
set(CLR_CMAKE_HOST_ARCH "loongarch64")
elseif(CLR_CMAKE_HOST_UNIX_AMD64)
set(CLR_CMAKE_HOST_ARCH_AMD64 1)
set(CLR_CMAKE_HOST_ARCH "x64")
Expand Down Expand Up @@ -268,6 +273,8 @@ if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
set(CLR_CMAKE_TARGET_ARCH_I386 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
set(CLR_CMAKE_TARGET_ARCH_ARM64 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL loongarch64)
set(CLR_CMAKE_TARGET_ARCH_LOONGARCH64 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
set(CLR_CMAKE_TARGET_ARCH_ARM 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armel)
Expand Down Expand Up @@ -374,6 +381,8 @@ if(CLR_CMAKE_TARGET_UNIX)
set(CLR_CMAKE_TARGET_UNIX_ARM 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
set(CLR_CMAKE_TARGET_UNIX_ARM64 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL loongarch64)
set(CLR_CMAKE_TARGET_UNIX_LOONGARCH64 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
set(CLR_CMAKE_TARGET_UNIX_X86 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x)
Expand Down
6 changes: 5 additions & 1 deletion eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function(clr_unknown_arch)
elseif(CLR_CROSS_COMPONENTS_BUILD)
message(FATAL_ERROR "Only AMD64, I386 host are supported for linux cross-architecture component. Found: ${CMAKE_SYSTEM_PROCESSOR}")
else()
message(FATAL_ERROR "Only AMD64, ARM64 and ARM are supported. Found: ${CMAKE_SYSTEM_PROCESSOR}")
message(FATAL_ERROR "Only AMD64, ARM64, LOONGARCH64 and ARM are supported. Found: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
endfunction()

Expand Down Expand Up @@ -94,6 +94,10 @@ function(find_unwind_libs UnwindLibs)
find_library(UNWIND_ARCH NAMES unwind-aarch64)
endif()

if(CLR_CMAKE_HOST_ARCH_LOONGARCH64)
find_library(UNWIND_ARCH NAMES unwind-loongarch64)
endif()

if(CLR_CMAKE_HOST_ARCH_AMD64)
find_library(UNWIND_ARCH NAMES unwind-x86_64)
endif()
Expand Down
4 changes: 4 additions & 0 deletions eng/native/init-os-and-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ case "$CPUName" in
arch=arm64
;;

loongarch64)
arch=loongarch64
;;

amd64|x86_64)
arch=x64
;;
Expand Down
6 changes: 3 additions & 3 deletions eng/native/tryrun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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|arm64|s390x|x86)$" OR FREEBSD OR ILLUMOS)
elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|loongarch64|s390x|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)
Expand Down Expand Up @@ -146,9 +146,9 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|s390x|x86)$" OR FREEBSD OR IL
set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
endif()
else()
message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64, s390x and x86 are supported!")
message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64, loongarch64, s390x and x86 are supported!")
endif()

if(TARGET_ARCH_NAME STREQUAL "x86" OR TARGET_ARCH_NAME STREQUAL "s390x")
if(TARGET_ARCH_NAME STREQUAL "x86" OR TARGET_ARCH_NAME STREQUAL "s390x" OR TARGET_ARCH_NAME STREQUAL "loongarch64")
set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
endif()
2 changes: 1 addition & 1 deletion eng/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ usage()
echo " default: Debug"
echo " --os <os> OS to run (FreeBSD, Linux, NetBSD, illumos or Solaris)"
echo " default: detect current OS"
echo " --arch <Architecture> Architecture to run (x64, arm, armel, x86, arm64)"
echo " --arch <Architecture> Architecture to run (x64, arm, armel, x86, arm64, loongarch64)"
echo " default: detect current architecture"
echo
echo "Execution options:"
Expand Down
6 changes: 3 additions & 3 deletions eng/targetingpacks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
LatestRuntimeFrameworkVersion="$(ProductVersion)"
RuntimeFrameworkName="$(LocalFrameworkOverrideName)"
RuntimePackNamePatterns="$(LocalFrameworkOverrideName).Runtime.**RID**"
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64"
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-loongarch64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64"
TargetFramework="$(NetCoreAppCurrent)"
TargetingPackName="$(LocalFrameworkOverrideName).Ref"
TargetingPackVersion="$(ProductVersion)"
Expand All @@ -43,13 +43,13 @@
RuntimeFrameworkName="$(LocalFrameworkOverrideName)"
LatestRuntimeFrameworkVersion="$(ProductVersion)"
RuntimePackNamePatterns="$(LocalFrameworkOverrideName).Runtime.Mono.**RID**"
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;browser-wasm;ios-arm64;ios-arm;iossimulator-arm64;iossimulator-x64;iossimulator-x86;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86"
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-loongarch64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;browser-wasm;ios-arm64;ios-arm;iossimulator-arm64;iossimulator-x64;iossimulator-x86;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86"
RuntimePackLabels="Mono"
Condition="'@(KnownRuntimePack)' == '' or !@(KnownRuntimePack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))"/>
<KnownAppHostPack Include="$(LocalFrameworkOverrideName)"
AppHostPackNamePattern="$(LocalFrameworkOverrideName).Host.**RID**"
AppHostPackVersion="$([MSBuild]::ValueOrDefault('$(_AppHostBaselinePackVersion)', '$(ProductVersion)'))"
AppHostRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64"
AppHostRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-loongarch64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64"
TargetFramework="$(NetCoreAppCurrent)"
Condition="'@(KnownAppHostPack)' == '' or !@(KnownAppHostPack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))" />
<KnownCrossgen2Pack Include="$(LocalFrameworkOverrideName).Crossgen2"
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/build-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ build_cross_architecture_components()
__SkipCrossArchBuild=0
elif [[ "$__BuildArch" == "arm64" && "$__CrossArch" == "x64" ]]; then
__SkipCrossArchBuild=0
elif [[ "$__BuildArch" == "loongarch64" && "$__CrossArch" == "x64" ]]; then
__SkipCrossArchBuild=0
else
# not supported
return
Expand Down
13 changes: 9 additions & 4 deletions src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ if (CLR_CMAKE_TARGET_ARCH_AMD64)
add_definitions(-DUNIX_AMD64_ABI_ITF)
endif (CLR_CMAKE_TARGET_ARCH_AMD64)
add_definitions(-DFEATURE_USE_ASM_GC_WRITE_BARRIERS)
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
add_definitions(-DFEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP)
endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
add_definitions(-DFEATURE_MANUALLY_MANAGED_CARD_BUNDLES)
endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_LOONGARCH64)

if(NOT CLR_CMAKE_TARGET_UNIX)
add_definitions(-DFEATURE_WIN32_REGISTRY)
Expand Down Expand Up @@ -240,6 +240,7 @@ function(set_target_definitions_to_custom_os_and_arch)
elseif (TARGETDETAILS_ARCH STREQUAL "x86")
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE UNIX_X86_ABI)
elseif (TARGETDETAILS_ARCH STREQUAL "arm64")
elseif (TARGETDETAILS_ARCH STREQUAL "loongarch64")
endif()
if ((TARGETDETAILS_ARCH STREQUAL "arm64") AND (TARGETDETAILS_OS STREQUAL "unix_osx"))
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE OSX_ARM64_ABI)
Expand All @@ -260,6 +261,10 @@ function(set_target_definitions_to_custom_os_and_arch)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_64BIT)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_ARM64)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_MULTIREG_RETURN)
elseif(TARGETDETAILS_ARCH STREQUAL "loongarch64")
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_64BIT)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_LOONGARCH64)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_MULTIREG_RETURN)
elseif((TARGETDETAILS_ARCH STREQUAL "arm") OR (TARGETDETAILS_ARCH STREQUAL "armel"))
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_ARM)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ else(CLR_CMAKE_HOST_WIN32)

set(REDEFINES_FILE_SCRIPT ${CMAKE_SOURCE_DIR}/generateredefinesfile.sh)

if (CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64)
if (CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64 OR CLR_CMAKE_HOST_ARCH_LOONGARCH64)
set(JUMP_INSTRUCTION b)
else()
set(JUMP_INSTRUCTION jmp)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/inc/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#if defined(TARGET_X86) || defined(TARGET_ARM)
#define USE_LAZY_PREFERRED_RANGE 0

#elif defined(TARGET_AMD64) || defined(TARGET_ARM64) || defined(TARGET_S390X)
#elif defined(TARGET_AMD64) || defined(TARGET_ARM64) || defined(TARGET_S390X) || defined(TARGET_LOONGARCH64)

#if defined(HOST_UNIX)
// In PAL we have a smechanism that reserves memory on start up that is
Expand Down

0 comments on commit b7e0a85

Please sign in to comment.