Skip to content

Commit

Permalink
Build support for s390x: eng scripts (#52840)
Browse files Browse the repository at this point in the history
Add support for Linux on s390x as host and target build architecture.
  • Loading branch information
uweigand authored May 18, 2021
1 parent 4267d56 commit 0dd6b7b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 6 deletions.
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 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."
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|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
Expand Down
4 changes: 4 additions & 0 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ while :; do
__BuildArch=x64
;;

s390x|-s390x)
__BuildArch=s390x
;;

wasm|-wasm)
__BuildArch=wasm
;;
Expand Down
11 changes: 11 additions & 0 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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()
Expand Down Expand Up @@ -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 ()
Expand Down
9 changes: 9 additions & 0 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion eng/native/configuretools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
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 @@ -54,6 +54,10 @@ case "$CPUName" in
arch=x86
;;

s390x)
arch=s390x
;;

*)
echo "Unknown CPU $CPUName detected, configuring as if for x64"
arch=x64
Expand Down
4 changes: 2 additions & 2 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|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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 0dd6b7b

Please sign in to comment.