Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono] Set thread suspend default in mono.proj; default to hybrid #46873

Merged
merged 4 commits into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(ANDROID_UNIFIED_HEADERS 1)
set(ENABLE_MONODROID 1)
set(DISABLE_EXECUTABLES 1)
set(GC_SUSPEND "hybrid")
# Force some defines
set(HAVE_SCHED_GETAFFINITY 0)
set(HAVE_SCHED_SETAFFINITY 0)
Expand Down Expand Up @@ -255,9 +254,6 @@ if(TARGET_SYSTEM_NAME STREQUAL "Darwin")
set(TARGET_MACH 1)
set(TARGET_OSX 1)
set(TARGET_DARWIN 1)
if (GC_SUSPEND STREQUAL "default")
set(GC_SUSPEND "hybrid")
endif()
elseif(TARGET_SYSTEM_NAME STREQUAL "iOS" OR TARGET_SYSTEM_NAME STREQUAL "tvOS")
set(TARGET_MACH 1)
set(TARGET_IOS 1)
Expand Down Expand Up @@ -543,6 +539,20 @@ if (GC_SUSPEND STREQUAL "coop")
set(ENABLE_COOP_SUSPEND 1)
elseif(GC_SUSPEND STREQUAL "hybrid")
set(ENABLE_HYBRID_SUSPEND 1)
elseif(GC_SUSPEND STREQUAL "preemptive")
elseif(GC_SUSPEND STREQUAL "default")
# set some kind of fallback default
if(TARGET_SYSTEM_NAME STREQUAL "watchOS")
lambdageek marked this conversation as resolved.
Show resolved Hide resolved
set(ENABLE_COOP_SUSPEND 1)
elseif(TARGET_SYSTEM_NAME STREQUAL "Windows")
# use preemptive
elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten")
# use preemptive
else()
set(ENABLE_HYBRID_SUSPEND 1)
endif()
else()
message(FATAL_ERROR "GC_SUSPEND (set to '${GC_SUSPEND}') must be one of coop, hybrid or preemptive")
lambdageek marked this conversation as resolved.
Show resolved Hide resolved
endif()

######################################
Expand Down
16 changes: 15 additions & 1 deletion src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- MonoAOTLLVMDir - [optional] the directory where LLVM is located, for an AOT-only Mono
- MonoVerboseBuild - enable verbose build
- MonoMetadataUpdate - enable experimental method body replacement code
- MonoThreadSuspend - coop,hybrid,preemptive - default thread suspend mode
-->

<PropertyGroup>
Expand Down Expand Up @@ -47,6 +48,15 @@
<MonoCxxCompiler Condition="'$(MonoCCompiler)' == 'gcc'">g++</MonoCxxCompiler>
</PropertyGroup>

<!-- default thread suspend for specific platforms -->
<PropertyGroup>
<MonoThreadSuspend Condition="'$(TargetswatchOS)' == 'true' and '$(MonoThreadSuspend)' == ''">coop</MonoThreadSuspend>
<!-- wasm isn't really preemptive, but we don't want safepoints -->
<MonoThreadSuspend Condition="'$(TargetsBrowser)' == 'true' and '$(MonoThreadSuspend)' == ''">preemptive</MonoThreadSuspend>
<!-- all other platforms -->
<MonoThreadSuspend Condition="'$(MonoThreadSuspend)' == ''">hybrid</MonoThreadSuspend>
</PropertyGroup>

<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<PackageReference Include="Microsoft.NETCore.Runtime.ICU.Transport" PrivateAssets="all" Version="$(MicrosoftNETCoreRuntimeICUTransportVersion)" GeneratePathProperty="true" />
</ItemGroup>
Expand Down Expand Up @@ -124,6 +134,7 @@
<_MonoCMakeArgs Include="-DCMAKE_INSTALL_LIBDIR=lib"/>
<_MonoCMakeArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/>
<_MonoCMakeArgs Condition="'$(MonoEnableLLVM)' == 'true'" Include="-DLLVM_PREFIX=$(MonoLLVMDir)" />
<_MonoCMakeArgs Include="-DGC_SUSPEND=$(MonoThreadSuspend)" />
</ItemGroup>

<!-- We build LLVM bits for x64 Linux without C++11 ABI (CentOS 7 has libstdc++ < 5.1) -->
Expand Down Expand Up @@ -414,7 +425,10 @@
<!-- FIXME: Add sanity check that the interpreter is enabled -->
<MonoAOTCMakeArgs Condition="'$(MonoMetadataUpdate)' == 'true'" Include="-DENABLE_METADATA_UPDATE=1" />

<!-- Select generator platform for VS generator -->
<!-- thread suspend -->
<MonoAOTCMakeArgs Include="-DGC_SUSPEND=$(MonoThreadSuspend)" />

<!-- Select generator platform for VS generator -->
<MonoAOTCMakeArgs Condition="'$(OS)' == 'Windows_NT' and '$(_MonoUseNinja)' != 'true' and '$(Platform)' == 'x64'" Include="-A x64" />
<MonoAOTCMakeArgs Condition="'$(OS)' == 'Windows_NT' and '$(_MonoUseNinja)' != 'true' and '$(Platform)' == 'x86'" Include="-A Win32" />
<MonoAOTCMakeArgs Condition="'$(OS)' == 'Windows_NT' and '$(_MonoUseNinja)' != 'true' and '$(Platform)' == 'arm'" Include="-A ARM" />
Expand Down