Skip to content
Merged
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
2 changes: 0 additions & 2 deletions src/absil/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2092,9 +2092,7 @@ type ILPropertyRef =
member Name: string
interface System.IComparable

#if ENABLE_MONO_SUPPORT
val runningOnMono: bool
#endif

type ILReferences =
{ AssemblyReferences: ILAssemblyRef list;
Expand Down
2 changes: 0 additions & 2 deletions src/absil/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3807,11 +3807,9 @@ let rec genOpenBinaryReader infile is opts =
let pdb = None
#else
let pdb =
#if ENABLE_MONO_SUPPORT
if runningOnMono then
None
else
#endif
getPdbReader opts infile
#endif

Expand Down
38 changes: 19 additions & 19 deletions src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,9 +1579,9 @@ let OutputErrorOrWarningContext prefix fileLineFn os err =
let GetFSharpCoreLibraryName () = "FSharp.Core"

type internal TypeInThisAssembly = class end
let GetFSharpCoreReferenceUsedByCompiler(useMonoResolution) =
let GetFSharpCoreReferenceUsedByCompiler(useSimpleResolution) =
// On Mono, there is no good reference resolution
if useMonoResolution then
if useSimpleResolution then
GetFSharpCoreLibraryName()+".dll"
else
let fsCoreName = GetFSharpCoreLibraryName()
Expand Down Expand Up @@ -1698,8 +1698,8 @@ let SystemAssemblies primaryAssemblyName =
//
// REVIEW: it isn't clear if there is any negative effect
// of leaving an assembly off this list.
let BasicReferencesForScriptLoadClosure(useMonoResolution, useFsiAuxLib) =
["mscorlib"; GetFSharpCoreReferenceUsedByCompiler(useMonoResolution) ] @ // Need to resolve these explicitly so they will be found in the reference assemblies directory which is where the .xml files are.
let BasicReferencesForScriptLoadClosure(useSimpleResolution, useFsiAuxLib) =
["mscorlib"; GetFSharpCoreReferenceUsedByCompiler(useSimpleResolution) ] @ // Need to resolve these explicitly so they will be found in the reference assemblies directory which is where the .xml files are.
DefaultBasicReferencesForOutOfProjectSources @
[ if useFsiAuxLib then yield GetFsiLibraryName () ]

Expand Down Expand Up @@ -2011,7 +2011,7 @@ type TcConfigBuilder =
mutable resolutionAssemblyFoldersConditions : string;
mutable platform : ILPlatform option;
mutable prefer32Bit : bool;
mutable useMonoResolution : bool
mutable useSimpleResolution : bool
mutable target : CompilerTarget
mutable debuginfo : bool
mutable testFlagEmitFeeFeeAs100001 : bool;
Expand Down Expand Up @@ -2177,9 +2177,9 @@ type TcConfigBuilder =
platform = None;
prefer32Bit = false;
#if ENABLE_MONO_SUPPORT
useMonoResolution = runningOnMono
useSimpleResolution = runningOnMono
#else
useMonoResolution = false
useSimpleResolution = false
#endif
target = ConsoleExe
debuginfo = false
Expand Down Expand Up @@ -2531,7 +2531,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
match fileNameOpt with
| None ->
// if FSharp.Core was not provided explicitly - use version that was referenced by compiler
AssemblyReference(range0, GetFSharpCoreReferenceUsedByCompiler(data.useMonoResolution), None), None
AssemblyReference(range0, GetFSharpCoreReferenceUsedByCompiler(data.useSimpleResolution), None), None
| _ -> res
let primaryAssemblyCcuInitializer = getSystemRuntimeInitializer data.primaryAssembly (computeKnownDllReference >> fst)

Expand Down Expand Up @@ -2667,7 +2667,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
member x.resolutionAssemblyFoldersConditions = data. resolutionAssemblyFoldersConditions
member x.platform = data.platform
member x.prefer32Bit = data.prefer32Bit
member x.useMonoResolution = data.useMonoResolution
member x.useSimpleResolution = data.useSimpleResolution
member x.target = data.target
member x.debuginfo = data.debuginfo
member x.testFlagEmitFeeFeeAs100001 = data.testFlagEmitFeeFeeAs100001
Expand Down Expand Up @@ -2942,7 +2942,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
// NOTE!! if mode=ReportErrors then this method must not raise exceptions. It must just report the errors and recover
static member TryResolveLibsUsingMSBuildRules (tcConfig:TcConfig,originalReferences:AssemblyReference list, errorAndWarningRange:range, mode:ResolveAssemblyReferenceMode) : AssemblyResolution list * UnresolvedAssemblyReference list =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind (BuildPhase.Parameter)
if tcConfig.useMonoResolution then
if tcConfig.useSimpleResolution then
failwith "MSBuild resolution is not supported."
if originalReferences=[] then [],[]
else
Expand Down Expand Up @@ -3450,7 +3450,7 @@ type TcAssemblyResolutions(results : AssemblyResolution list, unresolved : Unres

static member Resolve (tcConfig:TcConfig,assemblyList:AssemblyReference list, knownUnresolved:UnresolvedAssemblyReference list) : TcAssemblyResolutions =
let resolved,unresolved =
if tcConfig.useMonoResolution then
if tcConfig.useSimpleResolution then
let resolutions =
assemblyList
|> List.map (fun assemblyReference ->
Expand Down Expand Up @@ -4449,7 +4449,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
| Some assemblyResolution ->
ResultD [assemblyResolution]
| None ->
if tcConfigP.Get().useMonoResolution then
if tcConfigP.Get().useSimpleResolution then
let action =
match mode with
| ResolveAssemblyReferenceMode.ReportErrors -> CcuLoadFailureAction.RaiseError
Expand Down Expand Up @@ -4857,15 +4857,15 @@ module private ScriptPreprocessClosure =
ParseOneInputLexbuf (tcConfig,lexResourceManager,defines,lexbuf,filename,isLastCompiland,errorLogger)

/// Create a TcConfig for load closure starting from a single .fsx file
let CreateScriptSourceTcConfig (filename:string, codeContext, useMonoResolution, useFsiAuxLib, basicReferences, applyCommandLineArgs) =
let CreateScriptSourceTcConfig (filename:string, codeContext, useSimpleResolution, useFsiAuxLib, basicReferences, applyCommandLineArgs) =
let projectDir = Path.GetDirectoryName(filename)
let isInteractive = (codeContext = CodeContext.Evaluation)
let isInvalidationSupported = (codeContext = CodeContext.Editing)
// always use primary assembly = mscorlib for scripts
let tcConfigB = TcConfigBuilder.CreateNew(Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler.Value, true (* optimize for memory *), projectDir, isInteractive, isInvalidationSupported)
applyCommandLineArgs tcConfigB
match basicReferences with
| None -> BasicReferencesForScriptLoadClosure(useMonoResolution, useFsiAuxLib) |> List.iter(fun f->tcConfigB.AddReferencedAssemblyByPath(range0,f)) // Add script references
| None -> BasicReferencesForScriptLoadClosure(useSimpleResolution, useFsiAuxLib) |> List.iter(fun f->tcConfigB.AddReferencedAssemblyByPath(range0,f)) // Add script references
| Some rs -> for m,r in rs do tcConfigB.AddReferencedAssemblyByPath(m,r)

tcConfigB.resolutionEnvironment <-
Expand Down Expand Up @@ -5026,18 +5026,18 @@ module private ScriptPreprocessClosure =
result

/// Given source text, find the full load closure. Used from service.fs, when editing a script file
let GetFullClosureOfScriptSource(filename,source,codeContext,useMonoResolution,useFsiAuxLib,lexResourceManager:Lexhelp.LexResourceManager,applyCommmandLineArgs) =
let GetFullClosureOfScriptSource(filename,source,codeContext,useSimpleResolution,useFsiAuxLib,lexResourceManager:Lexhelp.LexResourceManager,applyCommmandLineArgs) =
// Resolve the basic references such as FSharp.Core.dll first, before processing any #I directives in the script
//
// This is tries to mimic the action of running the script in F# Interactive - the initial context for scripting is created
// first, then #I and other directives are processed.
let references0 =
let tcConfig = CreateScriptSourceTcConfig(filename,codeContext,useMonoResolution,useFsiAuxLib,None,applyCommmandLineArgs)
let tcConfig = CreateScriptSourceTcConfig(filename,codeContext,useSimpleResolution,useFsiAuxLib,None,applyCommmandLineArgs)
let resolutions0,_unresolvedReferences = GetAssemblyResolutionInformation(tcConfig)
let references0 = resolutions0 |> List.map (fun r->r.originalReference.Range,r.resolvedPath) |> Seq.distinct |> List.ofSeq
references0

let tcConfig = CreateScriptSourceTcConfig(filename,codeContext,useMonoResolution,useFsiAuxLib,Some references0,applyCommmandLineArgs)
let tcConfig = CreateScriptSourceTcConfig(filename,codeContext,useSimpleResolution,useFsiAuxLib,Some references0,applyCommmandLineArgs)

let protoClosure = [SourceFile(filename,range0,source)]
let finalClosure,tcConfig = FindClosureDirectives(protoClosure,tcConfig,codeContext,lexResourceManager)
Expand All @@ -5053,9 +5053,9 @@ module private ScriptPreprocessClosure =

type LoadClosure with
// Used from service.fs, when editing a script file
static member ComputeClosureOfSourceText(filename:string, source:string, codeContext, useMonoResolution:bool, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs) : LoadClosure =
static member ComputeClosureOfSourceText(filename:string, source:string, codeContext, useSimpleResolution:bool, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs) : LoadClosure =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind (BuildPhase.Parse)
ScriptPreprocessClosure.GetFullClosureOfScriptSource(filename,source,codeContext,useMonoResolution,useFsiAuxLib, lexResourceManager, applyCommmandLineArgs)
ScriptPreprocessClosure.GetFullClosureOfScriptSource(filename,source,codeContext,useSimpleResolution,useFsiAuxLib, lexResourceManager, applyCommmandLineArgs)

/// Used from fsi.fs and fsc.fs, for #load and command line.
/// The resulting references are then added to a TcConfig.
Expand Down
6 changes: 3 additions & 3 deletions src/fsharp/CompileOps.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ type TcConfigBuilder =
mutable resolutionAssemblyFoldersConditions : string
mutable platform : ILPlatform option
mutable prefer32Bit : bool
mutable useMonoResolution : bool
mutable useSimpleResolution : bool
mutable target : CompilerTarget
mutable debuginfo : bool
mutable testFlagEmitFeeFeeAs100001 : bool
Expand Down Expand Up @@ -425,7 +425,7 @@ type TcConfig =
member resolutionAssemblyFoldersConditions : string
member platform : ILPlatform option
member prefer32Bit : bool
member useMonoResolution : bool
member useSimpleResolution : bool
member target : CompilerTarget
member debuginfo : bool
member testFlagEmitFeeFeeAs100001 : bool
Expand Down Expand Up @@ -775,7 +775,7 @@ type LoadClosure =
RootWarnings : PhasedError list }

// Used from service.fs, when editing a script file
static member ComputeClosureOfSourceText : filename: string * source: string * implicitDefines:CodeContext * useMonoResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) -> LoadClosure
static member ComputeClosureOfSourceText : filename: string * source: string * implicitDefines:CodeContext * useSimpleResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) -> LoadClosure

