Skip to content

Commit 26edc07

Browse files
authored
Enable parallel compilation features for users of LangVersion=preview (#17948)
1 parent ab3c936 commit 26edc07

File tree

9 files changed

+51
-12
lines changed

9 files changed

+51
-12
lines changed

FSharp.Profiles.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<NullCheckingSupportInLibrary>false</NullCheckingSupportInLibrary>
1919
</PropertyGroup>
2020

21-
<PropertyGroup Condition="'$(Configuration)' != 'Proto' and '$(BUILDING_USING_DOTNET)' != 'true'">
22-
<OtherFlags>$(OtherFlags) /langversion:preview</OtherFlags>
21+
<PropertyGroup Condition="'$(Configuration)' != 'Proto' and '$(BUILDING_USING_DOTNET)' != 'true' and '$(MSBuildProjectExtension)' == '.fsproj'"> <!-- VB.NET does not understand "preview". It only knows "old","older" and "boomer" :-)) (jk)-->
22+
<LangVersion>preview</LangVersion>
2323
</PropertyGroup>
2424

2525
<PropertyGroup Condition="'$(BUILDING_USING_DOTNET)' == 'true'">

docs/release-notes/.FSharp.Compiler.Service/9.0.200.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Deprecate places where `seq` can be omitted. ([Language suggestion #1033](https://github.com/fsharp/fslang-suggestions/issues/1033), [PR #17772](https://github.com/dotnet/fsharp/pull/17772))
1616
* Support literal attribute on decimals ([PR #17769](https://github.com/dotnet/fsharp/pull/17769))
1717
* Added type conversions cache, only enabled for compiler runs, guarded by language version preview ([PR#17668](https://github.com/dotnet/fsharp/pull/17668))
18+
* Added project property ParallelCompilation which turns on graph based type checking, parallel ILXGen and parallel optimization. By default on for users of langversion=preview ([PR#17948](https://github.com/dotnet/fsharp/pull/17948))
1819

1920
### Changed
2021

src/Compiler/Driver/CompilerConfig.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ type TcConfigBuilder =
566566
mutable optSettings: Optimizer.OptimizationSettings
567567
mutable emitTailcalls: bool
568568
mutable deterministic: bool
569-
mutable concurrentBuild: bool
569+
mutable parallelParsing: bool
570570
mutable parallelIlxGen: bool
571571
mutable emitMetadataAssembly: MetadataAssemblyGeneration
572572
mutable preferredUiLang: string option
@@ -817,7 +817,7 @@ type TcConfigBuilder =
817817
}
818818
emitTailcalls = true
819819
deterministic = false
820-
concurrentBuild = true
820+
parallelParsing = true
821821
parallelIlxGen = FSharpExperimentalFeaturesEnabledAutomatically
822822
emitMetadataAssembly = MetadataAssemblyGeneration.None
823823
preferredUiLang = None
@@ -1380,7 +1380,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
13801380
member _.optSettings = data.optSettings
13811381
member _.emitTailcalls = data.emitTailcalls
13821382
member _.deterministic = data.deterministic
1383-
member _.concurrentBuild = data.concurrentBuild
1383+
member _.parallelParsing = data.parallelParsing
13841384
member _.parallelIlxGen = data.parallelIlxGen
13851385
member _.emitMetadataAssembly = data.emitMetadataAssembly
13861386
member _.pathMap = data.pathMap

src/Compiler/Driver/CompilerConfig.fsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ type TcConfigBuilder =
435435

436436
mutable deterministic: bool
437437

438-
mutable concurrentBuild: bool
438+
mutable parallelParsing: bool
439439

440440
mutable parallelIlxGen: bool
441441

@@ -771,7 +771,7 @@ type TcConfig =
771771

772772
member deterministic: bool
773773

774-
member concurrentBuild: bool
774+
member parallelParsing: bool
775775

776776
member parallelIlxGen: bool
777777

src/Compiler/Driver/CompilerOptions.fs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,26 @@ let splittingSwitch (tcConfigB: TcConfigBuilder) switch =
622622
let callVirtSwitch (tcConfigB: TcConfigBuilder) switch =
623623
tcConfigB.alwaysCallVirt <- switch = OptionSwitch.On
624624

625+
let callParallelCompilationSwitch (tcConfigB: TcConfigBuilder) switch =
626+
tcConfigB.parallelIlxGen <- switch = OptionSwitch.On
627+
628+
let (graphCheckingMode, optMode) =
629+
match switch with
630+
| OptionSwitch.On -> TypeCheckingMode.Graph, OptimizationProcessingMode.Parallel
631+
| OptionSwitch.Off -> TypeCheckingMode.Sequential, OptimizationProcessingMode.Sequential
632+
633+
if tcConfigB.typeCheckingConfig.Mode <> graphCheckingMode then
634+
tcConfigB.typeCheckingConfig <-
635+
{ tcConfigB.typeCheckingConfig with
636+
Mode = graphCheckingMode
637+
}
638+
639+
if tcConfigB.optSettings.processingMode <> optMode then
640+
tcConfigB.optSettings <-
641+
{ tcConfigB.optSettings with
642+
processingMode = optMode
643+
}
644+
625645
let useHighEntropyVASwitch (tcConfigB: TcConfigBuilder) switch =
626646
tcConfigB.useHighEntropyVA <- switch = OptionSwitch.On
627647

@@ -1365,9 +1385,9 @@ let testFlag tcConfigB =
13651385
| "DumpDebugInfo" -> tcConfigB.dumpDebugInfo <- true
13661386
| "ShowLoadedAssemblies" -> tcConfigB.showLoadedAssemblies <- true
13671387
| "ContinueAfterParseFailure" -> tcConfigB.continueAfterParseFailure <- true
1368-
| "ParallelOff" -> tcConfigB.concurrentBuild <- false
1369-
| "ParallelIlxGen" -> tcConfigB.parallelIlxGen <- true
1370-
| "GraphBasedChecking" ->
1388+
| "ParallelOff" -> tcConfigB.parallelParsing <- false
1389+
| "ParallelIlxGen" -> tcConfigB.parallelIlxGen <- true // Kept as --test:.. flag for temporary backwards compatibility during .NET10 period.
1390+
| "GraphBasedChecking" -> // Kept as --test:.. flag for temporary backwards compatibility during .NET10 period.
13711391
tcConfigB.typeCheckingConfig <-
13721392
{ tcConfigB.typeCheckingConfig with
13731393
Mode = TypeCheckingMode.Graph
@@ -1378,7 +1398,7 @@ let testFlag tcConfigB =
13781398
DumpGraph = true
13791399
}
13801400
| "DumpSignatureData" -> tcConfigB.dumpSignatureData <- true
1381-
| "ParallelOptimization" ->
1401+
| "ParallelOptimization" -> // Kept as --test:.. flag for temporary backwards compatibility during .NET10 period.
13821402
tcConfigB.optSettings <-
13831403
{ tcConfigB.optSettings with
13841404
processingMode = OptimizationProcessingMode.Parallel
@@ -1692,6 +1712,14 @@ let internalFlags (tcConfigB: TcConfigBuilder) =
16921712
None
16931713
)
16941714

1715+
CompilerOption(
1716+
"parallelcompilation",
1717+
tagNone,
1718+
OptionSwitch(callParallelCompilationSwitch tcConfigB),
1719+
Some(InternalCommandLineOption("--parallelcompilation", rangeCmdArgs)),
1720+
None
1721+
)
1722+
16951723
testFlag tcConfigB
16961724
]
16971725
@

src/Compiler/Driver/ParseAndCheckInputs.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ let ParseInputFilesSequential (tcConfig: TcConfig, lexResourceManager, sourceFil
853853
/// Parse multiple input files from disk
854854
let ParseInputFiles (tcConfig: TcConfig, lexResourceManager, sourceFiles, diagnosticsLogger: DiagnosticsLogger, retryLocked) =
855855
try
856-
if tcConfig.concurrentBuild then
856+
if tcConfig.parallelParsing then
857857
ParseInputFilesInParallel(tcConfig, lexResourceManager, sourceFiles, diagnosticsLogger, retryLocked)
858858
else
859859
ParseInputFilesSequential(tcConfig, lexResourceManager, sourceFiles, diagnosticsLogger, retryLocked)

src/FSharp.Build/Fsc.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type public Fsc() as this =
4949
let mutable otherFlags: string MaybeNull = null
5050
let mutable outputAssembly: string MaybeNull = null
5151
let mutable outputRefAssembly: string MaybeNull = null
52+
let mutable parallelCompilation: bool option = None
5253
let mutable pathMap: string MaybeNull = null
5354
let mutable pdbFile: string MaybeNull = null
5455
let mutable platform: string MaybeNull = null
@@ -202,6 +203,7 @@ type public Fsc() as this =
202203
if not tailcalls then
203204
builder.AppendSwitch("--tailcalls-")
204205

206+
// Nullables
205207
match nullable with
206208
| Some true ->
207209
builder.AppendSwitch("--checknulls+")
@@ -345,6 +347,8 @@ type public Fsc() as this =
345347
if deterministic then
346348
builder.AppendSwitch("--deterministic+")
347349

350+
builder.AppendOptionalSwitch("--parallelcompilation", parallelCompilation)
351+
348352
// OtherFlags - must be second-to-last
349353
builder.AppendSwitchUnquotedIfNotNull("", otherFlags)
350354
capturedArguments <- builder.CapturedArguments()
@@ -504,6 +508,10 @@ type public Fsc() as this =
504508
with get () = outputRefAssembly
505509
and set (s) = outputRefAssembly <- s
506510

511+
member _.ParallelCompilation
512+
with get () = parallelCompilation |> Option.defaultValue false
513+
and set (p) = parallelCompilation <- Some p
514+
507515
// --pathmap <string>: Paths to rewrite when producing deterministic builds
508516
member _.PathMap
509517
with get () = pathMap

src/FSharp.Build/Microsoft.FSharp.NetSdk.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
5050
<UseStandardResourceNames Condition=" '$(UseStandardResourceNames)' == '' ">true</UseStandardResourceNames>
5151
<FsiExec Condition=" '$(FsiExec)' == '' ">true</FsiExec>
5252
<ReflectionFree Condition=" '$(ReflectionFree)' == '' ">false</ReflectionFree>
53+
<ParallelCompilation Condition=" '$(ParallelCompilation)' == '' and '$(LangVersion)' == 'preview' "></ParallelCompilation> <!-- Default to parallel compilation for preview language users before it is rolled out to everyone -->
5354
</PropertyGroup>
5455

5556
<!-- BinaryFormatter is disabled (warning is treated as error) by default in .NET8+, this mirroring the change in SDK (https://github.com/dotnet/sdk/pull/31591) -->

src/FSharp.Build/Microsoft.FSharp.Targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ this file.
380380
OtherFlags="$(FscOtherFlags)"
381381
OutputAssembly="@(IntermediateAssembly)"
382382
OutputRefAssembly="@(IntermediateRefAssembly)"
383+
ParallelCompilation="@(ParallelCompilation)"
383384
PathMap="$(PathMap)"
384385
PdbFile="$(PdbFile)"
385386
Platform="$(PlatformTarget)"

0 commit comments

Comments
 (0)