Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/Compiler/Driver/CompilerConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,28 +1378,6 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =

member _.GetNativeProbingRoots() = data.GetNativeProbingRoots()

/// A closed set of assemblies where, for any subset S:
/// - the TcImports object built for S (and thus the F# Compiler CCUs for the assemblies in S)
/// is a resource that can be shared between any two IncrementalBuild objects that reference
/// precisely S
///
/// Determined by looking at the set of assemblies referenced by f# .
///
/// Returning true may mean that the file is locked and/or placed into the
/// 'framework' reference set that is potentially shared across multiple compilations.
member tcConfig.IsSystemAssembly(fileName: string) =
try
FileSystem.FileExistsShim fileName
&& ((tcConfig.GetTargetFrameworkDirectories()
|> List.exists (fun clrRoot -> clrRoot = Path.GetDirectoryName fileName))
|| (tcConfig
.FxResolver
.GetSystemAssemblies()
.Contains(FileSystemUtils.fileNameWithoutExtension fileName))
|| tcConfig.FxResolver.IsInReferenceAssemblyPackDirectory fileName)
with _ ->
false

member tcConfig.GenerateSignatureData =
not tcConfig.standalone && not tcConfig.noSignatureData

Expand Down
2 changes: 0 additions & 2 deletions src/Compiler/Driver/CompilerConfig.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,6 @@ type TcConfig =

member GetSearchPathsForLibraryFiles: unit -> string list

member IsSystemAssembly: string -> bool

member PrimaryAssemblyDllReference: unit -> AssemblyReference

member CoreLibraryDllReference: unit -> AssemblyReference
Expand Down
250 changes: 41 additions & 209 deletions src/Compiler/Driver/CompilerImports.fs

Large diffs are not rendered by default.

26 changes: 6 additions & 20 deletions src/Compiler/Driver/CompilerImports.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ type AssemblyResolution =
/// Create the tooltip text for the assembly reference
prepareToolTip: unit -> string

/// Whether or not this is an installed system assembly (for example, System.dll)
sysdir: bool

/// Lazily populated ilAssemblyRef for this reference.
mutable ilAssemblyRef: ILAssemblyRef option
}
Expand Down Expand Up @@ -124,14 +121,11 @@ type TcAssemblyResolutions =

member GetAssemblyResolutions: unit -> AssemblyResolution list

static member SplitNonFoundationalResolutions:
tcConfig: TcConfig -> AssemblyResolution list * AssemblyResolution list * UnresolvedAssemblyReference list
member GetUnresolvedReferences: unit -> UnresolvedAssemblyReference list

static member BuildFromPriorResolutions:
tcConfig: TcConfig * AssemblyResolution list * UnresolvedAssemblyReference list -> TcAssemblyResolutions
static member ResolveAssemblyReferences: tcConfig: TcConfig -> TcAssemblyResolutions

static member GetAssemblyResolutionInformation:
tcConfig: TcConfig -> AssemblyResolution list * UnresolvedAssemblyReference list
static member GetAssemblyResolutionInformation: tcConfig: TcConfig -> TcAssemblyResolutions

[<Sealed>]
type RawFSharpAssemblyData =
Expand All @@ -153,9 +147,6 @@ type TcImports =

member GetCcusInDeclOrder: unit -> CcuThunk list

/// This excludes any framework imports (which may be shared between multiple builds)
member GetCcusExcludingBase: unit -> CcuThunk list

member FindDllInfo: CompilationThreadToken * range * string -> ImportedBinary

member TryFindDllInfo: CompilationThreadToken * range * string * lookupOnly: bool -> ImportedBinary option
Expand Down Expand Up @@ -196,14 +187,9 @@ type TcImports =

member SystemRuntimeContainsType: string -> bool

member internal Base: TcImports option

static member BuildFrameworkTcImports:
TcConfigProvider * AssemblyResolution list * AssemblyResolution list -> NodeCode<TcGlobals * TcImports>

static member BuildNonFrameworkTcImports:
TcConfigProvider * TcImports * AssemblyResolution list * UnresolvedAssemblyReference list * DependencyProvider ->
NodeCode<TcImports>
static member BuildTcImports:
tcConfigP: TcConfigProvider * tcResolutions: TcAssemblyResolutions * dependencyProvider: DependencyProvider ->
NodeCode<TcGlobals * TcImports>

static member BuildTcImports:
tcConfigP: TcConfigProvider * dependencyProvider: DependencyProvider -> NodeCode<TcGlobals * TcImports>
Expand Down
17 changes: 9 additions & 8 deletions src/Compiler/Driver/ScriptClosure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,13 @@ module ScriptPreprocessClosure =

