Build support for s390x: eng scripts (#52840)
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 18 May 2021 12:48:38 +0000 (14:48 +0200)
committerGitHub <noreply@github.com>
Tue, 18 May 2021 12:48:38 +0000 (14:48 +0200)
Add support for Linux on s390x as host and target build architecture.

eng/build.sh
eng/native/build-commons.sh
eng/native/configurecompiler.cmake
eng/native/configureplatform.cmake
eng/native/configuretools.cmake
eng/native/init-os-and-arch.sh
eng/native/tryrun.cmake

index 355b7c3..128e720 100755 (executable)
@@ -17,7 +17,7 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
 usage()
 {
   echo "Common settings:"
-  echo "  --arch (-a)                     Target platform: x86, x64, arm, armel, arm64 or wasm."
+  echo "  --arch (-a)                     Target platform: x86, x64, arm, armel, arm64, s390x 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|armel|arm64|wasm)
+        x64|x86|arm|armel|arm64|s390x|wasm)
           arch=$passedArch
           ;;
         *)
           echo "Unsupported target architecture '$2'."
-          echo "The allowed values are x86, x64, arm, armel, arm64, and wasm."
+          echo "The allowed values are x86, x64, arm, armel, arm64, s390x, and wasm."
           exit 1
           ;;
       esac
index d568f9b..9bb323c 100755 (executable)
@@ -433,6 +433,10 @@ while :; do
             __BuildArch=x64
             ;;
 
+        s390x|-s390x)
+            __BuildArch=s390x
+            ;;
+
         wasm|-wasm)
             __BuildArch=wasm
             ;;
index 39b7bfc..9a6832c 100644 (file)
@@ -208,6 +208,10 @@ elseif (CLR_CMAKE_HOST_ARCH_ARM64)
   set(ARCH_HOST_NAME arm64)
   add_definitions(-DHOST_ARM64)
   add_definitions(-DHOST_64BIT)
+elseif (CLR_CMAKE_HOST_ARCH_S390X)
+  set(ARCH_HOST_NAME s390x)
+  add_definitions(-DHOST_S390X)
+  add_definitions(-DHOST_64BIT)
 else ()
   clr_unknown_arch()
 endif ()
@@ -222,6 +226,8 @@ if (CLR_CMAKE_HOST_UNIX)
       message("Detected Linux ARM64")
     elseif(CLR_CMAKE_HOST_UNIX_X86)
       message("Detected Linux i686")
+    elseif(CLR_CMAKE_HOST_UNIX_S390X)
+      message("Detected Linux s390x")
     else()
       clr_unknown_arch()
     endif()
@@ -277,6 +283,11 @@ elseif (CLR_CMAKE_TARGET_ARCH_I386)
     set(ARCH_TARGET_NAME x86)
     set(ARCH_SOURCES_DIR i386)
     add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_X86>)
+elseif (CLR_CMAKE_TARGET_ARCH_S390X)
+    set(ARCH_TARGET_NAME s390x)
+    set(ARCH_SOURCES_DIR s390x)
+    add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_S390X>)
+    add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>)
 else ()
     clr_unknown_arch()
 endif ()
index a942fb0..5194317 100644 (file)
@@ -45,6 +45,8 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux)
             set(CLR_CMAKE_HOST_UNIX_ARM64 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)
+            set(CLR_CMAKE_HOST_UNIX_S390X 1)
         else()
             clr_unknown_arch()
         endif()
@@ -221,6 +223,9 @@ elseif(CLR_CMAKE_HOST_UNIX_AMD64)
 elseif(CLR_CMAKE_HOST_UNIX_X86)
     set(CLR_CMAKE_HOST_ARCH_I386 1)
     set(CLR_CMAKE_HOST_ARCH "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_WASM)
     set(CLR_CMAKE_HOST_ARCH_WASM 1)
     set(CLR_CMAKE_HOST_ARCH "wasm")
@@ -265,6 +270,8 @@ if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
     set(CLR_CMAKE_TARGET_ARCH_ARM 1)
     set(CLR_CMAKE_TARGET_ARCH_ARMV7L 1)
     set(ARM_SOFTFP 1)
+  elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x)
+    set(CLR_CMAKE_TARGET_ARCH_S390X 1)
   elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm)
     set(CLR_CMAKE_TARGET_ARCH_WASM 1)
   else()
@@ -363,6 +370,8 @@ if(CLR_CMAKE_TARGET_UNIX)
         set(CLR_CMAKE_TARGET_UNIX_ARM64 1)
     elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
         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 wasm)
         set(CLR_CMAKE_TARGET_UNIX_WASM 1)
     else()
index 608f55e..37f3b49 100644 (file)
@@ -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 STREQUAL armv7l OR
-       CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm))
+       CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL s390x))
       set(TOOLSET_PREFIX "${TOOLCHAIN}-")
     else()
       set(TOOLSET_PREFIX "")
index cedee61..fc4078f 100644 (file)
@@ -54,6 +54,10 @@ case "$CPUName" in
         arch=x86
         ;;
 
+    s390x)
+        arch=s390x
+       ;;
+
     *)
         echo "Unknown CPU $CPUName detected, configuring as if for x64"
         arch=x64
index 2cfd798..4aac101 100644 (file)
@@ -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|x86)$" OR FREEBSD OR ILLUMOS)
+elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|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)
@@ -146,7 +146,7 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD OR ILLUMOS)
     set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
   endif()
 else()
-  message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64 and x86 are supported!")
+  message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64, s390x and x86 are supported!")
 endif()
 
 if(TARGET_ARCH_NAME STREQUAL "x86")