From ff2072bafc807adf5effcaa846193c6020253a7a Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Mon, 19 Jul 2021 07:29:47 +0300 Subject: [PATCH] Fix mono build on illumos --- src/mono/CMakeLists.txt | 8 ++++++++ src/mono/cmake/configure.cmake | 13 ++++++++++++- src/mono/mono.proj | 7 +++++++ src/mono/mono/mini/CMakeLists.txt | 4 +++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 4c25d97b7a5d93..e7a494c22cc8cd 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -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() @@ -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() @@ -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() diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index 34fa15f556caf9..b3d3f47c894e0b 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -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}) @@ -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 @@ -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) @@ -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() diff --git a/src/mono/mono.proj b/src/mono/mono.proj index a329c0ac299401..8b1fb3b13a4ed3 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -229,6 +229,13 @@ <_MonoBuildEnv Condition="'$(Platform)' == 'arm'" Include="PKG_CONFIG_PATH=$(MonoCrossDir)/usr/lib/arm-linux-gnueabihf/pkgconfig" /> + + + <_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" /> + + <_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$([MSBuild]::NormalizePath('$(RepositoryEngineeringDir)', 'common', 'cross', 'toolchain.cmake'))" /> diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 841bff5f566cf9..b07e58569160c2 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -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() # @@ -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}")