use unwindEL = PushDiagnosticsLoggerPhaseUntilUnwind(fun _ -> diagnosticsLogger)

let references, unresolvedReferences =
TcAssemblyResolutions.GetAssemblyResolutionInformation(tcConfig)
let tcResolutions = TcAssemblyResolutions.GetAssemblyResolutionInformation(tcConfig)

let resolutions = tcResolutions.GetAssemblyResolutions()
let unresolved = tcResolutions.GetUnresolvedReferences()

let references = references |> List.map (fun ar -> ar.resolvedPath, ar)
references, unresolvedReferences, diagnosticsLogger.Diagnostics
let references = resolutions |> List.map (fun ar -> ar.resolvedPath, ar)
references, unresolved, diagnosticsLogger.Diagnostics

// Root errors and warnings - look at the last item in the closureFiles list
let loadClosureRootDiagnostics, allRootDiagnostics =
Expand Down Expand Up @@ -662,14 +664,13 @@ module ScriptPreprocessClosure =
reduceMemoryUsage
)

let resolutions0, _unresolvedReferences =
let tcResolutions0 =
TcAssemblyResolutions.GetAssemblyResolutionInformation(tcConfig)

let references0 =
resolutions0
tcResolutions0.GetAssemblyResolutions()
|> List.map (fun r -> r.originalReference.Range, r.resolvedPath)
|> Seq.distinct
|> List.ofSeq
|> List.distinct

references0, tcConfig.assumeDotNetFramework, scriptDefaultReferencesDiagnostics

Expand Down
61 changes: 13 additions & 48 deletions src/Compiler/Driver/fsc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ let main1
if not bannerAlreadyPrinted then
Console.Write(GetBannerText tcConfigB)

// Create tcGlobals and frameworkTcImports
// Create tcGlobals and tcImports
let outfile, pdbfile, assemblyName =
try
tcConfigB.DecideNames sourceFiles
Expand Down Expand Up @@ -585,22 +585,19 @@ let main1
ReportTime tcConfig "Import mscorlib and FSharp.Core.dll"
let foundationalTcConfigP = TcConfigProvider.Constant tcConfig

let sysRes, otherRes, knownUnresolved =
TcAssemblyResolutions.SplitNonFoundationalResolutions(tcConfig)

// Import basic assemblies
let tcGlobals, frameworkTcImports =
TcImports.BuildFrameworkTcImports(foundationalTcConfigP, sysRes, otherRes)
// Import assemblies
let tcGlobals, tcImports =
TcImports.BuildTcImports(foundationalTcConfigP, dependencyProvider)
|> NodeCode.RunImmediateWithoutCancellation

// register tcImports to be disposed in future
disposables.Register tcImports

let ilSourceDocs =
[
for sourceFile in sourceFiles -> tcGlobals.memoize_file (FileIndex.fileIndexOfFile sourceFile)
]

// Register framework tcImports to be disposed in future
disposables.Register frameworkTcImports

// Parse sourceFiles
ReportTime tcConfig "Parse inputs"
use unwindParsePhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse
Expand Down Expand Up @@ -636,18 +633,6 @@ let main1
||> List.fold (fun z (input, sourceFileDirectory) ->
ApplyMetaCommandsFromInputToTcConfig(z, input, sourceFileDirectory, dependencyProvider))

let tcConfigP = TcConfigProvider.Constant tcConfig

// Import other assemblies
ReportTime tcConfig "Import non-system references"

let tcImports =
TcImports.BuildNonFrameworkTcImports(tcConfigP, frameworkTcImports, otherRes, knownUnresolved, dependencyProvider)
|> NodeCode.RunImmediateWithoutCancellation

// register tcImports to be disposed in future
disposables.Register tcImports

if not tcConfig.continueAfterParseFailure then
AbortOnError(diagnosticsLogger, exiter)

Expand Down Expand Up @@ -687,7 +672,6 @@ let main1
ctok,
tcGlobals,
tcImports,
frameworkTcImports,
tcState.Ccu,
typedAssembly,
topAttrs,
Expand Down Expand Up @@ -812,16 +796,13 @@ let main1OfAst
ReportTime tcConfig "Import mscorlib and FSharp.Core.dll"
let foundationalTcConfigP = TcConfigProvider.Constant tcConfig

let sysRes, otherRes, knownUnresolved =
TcAssemblyResolutions.SplitNonFoundationalResolutions(tcConfig)

