-
Notifications
You must be signed in to change notification settings - Fork 802
/
Copy pathCompilerConfig.fs
1543 lines (1291 loc) · 60.1 KB
/
CompilerConfig.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// The configuration of the compiler (TcConfig and TcConfigBuilder)
module internal FSharp.Compiler.CompilerConfig
open System
open System.Collections.Concurrent
open System.Runtime.InteropServices
open System.IO
open FSharp.Compiler.Optimizer
open Internal.Utilities
open Internal.Utilities.FSharpEnvironment
open Internal.Utilities.Library
open Internal.Utilities.Library.Extras
open FSharp.Compiler
open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler.AbstractIL.ILBinaryReader
open FSharp.Compiler.AbstractIL.ILPdbWriter
open FSharp.Compiler.DependencyManager
open FSharp.Compiler.Diagnostics
open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.Features
open FSharp.Compiler.IO
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Syntax
open FSharp.Compiler.Text
open FSharp.Compiler.Text.Range
open FSharp.Compiler.Xml
open FSharp.Compiler.TypedTree
open FSharp.Compiler.BuildGraph
#if !NO_TYPEPROVIDERS
open FSharp.Core.CompilerServices
#endif
let (++) x s = x @ [ s ]
//----------------------------------------------------------------------------
// Some Globals
//--------------------------------------------------------------------------
let FSharpSigFileSuffixes = [ ".mli"; ".fsi" ]
let FSharpMLCompatFileSuffixes = [ ".mli"; ".ml" ]
let FSharpImplFileSuffixes = [ ".ml"; ".fs"; ".fsscript"; ".fsx" ]
let FSharpScriptFileSuffixes = [ ".fsscript"; ".fsx" ]
let FSharpIndentationAwareSyntaxFileSuffixes =
[ ".fs"; ".fsscript"; ".fsx"; ".fsi" ]
let FSharpExperimentalFeaturesEnabledAutomatically =
String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("FSHARP_EXPERIMENTAL_FEATURES"))
|> not
//--------------------------------------------------------------------------
// General file name resolver
//--------------------------------------------------------------------------
exception FileNameNotResolved of searchedLocations: string * fileName: string * range: range
exception LoadedSourceNotFoundIgnoring of fileName: string * range: range
/// Will return None if the fileName is not found.
let TryResolveFileUsingPaths (paths, m, fileName) =
let () =
try
FileSystem.IsPathRootedShim fileName |> ignore
with :? ArgumentException as e ->
error (Error(FSComp.SR.buildProblemWithFilename (fileName, e.Message), m))
if FileSystem.IsPathRootedShim fileName then
if FileSystem.FileExistsShim fileName then
Some fileName
else
None
else
let res =
paths
|> Seq.tryPick (fun path ->
let n = Path.Combine(path, fileName)
if FileSystem.FileExistsShim n then Some n else None)
res
/// Will raise FileNameNotResolved if the fileName was not found
let ResolveFileUsingPaths (paths, m, fileName) =
match TryResolveFileUsingPaths(paths, m, fileName) with
| Some res -> res
| None ->
let searchMessage = String.concat "\n " paths
raise (FileNameNotResolved(fileName, searchMessage, m))
[<RequireQualifiedAccess>]
type WarningNumberSource =
| CommandLineOption
| CompilerDirective
[<RequireQualifiedAccess>]
type WarningDescription =
| Int32 of int
| String of string
| Ident of Ident
let GetWarningNumber (m, description: WarningDescription, langVersion: LanguageVersion, source: WarningNumberSource) =
let argFeature = LanguageFeature.ParsedHashDirectiveArgumentNonQuotes
let parse (numStr: string) =
let trimPrefix (s: string) =
if s.StartsWithOrdinal "FS" then s[2..] else s
let tryParseIntWithFailAction (s: string) (failAction: unit -> unit) =
match Int32.TryParse s with
| true, n -> Some n
| false, _ ->
failAction ()
None
let warnInvalid () =
warning (Error(FSComp.SR.buildInvalidWarningNumber numStr, m))
if source = WarningNumberSource.CommandLineOption then
tryParseIntWithFailAction (trimPrefix numStr) id
elif langVersion.SupportsFeature(argFeature) then
tryParseIntWithFailAction (trimPrefix numStr) warnInvalid
else
tryParseIntWithFailAction numStr id
match description with
| WarningDescription.Int32 n ->
if tryCheckLanguageFeatureAndRecover langVersion argFeature m then
Some n
else
None
| WarningDescription.String s ->
if
source = WarningNumberSource.CompilerDirective
&& not (langVersion.SupportsFeature argFeature)
&& s.StartsWithOrdinal "FS"
then
warning (Error(FSComp.SR.buildInvalidWarningNumber s, m))
parse s
| WarningDescription.Ident ident ->
if tryCheckLanguageFeatureAndRecover langVersion argFeature m then
parse ident.idText
else
None
let ComputeMakePathAbsolute implicitIncludeDir (path: string) =
try
// remove any quotation marks from the path first
let path = path.Replace("\"", "")
if not (FileSystem.IsPathRootedShim path) then
Path.Combine(implicitIncludeDir, path)
else
path
with :? ArgumentException ->
path
//----------------------------------------------------------------------------
// Configuration
//----------------------------------------------------------------------------
[<RequireQualifiedAccess>]
type CompilerTarget =
| WinExe
| ConsoleExe
| Dll
| Module
member x.IsExe =
(match x with
| ConsoleExe
| WinExe -> true
| _ -> false)
[<RequireQualifiedAccess>]
type ResolveAssemblyReferenceMode =
| Speculative
| ReportErrors
[<RequireQualifiedAccess>]
type CopyFSharpCoreFlag =
| Yes
| No
/// Represents the file or string used for the --version flag
type VersionFlag =
| VersionString of string
| VersionFile of string
| VersionNone
member x.GetVersionInfo implicitIncludeDir =
let vstr = x.GetVersionString implicitIncludeDir
try
parseILVersion vstr
with _ ->
errorR (Error(FSComp.SR.buildInvalidVersionString vstr, rangeStartup))
parseILVersion "0.0.0.0"
member x.GetVersionString implicitIncludeDir =
match x with
| VersionString s -> s
| VersionFile s ->
let s =
if FileSystem.IsPathRootedShim s then
s
else
Path.Combine(implicitIncludeDir, s)
if not (FileSystem.FileExistsShim s) then
errorR (Error(FSComp.SR.buildInvalidVersionFile s, rangeStartup))
"0.0.0.0"
else
use fs = FileSystem.OpenFileForReadShim(s)
use is = new StreamReader(fs)
!! is.ReadLine()
| VersionNone -> "0.0.0.0"
/// Represents a reference to an assembly. May be backed by a real assembly on disk, or a cross-project
/// reference backed by information generated by the compiler service.
type IRawFSharpAssemblyData =
/// The raw list AutoOpenAttribute attributes in the assembly
abstract GetAutoOpenAttributes: unit -> string list
/// The raw list InternalsVisibleToAttribute attributes in the assembly
abstract GetInternalsVisibleToAttributes: unit -> string list
/// The raw IL module definition in the assembly, if any. This is not present for cross-project references
/// in the language service
abstract TryGetILModuleDef: unit -> ILModuleDef option
/// The raw F# signature data in the assembly, if any
abstract GetRawFSharpSignatureData:
range * ilShortAssemName: string * fileName: string ->
(string * ((unit -> ReadOnlyByteMemory) * (unit -> ReadOnlyByteMemory) option)) list
/// The raw F# optimization data in the assembly, if any
abstract GetRawFSharpOptimizationData:
range * ilShortAssemName: string * fileName: string ->
(string * ((unit -> ReadOnlyByteMemory) * (unit -> ReadOnlyByteMemory) option)) list
/// The table of type forwarders in the assembly
abstract GetRawTypeForwarders: unit -> ILExportedTypesAndForwarders
/// The identity of the module
abstract ILScopeRef: ILScopeRef
abstract ILAssemblyRefs: ILAssemblyRef list
abstract ShortAssemblyName: string
/// Indicates if the assembly has any F# signature data attribute
abstract HasAnyFSharpSignatureDataAttribute: bool
/// Indicates if the assembly has an F# signature data attribute suitable for use with this version of F# tooling
abstract HasMatchingFSharpSignatureDataAttribute: bool
/// Cache of time stamps as we traverse a project description
type TimeStampCache(defaultTimeStamp: DateTime) =
let files = ConcurrentDictionary<string, DateTime>()
let projects =
ConcurrentDictionary<IProjectReference, DateTime>(HashIdentity.Reference)
member _.GetFileTimeStamp fileName =
let ok, v = files.TryGetValue fileName
if ok then
v
else
let v = FileSystem.GetLastWriteTimeShim fileName
files[fileName] <- v
v
member cache.GetProjectReferenceTimeStamp(projectReference: IProjectReference) =
let ok, v = projects.TryGetValue projectReference
if ok then
v
else
let v = defaultArg (projectReference.TryGetLogicalTimeStamp cache) defaultTimeStamp
projects[projectReference] <- v
v
and [<RequireQualifiedAccess>] ProjectAssemblyDataResult =
| Available of IRawFSharpAssemblyData
| Unavailable of useOnDiskInstead: bool
and IProjectReference =
/// The name of the assembly file generated by the project
abstract FileName: string
/// Evaluate raw contents of the assembly file generated by the project
abstract EvaluateRawContents: unit -> Async<ProjectAssemblyDataResult>
/// Get the logical timestamp that would be the timestamp of the assembly file generated by the project
///
/// For project references this is maximum of the timestamps of all dependent files.
/// The project is not actually built, nor are any assemblies read, but the timestamps for each dependent file
/// are read via the FileSystem. If the files don't exist, then a default timestamp is used.
///
/// The operation returns None only if it is not possible to create an IncrementalBuilder for the project at all, e.g. if there
/// are fatal errors in the options for the project.
abstract TryGetLogicalTimeStamp: cache: TimeStampCache -> DateTime option
type AssemblyReference =
| AssemblyReference of range: range * text: string * projectReference: IProjectReference option
member x.Range = (let (AssemblyReference(m, _, _)) = x in m)
member x.Text = (let (AssemblyReference(_, text, _)) = x in text)
member x.ProjectReference = (let (AssemblyReference(_, _, contents)) = x in contents)
member x.SimpleAssemblyNameIs name =
(String.Compare(FileSystemUtils.fileNameWithoutExtensionWithValidate false x.Text, name, StringComparison.OrdinalIgnoreCase) = 0)
|| not (x.Text.Contains "/")
&& not (x.Text.Contains "\\")
&& not (x.Text.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase))
&& not (x.Text.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase))
&& (try
let aname = System.Reflection.AssemblyName x.Text in aname.Name = name
with _ ->
false)
override x.ToString() = sprintf "AssemblyReference(%s)" x.Text
type UnresolvedAssemblyReference = UnresolvedAssemblyReference of string * AssemblyReference list
#if !NO_TYPEPROVIDERS
type ResolvedExtensionReference = ResolvedExtensionReference of string * AssemblyReference list * Tainted<ITypeProvider> list
#endif
type ImportedAssembly =
{
ILScopeRef: ILScopeRef
FSharpViewOfMetadata: CcuThunk
AssemblyAutoOpenAttributes: string list
AssemblyInternalsVisibleToAttributes: string list
#if !NO_TYPEPROVIDERS
IsProviderGenerated: bool
mutable TypeProviders: Tainted<ITypeProvider> list
#endif
FSharpOptimizationData: Microsoft.FSharp.Control.Lazy<Optimizer.LazyModuleInfo option>
}
type AvailableImportedAssembly =
| ResolvedImportedAssembly of ImportedAssembly
| UnresolvedImportedAssembly of string
type CcuLoadFailureAction =
| RaiseError
| ReturnNone
type Directive =
| Resolution
| Include
type LStatus =
| Unprocessed
| Processed
type TokenizeOption =
| AndCompile
| Only
| Debug
| Unfiltered
type PackageManagerLine =
{
Directive: Directive
LineStatus: LStatus
Line: string
Range: range
}
static member AddLineWithKey
(packageKey: string)
(directive: Directive)
(line: string)
(m: range)
(packageManagerLines: Map<string, PackageManagerLine list>)
: Map<string, PackageManagerLine list> =
let path = PackageManagerLine.StripDependencyManagerKey packageKey line
let newLine =
{
Directive = directive
LineStatus = LStatus.Unprocessed
Line = path
Range = m
}
let oldLines = MultiMap.find packageKey packageManagerLines
let newLines = oldLines @ [ newLine ]
packageManagerLines.Add(packageKey, newLines)
static member RemoveUnprocessedLines
(packageKey: string)
(packageManagerLines: Map<string, PackageManagerLine list>)
: Map<string, PackageManagerLine list> =
let oldLines = MultiMap.find packageKey packageManagerLines
let newLines =
oldLines |> List.filter (fun line -> line.LineStatus = LStatus.Processed)
packageManagerLines.Add(packageKey, newLines)
static member SetLinesAsProcessed
(packageKey: string)
(packageManagerLines: Map<string, PackageManagerLine list>)
: Map<string, PackageManagerLine list> =
let oldLines = MultiMap.find packageKey packageManagerLines
let newLines =
oldLines
|> List.map (fun line ->
{ line with
LineStatus = LStatus.Processed
})
packageManagerLines.Add(packageKey, newLines)
static member StripDependencyManagerKey (packageKey: string) (line: string) : string =
line.Substring(packageKey.Length + 1).Trim()
[<RequireQualifiedAccess>]
type MetadataAssemblyGeneration =
| None
| ReferenceOut of outputPath: string
| ReferenceOnly
[<RequireQualifiedAccess>]
type ParallelReferenceResolution =
| On
| Off
[<RequireQualifiedAccess>]
type TypeCheckingMode =
| Sequential
| Graph
[<RequireQualifiedAccess>]
type TypeCheckingConfig =
{
Mode: TypeCheckingMode
DumpGraph: bool
}
[<NoEquality; NoComparison>]
type TcConfigBuilder =
{
mutable primaryAssembly: PrimaryAssembly
mutable noFeedback: bool
mutable stackReserveSize: int32 option
mutable implicitIncludeDir: string (* normally "." *)
mutable openDebugInformationForLaterStaticLinking: bool (* only for --standalone *)
defaultFSharpBinariesDir: string
mutable compilingFSharpCore: bool
mutable useIncrementalBuilder: bool
mutable includes: string list
mutable implicitOpens: string list
mutable useFsiAuxLib: bool
mutable implicitlyReferenceDotNetAssemblies: bool
mutable resolutionEnvironment: LegacyResolutionEnvironment
mutable implicitlyResolveAssemblies: bool
mutable indentationAwareSyntax: bool option
mutable conditionalDefines: string list
mutable loadedSources: (range * string * string) list
mutable compilerToolPaths: string list
mutable referencedDLLs: AssemblyReference list
mutable packageManagerLines: Map<string, PackageManagerLine list>
mutable projectReferences: IProjectReference list
mutable knownUnresolvedReferences: UnresolvedAssemblyReference list
reduceMemoryUsage: ReduceMemoryFlag
mutable subsystemVersion: int * int
mutable useHighEntropyVA: bool
mutable inputCodePage: int option
mutable clearResultsCache: bool
mutable embedResources: string list
mutable diagnosticsOptions: FSharpDiagnosticOptions
mutable mlCompatibility: bool
mutable checkNullness: bool
mutable checkOverflow: bool
mutable showReferenceResolutions: bool
mutable outputDir: string option
mutable outputFile: string option
mutable platform: ILPlatform option
mutable prefer32Bit: bool
mutable useSimpleResolution: bool
mutable target: CompilerTarget
mutable debuginfo: bool
mutable testFlagEmitFeeFeeAs100001: bool
mutable dumpDebugInfo: bool
mutable debugSymbolFile: string option
(* Backend configuration *)
mutable typeCheckOnly: bool
mutable parseOnly: bool
mutable importAllReferencesOnly: bool
mutable simulateException: string option
mutable printAst: bool
mutable tokenize: TokenizeOption
mutable testInteractionParser: bool
mutable reportNumDecls: bool
mutable printSignature: bool
mutable printSignatureFile: string
mutable printAllSignatureFiles: bool
mutable xmlDocOutputFile: string option
mutable stats: bool
mutable generateFilterBlocks:
bool (* Previously marked with: `don't generate filter blocks due to bugs on Mono`. However, the related bug has been fixed: https://github.com/dotnet/linker/issues/2181 *)
mutable signer: string option
mutable container: string option
mutable delaysign: bool
mutable publicsign: bool
mutable version: VersionFlag
mutable metadataVersion: string option
mutable standalone: bool
mutable extraStaticLinkRoots: string list
mutable compressMetadata: bool
mutable noSignatureData: bool
mutable onlyEssentialOptimizationData: bool
mutable useOptimizationDataFile: bool
mutable jitTracking: bool
mutable portablePDB: bool
mutable embeddedPDB: bool
mutable embedAllSource: bool
mutable embedSourceList: string list
mutable sourceLink: string
mutable internConstantStrings: bool
mutable extraOptimizationIterations: int
mutable win32icon: string
mutable win32res: string
mutable win32manifest: string
mutable includewin32manifest: bool
mutable linkResources: string list
mutable legacyReferenceResolver: LegacyReferenceResolver
mutable showFullPaths: bool
mutable diagnosticStyle: DiagnosticStyle
mutable utf8output: bool
mutable flatErrors: bool
mutable maxErrors: int
mutable abortOnError: bool (* intended for fsi scripts that should exit on first error *)
mutable baseAddress: int32 option
mutable checksumAlgorithm: HashAlgorithm
#if DEBUG
mutable showOptimizationData: bool
#endif
mutable showTerms: bool (* show terms between passes? *)
mutable writeTermsToFiles: bool (* show terms to files? *)
mutable doDetuple: bool (* run detuple pass? *)
mutable doTLR: bool (* run TLR pass? *)
mutable doFinalSimplify: bool (* do final simplification pass *)
mutable optsOn: bool (* optimizations are turned on *)
mutable optSettings: Optimizer.OptimizationSettings
mutable emitTailcalls: bool
mutable deterministic: bool
mutable parallelParsing: bool
mutable parallelIlxGen: bool
mutable emitMetadataAssembly: MetadataAssemblyGeneration
mutable preferredUiLang: string option
mutable lcid: int option
mutable productNameForBannerText: string
/// show the MS (c) notice, e.g. with help or fsi?
mutable showBanner: bool
/// show times between passes?
mutable showTimes: bool
mutable writeTimesToFile: string option
mutable showLoadedAssemblies: bool
mutable continueAfterParseFailure: bool
#if !NO_TYPEPROVIDERS
/// show messages about extension type resolution?
mutable showExtensionTypeMessages: bool
#endif
/// Pause between passes?
mutable pause: bool
/// Whenever possible, emit callvirt instead of call
mutable alwaysCallVirt: bool
/// If true, strip away data that would not be of use to end users, but is useful to us for debugging
mutable noDebugAttributes: bool
/// If true, do not emit ToString implementations for unions, records, structs, exceptions
mutable useReflectionFreeCodeGen: bool
/// If true, indicates all type checking and code generation is in the context of fsi.exe
isInteractive: bool
isInvalidationSupported: bool
/// If true - every expression in quotations will be augmented with full debug info (fileName, location in file)
mutable emitDebugInfoInQuotations: bool
mutable strictIndentation: bool option
mutable exename: string option
// If true - the compiler will copy FSharp.Core.dll along the produced binaries
mutable copyFSharpCore: CopyFSharpCoreFlag
/// When false FSI will lock referenced assemblies requiring process restart, false = disable Shadow Copy false, the default
mutable shadowCopyReferences: bool
mutable useSdkRefs: bool
mutable fxResolver: FxResolver option
mutable bufferWidth: int option
// Is F# Interactive using multi-assembly emit?
mutable fsiMultiAssemblyEmit: bool
/// specify the error range for FxResolver
rangeForErrors: range
/// Override the SDK directory used by FxResolver, used for FCS only
sdkDirOverride: string option
/// A function to call to try to get an object that acts as a snapshot of the metadata section of a .NET binary,
/// and from which we can read the metadata. Only used when metadataOnly=true.
mutable tryGetMetadataSnapshot: ILReaderTryGetMetadataSnapshot
mutable internalTestSpanStackReferring: bool
mutable noConditionalErasure: bool
mutable applyLineDirectives: bool
mutable pathMap: PathMap
mutable langVersion: LanguageVersion
mutable xmlDocInfoLoader: IXmlDocumentationInfoLoader option
mutable exiter: Exiter
mutable parallelReferenceResolution: ParallelReferenceResolution
mutable captureIdentifiersWhenParsing: bool
mutable typeCheckingConfig: TypeCheckingConfig
mutable dumpSignatureData: bool
mutable realsig: bool
mutable compilationMode: TcGlobals.CompilationMode
}
// Directories to start probing in
// Algorithm:
// Search for native libraries using:
// 1. Include directories
// 2. compilerToolPath directories
// 3. reference dll's
// 4. The implicit include directory
//
// NOTE: it is important this is a delayed IEnumerable sequence. It is recomputed
// each time a resolution happens and additional paths may be added as a result.
member tcConfigB.GetNativeProbingRoots() =
seq {
yield! tcConfigB.includes
yield! tcConfigB.compilerToolPaths
yield!
(tcConfigB.referencedDLLs
|> Seq.map (fun ref -> !! Path.GetDirectoryName(ref.Text)))
tcConfigB.implicitIncludeDir
}
|> Seq.distinct
static member CreateNew
(
legacyReferenceResolver,
defaultFSharpBinariesDir,
reduceMemoryUsage,
implicitIncludeDir,
isInteractive,
isInvalidationSupported,
defaultCopyFSharpCore,
tryGetMetadataSnapshot,
sdkDirOverride,
rangeForErrors
) =
let defaultFSharpBinariesDir =
nullArgCheck "defaultFSharpBinariesDir" defaultFSharpBinariesDir
// These are all default values, many can be overridden using the command line switch
{
primaryAssembly = PrimaryAssembly.Mscorlib
indentationAwareSyntax = None
noFeedback = false
stackReserveSize = None
conditionalDefines = []
openDebugInformationForLaterStaticLinking = false
compilingFSharpCore = false
useIncrementalBuilder = false
implicitOpens = []
includes = []
resolutionEnvironment = LegacyResolutionEnvironment.EditingOrCompilation false
implicitlyReferenceDotNetAssemblies = true
implicitlyResolveAssemblies = true
compilerToolPaths = []
referencedDLLs = []
packageManagerLines = Map.empty
projectReferences = []
knownUnresolvedReferences = []
loadedSources = []
diagnosticsOptions = FSharpDiagnosticOptions.Default
embedResources = []
inputCodePage = None
clearResultsCache = false
subsystemVersion = 4, 0 // per spec for 357994
useHighEntropyVA = false
mlCompatibility = false
checkNullness = false
checkOverflow = false
showReferenceResolutions = false
outputDir = None
outputFile = None
platform = None
prefer32Bit = false
useSimpleResolution = false
target = CompilerTarget.ConsoleExe
debuginfo = false
testFlagEmitFeeFeeAs100001 = false
dumpDebugInfo = false
debugSymbolFile = None
(* Backend configuration *)
typeCheckOnly = false
parseOnly = false
importAllReferencesOnly = false
simulateException = None
printAst = false
tokenize = TokenizeOption.AndCompile
testInteractionParser = false
reportNumDecls = false
printSignature = false
printSignatureFile = ""
printAllSignatureFiles = false
xmlDocOutputFile = None
stats = false
generateFilterBlocks = false (* This was set as false due to an older bug in Mono https://github.com/dotnet/linker/issues/2181. This has been fixed in the meantime. *)
signer = None
container = None
maxErrors = 100
abortOnError = false
baseAddress = None
checksumAlgorithm = HashAlgorithm.Sha256
delaysign = false
publicsign = false
version = VersionNone
metadataVersion = None
standalone = false
extraStaticLinkRoots = []
compressMetadata = true
noSignatureData = false
onlyEssentialOptimizationData = false
useOptimizationDataFile = false
jitTracking = true
portablePDB = true
embeddedPDB = false
embedAllSource = false
embedSourceList = []
sourceLink = ""
internConstantStrings = true
extraOptimizationIterations = 0
win32icon = ""
win32res = ""
win32manifest = ""
includewin32manifest = true
linkResources = []
showFullPaths = false
diagnosticStyle = DiagnosticStyle.Default
utf8output = false
flatErrors = false
#if DEBUG
showOptimizationData = false
#endif
showTerms = false
writeTermsToFiles = false
doDetuple = false
doTLR = false
doFinalSimplify = false
optsOn = false
optSettings =
{ OptimizationSettings.Defaults with
processingMode =
if FSharpExperimentalFeaturesEnabledAutomatically then
OptimizationProcessingMode.Parallel
else
OptimizationProcessingMode.Sequential
}
emitTailcalls = true
deterministic = false
parallelParsing = true
parallelIlxGen = FSharpExperimentalFeaturesEnabledAutomatically
emitMetadataAssembly = MetadataAssemblyGeneration.None
preferredUiLang = None
lcid = None
productNameForBannerText = FSharpProductName
showBanner = true
showTimes = false
writeTimesToFile = None
showLoadedAssemblies = false
continueAfterParseFailure = false
#if !NO_TYPEPROVIDERS
showExtensionTypeMessages = false
#endif
pause = false
alwaysCallVirt = true
noDebugAttributes = false
useReflectionFreeCodeGen = false
emitDebugInfoInQuotations = false
exename = None
shadowCopyReferences = false
useSdkRefs = true
fxResolver = None
bufferWidth = None
fsiMultiAssemblyEmit = true
internalTestSpanStackReferring = false
noConditionalErasure = false
pathMap = PathMap.empty
applyLineDirectives = true
langVersion = LanguageVersion.Default
implicitIncludeDir = implicitIncludeDir
defaultFSharpBinariesDir = defaultFSharpBinariesDir
reduceMemoryUsage = reduceMemoryUsage
legacyReferenceResolver = legacyReferenceResolver
isInteractive = isInteractive
isInvalidationSupported = isInvalidationSupported
copyFSharpCore = defaultCopyFSharpCore
tryGetMetadataSnapshot = tryGetMetadataSnapshot
useFsiAuxLib = isInteractive
rangeForErrors = rangeForErrors
sdkDirOverride = sdkDirOverride
xmlDocInfoLoader = None
exiter = QuitProcessExiter
parallelReferenceResolution = ParallelReferenceResolution.Off
captureIdentifiersWhenParsing = false
typeCheckingConfig =
{
TypeCheckingConfig.Mode =
if FSharpExperimentalFeaturesEnabledAutomatically then
TypeCheckingMode.Graph
else
TypeCheckingMode.Sequential
DumpGraph = false
}
dumpSignatureData = false
realsig = false
strictIndentation = None
compilationMode = TcGlobals.CompilationMode.Unset
}
member tcConfigB.FxResolver =
// We compute the FxResolver on-demand. It depends on some configuration parameters
// which may be later adjusted.
match tcConfigB.fxResolver with
| None ->
let useDotNetFramework = (tcConfigB.primaryAssembly = PrimaryAssembly.Mscorlib)
let fxResolver =
FxResolver(
useDotNetFramework,
tcConfigB.implicitIncludeDir,
rangeForErrors = tcConfigB.rangeForErrors,
useSdkRefs = tcConfigB.useSdkRefs,
isInteractive = tcConfigB.isInteractive,
sdkDirOverride = tcConfigB.sdkDirOverride
)
tcConfigB.fxResolver <- Some fxResolver
fxResolver
| Some fxResolver -> fxResolver
member tcConfigB.SetPrimaryAssembly primaryAssembly =
tcConfigB.primaryAssembly <- primaryAssembly
tcConfigB.fxResolver <- None // this needs to be recreated when the primary assembly changes
member tcConfigB.SetUseSdkRefs useSdkRefs =
tcConfigB.useSdkRefs <- useSdkRefs
tcConfigB.fxResolver <- None // this needs to be recreated when the primary assembly changes
member tcConfigB.ResolveSourceFile(m, nm, pathLoadedFrom) =
use _ = UseBuildPhase BuildPhase.Parameter
let paths =
seq {
yield! tcConfigB.includes
yield pathLoadedFrom
}
ResolveFileUsingPaths(paths, m, nm)
/// Decide names of output file, pdb and assembly
member tcConfigB.DecideNames sourceFiles =
use _ = UseBuildPhase BuildPhase.Parameter
if List.isEmpty sourceFiles then
errorR (Error(FSComp.SR.buildNoInputsSpecified (), rangeCmdArgs))
let ext () =
match tcConfigB.target with
| CompilerTarget.Dll -> ".dll"
| CompilerTarget.Module -> ".netmodule"
| CompilerTarget.ConsoleExe
| CompilerTarget.WinExe -> ".exe"
let implFiles =
sourceFiles
|> List.filter (fun fileName -> List.exists (FileSystemUtils.checkSuffix fileName) FSharpImplFileSuffixes)
let outfile =
match tcConfigB.outputFile, List.rev implFiles with
| None, [] -> "out" + ext ()
| None, h :: _ ->
let basic = FileSystemUtils.fileNameOfPath h
let modname =
try
FileSystemUtils.chopExtension basic
with _ ->
basic
modname + (ext ())
| Some f, _ -> f
let assemblyName =
let baseName = FileSystemUtils.fileNameOfPath outfile
(FileSystemUtils.fileNameWithoutExtension baseName)
let pdbfile =
if tcConfigB.debuginfo then
Some(
match tcConfigB.debugSymbolFile with
| None -> getDebugFileName outfile
| Some f -> f
)
elif (tcConfigB.debugSymbolFile <> None) && (not tcConfigB.debuginfo) then
error (Error(FSComp.SR.buildPdbRequiresDebug (), rangeStartup))
else
None
tcConfigB.outputFile <- Some outfile
outfile, pdbfile, assemblyName
member tcConfigB.TurnWarningOff(m, s: string) =
use _ = UseBuildPhase BuildPhase.Parameter
match GetWarningNumber(m, WarningDescription.String s, tcConfigB.langVersion, WarningNumberSource.CommandLineOption) with
| None -> ()
| Some n ->
// nowarn:62 turns on mlCompatibility, e.g. shows ML compat items in intellisense menus
if n = 62 then
tcConfigB.mlCompatibility <- true
tcConfigB.diagnosticsOptions <-
{ tcConfigB.diagnosticsOptions with
WarnOff = ListSet.insert (=) n tcConfigB.diagnosticsOptions.WarnOff
}
member tcConfigB.TurnWarningOn(m, s: string) =
use _ = UseBuildPhase BuildPhase.Parameter
match GetWarningNumber(m, WarningDescription.String s, tcConfigB.langVersion, WarningNumberSource.CommandLineOption) with
| None -> ()
| Some n ->
// warnon 62 turns on mlCompatibility, e.g. shows ML compat items in intellisense menus
if n = 62 then
tcConfigB.mlCompatibility <- false
tcConfigB.diagnosticsOptions <-
{ tcConfigB.diagnosticsOptions with
WarnOn = ListSet.insert (=) n tcConfigB.diagnosticsOptions.WarnOn
}