-
Notifications
You must be signed in to change notification settings - Fork 831
Closed
Labels
Area-FSCEverything related to F# compiler CLIEverything related to F# compiler CLI
Milestone
Description
On the review with @KevinRansom, we've realized that there's an existing mechanism for proper exit from the compiler - using of exiters (with StopProcessing exceptions probably).
For example:
Lines 77 to 108 in af0015e
| let quitProcessExiter = | |
| { new Exiter with | |
| member _.Exit(n) = | |
| try | |
| exit n | |
| with _ -> | |
| () | |
| failwithf "%s" (FSComp.SR.elSysEnvExitDidntExit ()) | |
| } | |
| // Get the handler for legacy resolution of references via MSBuild. | |
| let legacyReferenceResolver = LegacyMSBuildReferenceResolver.getResolver () | |
| // Perform the main compilation. | |
| // | |
| // This is the only place where ReduceMemoryFlag.No is set. This is because fsc.exe is not a long-running process and | |
| // thus we can use file-locking memory mapped files. | |
| // | |
| // This is also one of only two places where CopyFSharpCoreFlag.Yes is set. The other is in LegacyHostedCompilerForTesting. | |
| CompileFromCommandLineArguments( | |
| ctok, | |
| argv, | |
| legacyReferenceResolver, | |
| false, | |
| ReduceMemoryFlag.No, | |
| CopyFSharpCoreFlag.Yes, | |
| quitProcessExiter, | |
| ConsoleLoggerProvider(), | |
| None, | |
| None | |
| ) |
or:
fsharp/src/Compiler/Service/service.fs
Lines 119 to 129 in af0015e
| let exiter = | |
| { new Exiter with | |
| member x.Exit n = raise StopProcessing | |
| } | |
| try | |
| f exiter | |
| 0 | |
| with e -> | |
| stopProcessingRecovery e range0 | |
| 1 |
Wondering how easy will it be to plug into the cli options, since it is designed for cases like this and is probably the right way of dealing with it.
Originally posted by @vzarytovskii in #13702 (comment)
abelbraaksma
Metadata
Metadata
Assignees
Labels
Area-FSCEverything related to F# compiler CLIEverything related to F# compiler CLI
Type
Projects
Status
Done