// Import basic assemblies
let tcGlobals, frameworkTcImports =
TcImports.BuildFrameworkTcImports(foundationalTcConfigP, sysRes, otherRes)
let tcGlobals, tcImports =
TcImports.BuildTcImports(foundationalTcConfigP, dependencyProvider)
|> NodeCode.RunImmediateWithoutCancellation

// Register framework tcImports to be disposed in future
disposables.Register frameworkTcImports
// register tcImports to be disposed in future
disposables.Register tcImports

use unwindParsePhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse

Expand All @@ -831,18 +812,6 @@ let main1OfAst
(tcConfig, inputs)
||> List.fold (fun tcc inp -> ApplyMetaCommandsFromInputToTcConfig(tcc, inp, meta, dependencyProvider))

let tcConfigP = TcConfigProvider.Constant tcConfig

// Import other assemblies
ReportTime tcConfig "Import non-system references"

let tcImports =
TcImports.BuildNonFrameworkTcImports(tcConfigP, frameworkTcImports, otherRes, knownUnresolved, dependencyProvider)
|> NodeCode.RunImmediateWithoutCancellation

// register tcImports to be disposed in future
disposables.Register tcImports

// Build the initial type checking environment
ReportTime tcConfig "Typecheck"
use unwindParsePhase = PushThreadBuildPhaseUntilUnwind BuildPhase.TypeCheck
Expand Down Expand Up @@ -873,7 +842,6 @@ let main1OfAst
ctok,
tcGlobals,
tcImports,
frameworkTcImports,
tcState.Ccu,
typedAssembly,
topAttrs,
Expand All @@ -892,7 +860,6 @@ let main2
(Args (ctok,
tcGlobals,
tcImports: TcImports,
frameworkTcImports,
generatedCcu: CcuThunk,
typedImplFiles,
topAttrs,
Expand Down Expand Up @@ -975,7 +942,6 @@ let main2
ctok,
tcConfig,
tcImports,
frameworkTcImports,
tcGlobals,
diagnosticsLogger,
generatedCcu,
Expand All @@ -997,8 +963,7 @@ let main2
let main3
(Args (ctok,
tcConfig,
tcImports,
frameworkTcImports: TcImports,
tcImports: TcImports,
tcGlobals,
diagnosticsLogger: DiagnosticsLogger,
generatedCcu: CcuThunk,
Expand Down Expand Up @@ -1028,7 +993,7 @@ let main3
match tcConfig.metadataVersion with
| Some v -> v
| _ ->
match frameworkTcImports.DllTable.TryFind tcConfig.primaryAssembly.Name with
match tcImports.DllTable.TryFind tcConfig.primaryAssembly.Name with
| Some ib -> ib.RawMetadata.TryGetILModuleDef().Value.MetadataVersion
| _ -> ""

Expand Down
16 changes: 4 additions & 12 deletions src/Compiler/Interactive/fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3308,8 +3308,8 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
match fsiOptions.WriteReferencesAndExit with
| Some outFile ->
let tcConfig = tcConfigP.Get(ctokStartup)
let references, _unresolvedReferences = TcAssemblyResolutions.GetAssemblyResolutionInformation(tcConfig)
let lines = [ for r in references -> r.resolvedPath ]
let tcResolutions = TcAssemblyResolutions.GetAssemblyResolutionInformation(tcConfig)
let lines = [ for r in tcResolutions.GetAssemblyResolutions() -> r.resolvedPath ]
FileSystem.OpenFileForWriteShim(outFile).WriteAllLines(lines)
exit 0
| _ -> ()
Expand Down Expand Up @@ -3346,21 +3346,13 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
/// on the FsiEvaluationSession.
let checker = FSharpChecker.Create(legacyReferenceResolver=legacyReferenceResolver)

let tcGlobals,frameworkTcImports,nonFrameworkResolutions,unresolvedReferences =
let tcGlobals, tcImports =
try
let tcConfig = tcConfigP.Get(ctokStartup)
checker.FrameworkImportsCache.Get tcConfig
TcImports.BuildTcImports(tcConfigP, fsiOptions.DependencyProvider)
|> NodeCode.RunImmediateWithoutCancellation
with e ->
stopProcessingRecovery e range0; failwithf "Error creating evaluation session: %A" e

let tcImports =
try
TcImports.BuildNonFrameworkTcImports(tcConfigP, frameworkTcImports, nonFrameworkResolutions, unresolvedReferences, fsiOptions.DependencyProvider)
|> NodeCode.RunImmediateWithoutCancellation
with e ->
stopProcessingRecovery e range0; failwithf "Error creating evaluation session: %A" e

let niceNameGen = NiceNameGenerator()

// Share intern'd strings across all lexing/parsing
Expand Down
Loading