diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 4199828f2970be..dd0dea81cd6199 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -234,23 +234,19 @@ __HostOS=$os __BuildOS=$os # Get the number of processors available to the scheduler -# Other techniques such as `nproc` only get the number of -# processors available to a single process. platform="$(uname)" if [[ "$platform" == "FreeBSD" ]]; then - __NumProc=$(($(sysctl -n hw.ncpu)+1)) + __NumProc="$(($(sysctl -n hw.ncpu)+1))" elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then - __NumProc=$(($(getconf NPROCESSORS_ONLN)+1)) + __NumProc="$(($(getconf NPROCESSORS_ONLN)+1))" elif [[ "$platform" == "Darwin" ]]; then - __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1)) + __NumProc="$(($(getconf _NPROCESSORS_ONLN)+1))" +elif command -v nproc > /dev/null 2>&1; then + __NumProc="$(nproc)" +elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then + __NumProc="$(getconf _NPROCESSORS_ONLN)" else - if command -v nproc > /dev/null 2>&1; then - __NumProc=$(nproc --all) - elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then - __NumProc=$(getconf _NPROCESSORS_ONLN) - else - __NumProc=1 - fi + __NumProc=1 fi while :; do diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 9594de561b452e..a0163845e63e8c 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -787,6 +787,13 @@ if (CLR_CMAKE_HOST_WIN32) endif() elseif (NOT CLR_CMAKE_HOST_BROWSER) + # This is a workaround for upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22995. + # + # In Clang.cmake, the decision to use single or double hyphen for target and gcc-toolchain + # is made based on CMAKE_${LANG}_COMPILER_VERSION, but CMAKE_ASM_COMPILER_VERSION is empty + # so it picks up single hyphen options, which new clang versions don't recognize. + set (CMAKE_ASM_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION}") + enable_language(ASM) endif(CLR_CMAKE_HOST_WIN32) diff --git a/eng/native/configuretools.cmake b/eng/native/configuretools.cmake index 2a02d1110f7270..07a3bbfafe4dd9 100644 --- a/eng/native/configuretools.cmake +++ b/eng/native/configuretools.cmake @@ -21,7 +21,7 @@ if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER) endif() endif() - function(locate_toolchain_exec exec var) + function(locate_toolchain_exec exec var required) string(TOUPPER ${exec} EXEC_UPPERCASE) if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "") set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE) @@ -34,33 +34,40 @@ if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER) "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}" "${TOOLSET_PREFIX}${exec}") - if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") - message(FATAL_ERROR "Unable to find toolchain executable. Name: '${exec}', Prefix: '${TOOLSET_PREFIX}.'") + if (required AND EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") + message(FATAL_ERROR "Unable to find toolchain executable. Name: '${exec}', Prefix: '${TOOLSET_PREFIX}'") + endif() + + if (NOT EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") + set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) endif() - set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) endfunction() - locate_toolchain_exec(ar CMAKE_AR) - locate_toolchain_exec(nm CMAKE_NM) - locate_toolchain_exec(ranlib CMAKE_RANLIB) + locate_toolchain_exec(ar CMAKE_AR YES) + locate_toolchain_exec(nm CMAKE_NM YES) + locate_toolchain_exec(ranlib CMAKE_RANLIB YES) if(CMAKE_C_COMPILER_ID MATCHES "Clang") - locate_toolchain_exec(link CMAKE_LINKER) + 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)) - locate_toolchain_exec(objdump CMAKE_OBJDUMP) - locate_toolchain_exec(objcopy CMAKE_OBJCOPY) + locate_toolchain_exec(objdump CMAKE_OBJDUMP YES) - execute_process( - COMMAND ${CMAKE_OBJCOPY} --help - OUTPUT_VARIABLE OBJCOPY_HELP_OUTPUT - ) + unset(CMAKE_OBJCOPY CACHE) + locate_toolchain_exec(objcopy CMAKE_OBJCOPY NO) + + if (CMAKE_OBJCOPY) + execute_process( + COMMAND ${CMAKE_OBJCOPY} --help + OUTPUT_VARIABLE OBJCOPY_HELP_OUTPUT + ) + endif() # if llvm-objcopy does not support --only-keep-debug argument, try to locate binutils' objcopy - if (CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT "${OBJCOPY_HELP_OUTPUT}" MATCHES "--only-keep-debug") + if (NOT CMAKE_OBJCOPY OR (CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT "${OBJCOPY_HELP_OUTPUT}" MATCHES "--only-keep-debug")) set(TOOLSET_PREFIX "") - locate_toolchain_exec(objcopy CMAKE_OBJCOPY) + locate_toolchain_exec(objcopy CMAKE_OBJCOPY YES) endif () endif() diff --git a/eng/native/ijw/IJW.cmake b/eng/native/ijw/IJW.cmake index f606b5e98889fe..9a38a18dc0759b 100644 --- a/eng/native/ijw/IJW.cmake +++ b/eng/native/ijw/IJW.cmake @@ -32,7 +32,7 @@ if (CLR_CMAKE_HOST_WIN32) endfunction() # 4365 - signed/unsigned mismatch - # 4679 - Could not import member. This is an issue with IJW and static abstract methods in interfaces. + # 4679 - Could not import member. This is an issue with IJW and static abstract methods in interfaces. add_compile_options(/wd4365 /wd4679) # IJW diff --git a/eng/native/init-os-and-arch.sh b/eng/native/init-os-and-arch.sh index 4064314011391d..9f8b78984db0f9 100644 --- a/eng/native/init-os-and-arch.sh +++ b/eng/native/init-os-and-arch.sh @@ -68,11 +68,11 @@ case "$CPUName" in s390x) arch=s390x - ;; + ;; ppc64le) - arch=ppc64le - ;; + arch=ppc64le + ;; *) echo "Unknown CPU $CPUName detected!" exit 1 diff --git a/src/coreclr/debug/ee/CMakeLists.txt b/src/coreclr/debug/ee/CMakeLists.txt index 106f4bed5d0e6c..aebc2d22022629 100644 --- a/src/coreclr/debug/ee/CMakeLists.txt +++ b/src/coreclr/debug/ee/CMakeLists.txt @@ -49,11 +49,9 @@ set(CORDBEE_HEADERS_DAC list(APPEND CORDBEE_SOURCES_WKS ${ARCH_SOURCES_DIR}/walker.cpp) -if(CLR_CMAKE_TARGET_ARCH_AMD64) +if (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386) list(APPEND CORDBEE_SOURCES_WKS ${ARCH_SOURCES_DIR}/debuggerregdisplayhelper.cpp) -elseif(CLR_CMAKE_TARGET_ARCH_I386) - list(APPEND CORDBEE_SOURCES_WKS ${ARCH_SOURCES_DIR}/debuggerregdisplayhelper.cpp) -endif() +endif () convert_to_absolute_path(CORDBEE_SOURCES_DAC ${CORDBEE_SOURCES_DAC}) convert_to_absolute_path(CORDBEE_SOURCES_WKS ${CORDBEE_SOURCES_WKS}) diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 7cab500089376f..f58c854487128a 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -2653,7 +2653,7 @@ PALIMPORT BOOL PALAPI PAL_GetUnwindInfoSize(SIZE_T baseAddress, ULONG64 ehFrameH #define PAL_CS_NATIVE_DATA_SIZE 48 #elif defined(__linux__) && defined(__loongarch64) #define PAL_CS_NATIVE_DATA_SIZE 96 -#elif defined(__linux__) && defined(_riscv) && __riscv_xlen == 64 +#elif defined(__linux__) && defined(__riscv) && __riscv_xlen == 64 #define PAL_CS_NATIVE_DATA_SIZE 96 #else #error PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture @@ -3742,7 +3742,7 @@ YieldProcessor() __asm__ __volatile__( "yield"); #elif defined(HOST_LOONGARCH64) __asm__ volatile( "dbar 0; \n"); -#elif defined(HOST_RISV64) +#elif defined(HOST_RISCV64) __asm__ __volatile__( "wfi"); #else return; diff --git a/src/tests/Common/scripts/bringup_runtest.sh b/src/tests/Common/scripts/bringup_runtest.sh index b5228105980ffc..e532f36631b6be 100755 --- a/src/tests/Common/scripts/bringup_runtest.sh +++ b/src/tests/Common/scripts/bringup_runtest.sh @@ -727,20 +727,22 @@ function run_test { return $testScriptExitCode } -# Variables for running tests in the background -if [ `uname` = "NetBSD" ]; then - NumProc=$(getconf NPROCESSORS_ONLN) -elif [ `uname` = "Darwin" ]; then - NumProc=$(getconf _NPROCESSORS_ONLN) +# Get the number of processors available to the scheduler +platform="$(uname)" +if [[ "$platform" == "FreeBSD" ]]; then + NumProc="$(($(sysctl -n hw.ncpu)+1))" +elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then + NumProc="$(($(getconf NPROCESSORS_ONLN)+1))" +elif [[ "$platform" == "Darwin" ]]; then + NumProc="$(($(getconf _NPROCESSORS_ONLN)+1))" +elif command -v nproc > /dev/null 2>&1; then + NumProc="$(nproc)" +elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then + NumProc="$(getconf _NPROCESSORS_ONLN)" else - if [ -x "$(command -v nproc)" ]; then - NumProc=$(nproc --all) - elif [ -x "$(command -v getconf)" ]; then - NumProc=$(getconf _NPROCESSORS_ONLN) - else - NumProc=1 - fi + NumProc=1 fi + ((maxProcesses = $NumProc * 3 / 2)) # long tests delay process creation, use a few more processors ((processCount = 0)) diff --git a/src/tests/build.sh b/src/tests/build.sh index 3e806743062fcf..c6f30ccf3670cc 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -358,17 +358,19 @@ else fi # Get the number of processors available to the scheduler -# Other techniques such as `nproc` only get the number of -# processors available to a single process. -__Platform="$(uname)" -if [[ "$__Platform" == "FreeBSD" ]]; then - __NumProc=$(($(sysctl -n hw.ncpu)+1)) -elif [[ "$__Platform" == "NetBSD" || "$__Platform" == "SunOS" ]]; then - __NumProc=$(($(getconf NPROCESSORS_ONLN)+1)) -elif [[ "$__Platform" == "Darwin" ]]; then - __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1)) +platform="$(uname)" +if [[ "$platform" == "FreeBSD" ]]; then + __NumProc="$(($(sysctl -n hw.ncpu)+1))" +elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then + __NumProc="$(($(getconf NPROCESSORS_ONLN)+1))" +elif [[ "$platform" == "Darwin" ]]; then + __NumProc="$(($(getconf _NPROCESSORS_ONLN)+1))" +elif command -v nproc > /dev/null 2>&1; then + __NumProc="$(nproc)" +elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then + __NumProc="$(getconf _NPROCESSORS_ONLN)" else - __NumProc=$(nproc --all) + __NumProc=1 fi # Set dependent variables