/// Used from fsi.fs and fsc.fs, for #load and command line. The resulting references are then added to a TcConfig.
static member ComputeClosureOfSourceFiles : tcConfig:TcConfig * (string * range) list * implicitDefines:CodeContext * useDefaultScriptingReferences : bool * lexResourceManager : Lexhelp.LexResourceManager -> LoadClosure
4 changes: 2 additions & 2 deletions src/fsharp/CompileOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ let advancedFlagsFsc tcConfigB =
#endif
yield CompilerOption("pdb", tagString, OptionString (fun s -> tcConfigB.debugSymbolFile <- Some s), None,
Some (FSComp.SR.optsPdb()));
yield CompilerOption("simpleresolution", tagNone, OptionUnit (fun () -> tcConfigB.useMonoResolution<-true), None,
yield CompilerOption("simpleresolution", tagNone, OptionUnit (fun () -> tcConfigB.useSimpleResolution<-true), None,
Some (FSComp.SR.optsSimpleresolution()));
yield CompilerOption("highentropyva", tagNone, OptionSwitch (useHighEntropyVASwitch tcConfigB), None, Some (FSComp.SR.optsUseHighEntropyVA()))
yield CompilerOption("subsystemversion", tagString, OptionString (subSystemVersionSwitch tcConfigB), None, Some (FSComp.SR.optsSubSystemVersion()))
Expand Down Expand Up @@ -859,7 +859,7 @@ let internalFlags (tcConfigB:TcConfigBuilder) =
CompilerOption("resolutionframeworkregistrybase", tagString, OptionString (fun s -> tcConfigB.resolutionFrameworkRegistryBase<-s), Some(InternalCommandLineOption("", rangeCmdArgs)), None); // "The base registry key to use for assembly resolution. This part in brackets here: HKEY_LOCAL_MACHINE\[SOFTWARE\Microsoft\.NETFramework]\v2.0.50727\AssemblyFoldersEx");
CompilerOption("resolutionassemblyfoldersuffix", tagString, OptionString (fun s -> tcConfigB.resolutionAssemblyFoldersSuffix<-s), Some(InternalCommandLineOption("resolutionassemblyfoldersuffix", rangeCmdArgs)), None); // "The base registry key to use for assembly resolution. This part in brackets here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\[AssemblyFoldersEx]");
CompilerOption("resolutionassemblyfoldersconditions", tagString, OptionString (fun s -> tcConfigB.resolutionAssemblyFoldersConditions <- ","^s), Some(InternalCommandLineOption("resolutionassemblyfoldersconditions", rangeCmdArgs)), None); // "Additional reference resolution conditions. For example \"OSVersion=5.1.2600.0,PlatformID=id");
CompilerOption("msbuildresolution", tagNone, OptionUnit (fun () -> tcConfigB.useMonoResolution<-false), Some(InternalCommandLineOption("msbuildresolution", rangeCmdArgs)), None); // "Resolve assembly references using MSBuild resolution rules rather than directory based (Default=true except when running fsc.exe under mono)");
CompilerOption("msbuildresolution", tagNone, OptionUnit (fun () -> tcConfigB.useSimpleResolution<-false), Some(InternalCommandLineOption("msbuildresolution", rangeCmdArgs)), None); // "Resolve assembly references using MSBuild resolution rules rather than directory based (Default=true except when running fsc.exe under mono)");
CompilerOption("alwayscallvirt",tagNone,OptionSwitch(callVirtSwitch tcConfigB),Some(InternalCommandLineOption("alwayscallvirt",rangeCmdArgs)), None);
CompilerOption("nodebugdata",tagNone, OptionUnit (fun () -> tcConfigB.noDebugData<-true),Some(InternalCommandLineOption("--nodebugdata",rangeCmdArgs)), None);
testFlag tcConfigB ] @
Expand Down
6 changes: 1 addition & 5 deletions src/fsharp/fsc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,11 +1234,7 @@ module MainModuleBuilder =
yield Lazy<_>.CreateFromValue av
if not(tcConfig.win32res = "") then
yield Lazy<_>.CreateFromValue (FileSystem.ReadAllBytesShim tcConfig.win32res)
#if ENABLE_MONO_SUPPORT
if tcConfig.includewin32manifest && not(win32Manifest = "") && not(runningOnMono) then
#else
if tcConfig.includewin32manifest && not(win32Manifest = "") then
#endif
if tcConfig.includewin32manifest && not(win32Manifest = "") && not runningOnMono then
yield Lazy<_>.CreateFromValue [| yield! ResFileFormat.ResFileHeader()
yield! (ManifestResourceFormat.VS_MANIFEST_RESOURCE((FileSystem.ReadAllBytesShim win32Manifest), tcConfig.target = Dll)) |]]

