Add native configurations for SunOS (#34756)
authorAdeel Mujahid <adeelbm@outlook.com>
Sat, 11 Apr 2020 16:03:18 +0000 (19:03 +0300)
committerGitHub <noreply@github.com>
Sat, 11 Apr 2020 16:03:18 +0000 (09:03 -0700)
eng/native/build-commons.sh
eng/native/configureplatform.cmake
eng/native/init-distro-rid.sh
src/coreclr/tests/setup-stress-dependencies.sh
src/libraries/Native/Unix/configure.cmake

index 425ed7d..a1a975c 100755 (executable)
@@ -53,7 +53,7 @@ check_prereqs()
 
     function version { echo "$@" | awk -F. '{ printf("%d%02d%02d\n", $1,$2,$3); }'; }
 
-    local cmake_version="$(cmake --version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
+    local cmake_version="$(cmake --version | awk '/^cmake version [0-9]+\.[0-9]+\.[0-9]+$/ {print $3}')"
 
     if [[ "$(version "$cmake_version")" -lt "$(version 3.14.2)" ]]; then
         echo "Please install CMake 3.14.2 or newer from http://www.cmake.org/download/ or https://apt.kitware.com and ensure it is on your path."; exit 1;
@@ -385,7 +385,7 @@ done
 platform=$(uname)
 if [[ "$platform" == "FreeBSD" ]]; then
   __NumProc=$(sysctl hw.ncpu | awk '{ print $2+1 }')
-elif [[ "$platform" == "NetBSD" ]]; then
+elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then
   __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
 elif [[ "$platform" == "Darwin" ]]; then
   __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
index e28bad6..1c5254d 100644 (file)
@@ -361,7 +361,9 @@ if(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
     # Skip check_pie_supported call on Android as ld from llvm toolchain with NDK API level 21
     # complains about missing linker flag `-no-pie` (while level 28's ld does support this flag,
     # but since we know that PIE is supported, we can safely skip this redundant check).
-    if(NOT CLR_CMAKE_TARGET_ANDROID)
+    #
+    # The default linker on Solaris also does not support PIE.
+    if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS)
         # All code we build should be compiled as position independent
         get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
         if("CXX" IN_LIST languages)
@@ -374,10 +376,10 @@ if(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
             message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n"
                       "PIE link options will not be passed to linker.")
         endif()
-    endif(NOT CLR_CMAKE_TARGET_ANDROID)
+    endif()
 
     set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-endif(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
+endif()
 
 string(TOLOWER "${CMAKE_BUILD_TYPE}" LOWERCASE_CMAKE_BUILD_TYPE)
 if(LOWERCASE_CMAKE_BUILD_TYPE STREQUAL debug)
index 7a00378..3c875a3 100644 (file)
@@ -167,6 +167,8 @@ initDistroRidGlobal()
                 distroRid="android-$buildArch"
             elif [ "$targetOs" = "FreeBSD" ]; then
                 distroRid="freebsd-$buildArch"
+            elif [ "$targetOs" = "SunOS" ]; then
+                distroRid="sunos-$buildArch"
             fi
         fi
 
index c4516fa..400a780 100755 (executable)
@@ -189,7 +189,7 @@ fi
 packageDir=$(<"${CoreDisToolsPackagePathOutputFile}")
 
 # Get library path
-libPath=`find $packageDir | grep $rid | grep -m 1 libcoredistools`
+libPath="$(find "$packageDir" -path "*$rid*libcoredistools*" -print | head -n 1)"
 echo "libPath to be used: ${libPath}"
 
 if [ ! -e $libPath ] || [ -z "$libPath" ]; then
index 4846ab0..c043ced 100644 (file)
@@ -30,6 +30,11 @@ elseif (CLR_CMAKE_TARGET_FREEBSD)
     set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include)
 elseif (CLR_CMAKE_TARGET_NETBSD)
     set(PAL_UNIX_NAME \"NETBSD\")
+elseif (CLR_CMAKE_TARGET_SUNOS)
+    set(PAL_UNIX_NAME \"SUNOS\")
+    set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include)
+    set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib)
+    include_directories(SYSTEM /opt/local/include)
 else ()
     message(FATAL_ERROR "Unknown platform.  Cannot define PAL_UNIX_NAME, used by RuntimeInformation.")
 endif ()