Skip to content

Commit a47b8dc

Browse files
authored
Fix mono build on illumos (#55897)
1 parent 5da7094 commit a47b8dc

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

src/mono/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
252252
add_compile_options(/GL) # whole program optimization
253253
add_link_options(/LTCG) # link-time code generation
254254
endif()
255+
elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
256+
set(HOST_SOLARIS 1)
257+
add_definitions(-DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_MMAP -DUSE_MUNMAP -DHOST_SOLARIS -D__EXTENSIONS__ -D_XPG4_2)
255258
else()
256259
message(FATAL_ERROR "Host '${CMAKE_SYSTEM_NAME}' not supported.")
257260
endif()
@@ -290,6 +293,8 @@ elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten")
290293
endif()
291294
elseif(TARGET_SYSTEM_NAME STREQUAL "Windows")
292295
set(TARGET_WIN32 1)
296+
elseif(TARGET_SYSTEM_NAME STREQUAL "SunOS")
297+
set(TARGET_SOLARIS 1)
293298
else()
294299
message(FATAL_ERROR "Target '${TARGET_SYSTEM_NAME}' not supported.")
295300
endif()
@@ -589,6 +594,9 @@ elseif(HOST_LINUX)
589594
elseif(HOST_WIN32)
590595
set(ICU_FLAGS "-DTARGET_WINDOWS -DPALEXPORT=EXTERN_C")
591596
set(HAVE_SYS_ICU 1)
597+
elseif(HOST_SOLARIS)
598+
set(ICU_FLAGS "-DPALEXPORT=\"\" -DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option")
599+
set(HAVE_SYS_ICU 1)
592600
else()
593601
message(FATAL_ERROR "Unknown host")
594602
endif()

src/mono/cmake/configure.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ if(C_SUPPORTS_WUNGUARDED_AVAILABILITY)
1616
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unguarded-availability")
1717
endif()
1818

19+
if(HOST_SOLARIS)
20+
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_MMAP -DUSE_MUNMAP -DHOST_SOLARIS -D__EXTENSIONS__ -D_XPG4_2")
21+
endif()
22+
1923
function(ac_check_headers)
2024
foreach(arg ${ARGN})
2125
check_include_file ("${arg}" FOUND_${arg})
@@ -66,7 +70,7 @@ ac_check_headers (
6670

6771
ac_check_funcs (
6872
sigaction kill clock_nanosleep kqueue backtrace_symbols mkstemp mmap
69-
madvise getrusage dladdr sysconf getrlimit prctl nl_langinfo
73+
getrusage dladdr sysconf getrlimit prctl nl_langinfo
7074
sched_getaffinity sched_setaffinity getpwuid_r readlink chmod lstat getdtablesize ftruncate msync
7175
getpeername utime utimes openlog closelog atexit popen strerror_r inet_pton inet_aton
7276
shm_open poll getfsstat mremap posix_fadvise vsnprintf sendfile statfs statvfs setpgid system
@@ -89,6 +93,7 @@ ac_check_funcs(
8993
pthread_attr_setstacksize pthread_get_stackaddr_np
9094
)
9195

96+
check_symbol_exists(madvise "sys/mman.h" HAVE_MADVISE)
9297
check_symbol_exists(pthread_mutexattr_setprotocol "pthread.h" HAVE_DECL_PTHREAD_MUTEXATTR_SETPROTOCOL)
9398
check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
9499
check_symbol_exists(CLOCK_MONOTONIC_COARSE "time.h" HAVE_CLOCK_MONOTONIC_COARSE)
@@ -164,3 +169,9 @@ endif()
164169
if(HOST_BROWSER)
165170
set(HAVE_FORK 0)
166171
endif()
172+
173+
if(HOST_SOLARIS)
174+
set(HAVE_GETPROTOBYNAME 1)
175+
set(HAVE_NETINET_TCP_H 1)
176+
set(HAVE_GETADDRINFO 1)
177+
endif()

src/mono/mono.proj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@
229229
<_MonoBuildEnv Condition="'$(Platform)' == 'arm'" Include="PKG_CONFIG_PATH=$(MonoCrossDir)/usr/lib/arm-linux-gnueabihf/pkgconfig" />
230230
</ItemGroup>
231231

232+
<!-- x64 illumos cross build options -->
233+
<ItemGroup Condition="'$(TargetsIllumos)' == 'true' and '$(MonoCrossDir)' != ''">
234+
<_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$([MSBuild]::NormalizePath('$(RepositoryEngineeringDir)', 'common', 'cross', 'toolchain.cmake'))" />
235+
<_MonoBuildEnv Include="TARGET_BUILD_ARCH=x64" />
236+
<_MonoBuildEnv Include="PKG_CONFIG_PATH=$(MonoCrossDir)/lib/pkgconfig" />
237+
</ItemGroup>
238+
232239
<!-- s390x Linux cross build options -->
233240
<ItemGroup Condition="'$(MonoCrossDir)' != '' and '$(TargetArchitecture)' == 's390x'">
234241
<_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$([MSBuild]::NormalizePath('$(RepositoryEngineeringDir)', 'common', 'cross', 'toolchain.cmake'))" />

src/mono/mono/mini/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ elseif(HOST_LINUX)
3333
set(OS_LIBS pthread m dl)
3434
elseif(HOST_WIN32)
3535
set(OS_LIBS bcrypt.lib Mswsock.lib ws2_32.lib psapi.lib version.lib advapi32.lib winmm.lib kernel32.lib)
36+
elseif(HOST_SOLARIS)
37+
set(OS_LIBS socket pthread m ${CMAKE_DL_LIBS})
3638
endif()
3739

3840
#
@@ -253,7 +255,7 @@ set(posix_sources
253255

254256
if(HOST_DARWIN)
255257
set(os_sources "${darwin_sources};${posix_sources}")
256-
elseif(HOST_LINUX)
258+
elseif(HOST_LINUX OR HOST_SOLARIS)
257259
set(os_sources "${posix_sources}")
258260
elseif(HOST_WIN32)
259261
set(os_sources "${windows_sources}")

0 commit comments

Comments
 (0)