Expand Down
6 changes: 1 addition & 5 deletions src/fsharp/fsi/fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,7 @@ type internal FsiDynamicCompiler
errorLogger.AbortOnError();

let fragName = textOfLid prefixPath
#if ENABLE_MONO_SUPPORT
let codegenResults = GenerateIlxCode (IlReflectBackend, isInteractiveItExpr, runningOnMono, tcConfig, topCustomAttrs, optimizedImpls, fragName, true, ilxGenerator)
#else
let codegenResults = GenerateIlxCode (IlReflectBackend, isInteractiveItExpr, false, tcConfig, topCustomAttrs, optimizedImpls, fragName, true, ilxGenerator)
#endif
errorLogger.AbortOnError();

// Each input is like a small separately compiled extension to a single source file.
Expand Down Expand Up @@ -2229,7 +2225,7 @@ type internal FsiEvaluationSession (argv:string[], inReader:TextReader, outWrite
do tcConfigB.useFsiAuxLib <- true

#if TODO_REWORK_ASSEMBLY_LOAD
do tcConfigB.useMonoResolution<-true
do tcConfigB.useSimpleResolution<-true
#else
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/vs/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun
let useFsiAuxLib = defaultArg useFsiAuxLib true
// Do we use a "FSharp.Core, 4.3.0.0" reference by default?
let otherFlags = defaultArg otherFlags [| |]
let useMonoResolution =
let useSimpleResolution =
#if ENABLE_MONO_SUPPORT
runningOnMono || otherFlags |> Array.exists (fun x -> x = "--simpleresolution")
#else
Expand All @@ -2474,7 +2474,7 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun
let collect _name = ()
let fsiCompilerOptions = CompileOptions.GetCoreFsiCompilerOptions tcConfigB
CompileOptions.ParseCompilerOptions (collect, fsiCompilerOptions, Array.toList otherFlags)
let fas = LoadClosure.ComputeClosureOfSourceText(filename, source, CodeContext.Editing, useMonoResolution, useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions)
let fas = LoadClosure.ComputeClosureOfSourceText(filename, source, CodeContext.Editing, useSimpleResolution, useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions)
let otherFlags =
[| yield "--noframework"; yield "--warn:3";
yield! otherFlags
Expand Down