Skip to content

Commit

Permalink
Fix mono build on illumos (#55897)
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 authored Jul 19, 2021
1 parent 5da7094 commit a47b8dc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_compile_options(/GL) # whole program optimization
add_link_options(/LTCG) # link-time code generation
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
set(HOST_SOLARIS 1)
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)
else()
message(FATAL_ERROR "Host '${CMAKE_SYSTEM_NAME}' not supported.")
endif()
Expand Down Expand Up @@ -290,6 +293,8 @@ elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten")
endif()
elseif(TARGET_SYSTEM_NAME STREQUAL "Windows")
set(TARGET_WIN32 1)
elseif(TARGET_SYSTEM_NAME STREQUAL "SunOS")
set(TARGET_SOLARIS 1)
else()
message(FATAL_ERROR "Target '${TARGET_SYSTEM_NAME}' not supported.")
endif()
Expand Down Expand Up @@ -589,6 +594,9 @@ elseif(HOST_LINUX)
elseif(HOST_WIN32)
set(ICU_FLAGS "-DTARGET_WINDOWS -DPALEXPORT=EXTERN_C")
set(HAVE_SYS_ICU 1)
elseif(HOST_SOLARIS)
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")
set(HAVE_SYS_ICU 1)
else()
message(FATAL_ERROR "Unknown host")
endif()
Expand Down
13 changes: 12 additions & 1 deletion src/mono/cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ if(C_SUPPORTS_WUNGUARDED_AVAILABILITY)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unguarded-availability")
endif()

if(HOST_SOLARIS)
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")
endif()

function(ac_check_headers)
foreach(arg ${ARGN})
check_include_file ("${arg}" FOUND_${arg})
Expand Down Expand Up @@ -66,7 +70,7 @@ ac_check_headers (

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

check_symbol_exists(madvise "sys/mman.h" HAVE_MADVISE)
check_symbol_exists(pthread_mutexattr_setprotocol "pthread.h" HAVE_DECL_PTHREAD_MUTEXATTR_SETPROTOCOL)
check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
check_symbol_exists(CLOCK_MONOTONIC_COARSE "time.h" HAVE_CLOCK_MONOTONIC_COARSE)
Expand Down Expand Up @@ -164,3 +169,9 @@ endif()
if(HOST_BROWSER)
set(HAVE_FORK 0)
endif()

if(HOST_SOLARIS)
set(HAVE_GETPROTOBYNAME 1)
set(HAVE_NETINET_TCP_H 1)
set(HAVE_GETADDRINFO 1)
endif()
7 changes: 7 additions & 0 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@
<_MonoBuildEnv Condition="'$(Platform)' == 'arm'" Include="PKG_CONFIG_PATH=$(MonoCrossDir)/usr/lib/arm-linux-gnueabihf/pkgconfig" />
</ItemGroup>

<!-- x64 illumos cross build options -->
<ItemGroup Condition="'$(TargetsIllumos)' == 'true' and '$(MonoCrossDir)' != ''">
<_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$([MSBuild]::NormalizePath('$(RepositoryEngineeringDir)', 'common', 'cross', 'toolchain.cmake'))" />
<_MonoBuildEnv Include="TARGET_BUILD_ARCH=x64" />
<_MonoBuildEnv Include="PKG_CONFIG_PATH=$(MonoCrossDir)/lib/pkgconfig" />
</ItemGroup>

<!-- s390x Linux cross build options -->
<ItemGroup Condition="'$(MonoCrossDir)' != '' and '$(TargetArchitecture)' == 's390x'">
<_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$([MSBuild]::NormalizePath('$(RepositoryEngineeringDir)', 'common', 'cross', 'toolchain.cmake'))" />
Expand Down
4 changes: 3 additions & 1 deletion src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ elseif(HOST_LINUX)
set(OS_LIBS pthread m dl)
elseif(HOST_WIN32)
set(OS_LIBS bcrypt.lib Mswsock.lib ws2_32.lib psapi.lib version.lib advapi32.lib winmm.lib kernel32.lib)
elseif(HOST_SOLARIS)
set(OS_LIBS socket pthread m ${CMAKE_DL_LIBS})
endif()

#
Expand Down Expand Up @@ -253,7 +255,7 @@ set(posix_sources

if(HOST_DARWIN)
set(os_sources "${darwin_sources};${posix_sources}")
elseif(HOST_LINUX)
elseif(HOST_LINUX OR HOST_SOLARIS)
set(os_sources "${posix_sources}")
elseif(HOST_WIN32)
set(os_sources "${windows_sources}")
Expand Down

0 comments on commit a47b8dc

Please sign in to comment.