Browse Source

Do not pass /shared to compilers that cannot reach a compiler server

The dotnet-hosted Roslyn 2.10 build cannot start its VBCSCompiler server
under a current dotnet host, so with /shared every test compilation first
waited out the client's full 20-second new-server connection timeout
before falling back to a sub-second in-process compile. Since the 2.10
configurations were enabled on non-Windows (#3914), that added ~29
minutes to the Linux CI job and ~43 minutes on macOS: ~340 affected
tests at ~21s each, versus ~0.2s for the toolsets whose server works.

Assisted-by: Claude:claude-fable-5:Claude Code
pull/3932/head
Siegfried Pammer 2 months ago committed by Siegfried Pammer
parent
commit
d29aeb3eaa
  1. 5
      ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
  2. 24
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

5
ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs

@ -135,9 +135,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -135,9 +135,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
}
}
// note: the /shared switch is undocumented. It allows us to use the VBCSCompiler.exe compiler
// server to speed up testing
if (roslynVersion != "legacy")
// See UseCompilerServer for why /shared is not passed to every compiler.
if (roslynVersion != "legacy" && UseCompilerServer(roslynVersion))
{
otherOptions += "/shared ";
}

24
ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

@ -231,6 +231,23 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -231,6 +231,23 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
&& !(executesCompiledOutput && c.HasFlag(CompilerOptions.TargetNet40))).ToArray();
}
/// <summary>
/// Whether to pass the undocumented /shared switch, which makes the compiler use the
/// VBCSCompiler compiler server and so avoids paying compiler startup per invocation.
/// The dotnet-hosted Roslyn 2.x build cannot start its compiler server under a current
/// 'dotnet' host (the roll-forward in WrapCompiler applies to csc/vbc itself, not to
/// the server process the client tries to spawn), so with /shared every invocation
/// first waits out the client's full 20-second new-server connection timeout before
/// falling back to a sub-second in-process compile. Only the dotnet-hosted Roslyn 3.0+
/// builds get the switch on non-Windows platforms; the Mono-hosted 1.x compilers skip
/// it too rather than rely on the server protocol working under Mono.
/// </summary>
static bool UseCompilerServer(string roslynVersion)
{
return OperatingSystem.IsWindows()
|| Version.Parse(RoslynToolset.SanitizeVersion(roslynVersion)).Major > 2;
}
/// <summary>
/// Wraps an external compiler invocation. The .NET Framework builds of the Roslyn
/// compilers (csc.exe/vbc.exe) are directly executable on Windows and are hosted by
@ -717,11 +734,12 @@ namespace System.Runtime.CompilerServices @@ -717,11 +734,12 @@ namespace System.Runtime.CompilerServices
HashSet<string> noWarn = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
// note: the /shared switch is undocumented. It allows us to use the VBCSCompiler.exe compiler
// server to speed up testing
if (roslynVersion != "legacy")
{
otherOptions += "/shared ";
if (UseCompilerServer(roslynVersion))
{
otherOptions += "/shared ";
}
var version = Version.Parse(RoslynToolset.SanitizeVersion(roslynVersion));
if (!targetNet40 && version.Major > 2)
{

Loading…
Cancel
Save