Skip to content

Commit 4d3b5e5

Browse files
authored
Add native configurations for SunOS (#34756)
1 parent 78643b9 commit 4d3b5e5

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

eng/native/build-commons.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ check_prereqs()
5353

5454
function version { echo "$@" | awk -F. '{ printf("%d%02d%02d\n", $1,$2,$3); }'; }
5555

56-
local cmake_version="$(cmake --version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
56+
local cmake_version="$(cmake --version | awk '/^cmake version [0-9]+\.[0-9]+\.[0-9]+$/ {print $3}')"
5757

5858
if [[ "$(version "$cmake_version")" -lt "$(version 3.14.2)" ]]; then
5959
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
385385
platform=$(uname)
386386
if [[ "$platform" == "FreeBSD" ]]; then
387387
__NumProc=$(sysctl hw.ncpu | awk '{ print $2+1 }')
388-
elif [[ "$platform" == "NetBSD" ]]; then
388+
elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then
389389
__NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
390390
elif [[ "$platform" == "Darwin" ]]; then
391391
__NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))

eng/native/configureplatform.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ if(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
361361
# Skip check_pie_supported call on Android as ld from llvm toolchain with NDK API level 21
362362
# complains about missing linker flag `-no-pie` (while level 28's ld does support this flag,
363363
# but since we know that PIE is supported, we can safely skip this redundant check).
364-
if(NOT CLR_CMAKE_TARGET_ANDROID)
364+
#
365+
# The default linker on Solaris also does not support PIE.
366+
if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS)
365367
# All code we build should be compiled as position independent
366368
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
367369
if("CXX" IN_LIST languages)
@@ -374,10 +376,10 @@ if(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
374376
message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n"
375377
"PIE link options will not be passed to linker.")
376378
endif()
377-
endif(NOT CLR_CMAKE_TARGET_ANDROID)
379+
endif()
378380

379381
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
380-
endif(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
382+
endif()
381383

382384
string(TOLOWER "${CMAKE_BUILD_TYPE}" LOWERCASE_CMAKE_BUILD_TYPE)
383385
if(LOWERCASE_CMAKE_BUILD_TYPE STREQUAL debug)

eng/native/init-distro-rid.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ initDistroRidGlobal()
167167
distroRid="android-$buildArch"
168168
elif [ "$targetOs" = "FreeBSD" ]; then
169169
distroRid="freebsd-$buildArch"
170+
elif [ "$targetOs" = "SunOS" ]; then
171+
distroRid="sunos-$buildArch"
170172
fi
171173
fi
172174

src/coreclr/tests/setup-stress-dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ fi
189189
packageDir=$(<"${CoreDisToolsPackagePathOutputFile}")
190190

191191
# Get library path
192-
libPath=`find $packageDir | grep $rid | grep -m 1 libcoredistools`
192+
libPath="$(find "$packageDir" -path "*$rid*libcoredistools*" -print | head -n 1)"
193193
echo "libPath to be used: ${libPath}"
194194

195195
if [ ! -e $libPath ] || [ -z "$libPath" ]; then

src/libraries/Native/Unix/configure.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ elseif (CLR_CMAKE_TARGET_FREEBSD)
3030
set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include)
3131
elseif (CLR_CMAKE_TARGET_NETBSD)
3232
set(PAL_UNIX_NAME \"NETBSD\")
33+
elseif (CLR_CMAKE_TARGET_SUNOS)
34+
set(PAL_UNIX_NAME \"SUNOS\")
35+
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include)
36+
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib)
37+
include_directories(SYSTEM /opt/local/include)
3338
else ()
3439
message(FATAL_ERROR "Unknown platform. Cannot define PAL_UNIX_NAME, used by RuntimeInformation.")
3540
endif ()

0 commit comments

Comments
 (0)