Skip to content

Commit b7c486c

Browse files
KevinRansombaronfel
authored andcommitted
Remove the requirement for explicit FSharp.Core reference need --noframework (#7572)
* Remove the requirement that an explicit FSharp.Core reference requires --noframework * fsharpqa
1 parent b18cb9d commit b7c486c

File tree

2 files changed

+9
-36
lines changed

2 files changed

+9
-36
lines changed

src/fsharp/CompileOps.fs

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,24 +2580,21 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
25802580
errorR(Error(FSComp.SR.buildMultipleReferencesNotAllowed libraryName, rangeCmdArgs))
25812581
nameOfDll r
25822582

2583-
// Look for an explicit reference to mscorlib and use that to compute clrRoot and targetFrameworkVersion
2583+
// Look for an explicit reference to mscorlib/netstandard.dll or System.Runtime.dll and use that to compute clrRoot and targetFrameworkVersion
25842584
let primaryAssemblyReference, primaryAssemblyExplicitFilenameOpt = computeKnownDllReference(data.primaryAssembly.Name)
2585-
let fslibReference, fslibExplicitFilenameOpt =
2586-
let (_, fileNameOpt) as res = computeKnownDllReference getFSharpCoreLibraryName
2585+
let fslibReference =
2586+
// Look for explict FSharp.Core reference otherwise use version that was referenced by compiler
2587+
let dllReference, fileNameOpt = computeKnownDllReference getFSharpCoreLibraryName
25872588
match fileNameOpt with
2588-
| None ->
2589-
// if FSharp.Core was not provided explicitly - use version that was referenced by compiler
2590-
AssemblyReference(range0, getDefaultFSharpCoreReference, None), None
2591-
| _ -> res
2589+
| Some _ -> dllReference
2590+
| None -> AssemblyReference(range0, getDefaultFSharpCoreReference, None)
25922591

25932592
// If either mscorlib.dll/System.Runtime.dll/netstandard.dll or FSharp.Core.dll are explicitly specified then we require the --noframework flag.
25942593
// The reason is that some non-default frameworks may not have the default dlls. For example, Client profile does
25952594
// not have System.Web.dll.
2596-
do if ((primaryAssemblyExplicitFilenameOpt.IsSome || fslibExplicitFilenameOpt.IsSome) && data.framework) then
2595+
do if (primaryAssemblyExplicitFilenameOpt.IsSome && data.framework) then
25972596
error(Error(FSComp.SR.buildExplicitCoreLibRequiresNoFramework("--noframework"), rangeStartup))
25982597

2599-
let ilGlobals = mkILGlobals ILScopeRef.Local
2600-
26012598
// clrRoot: the location of the primary assembly (mscorlib.dll or netstandard.dll or System.Runtime.dll)
26022599
//
26032600
// targetFrameworkVersionValue: Normally just HighestInstalledNetFrameworkVersion()
@@ -2627,37 +2624,13 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
26272624

26282625
let systemAssemblies = systemAssemblies
26292626

2630-
// Look for an explicit reference to FSharp.Core and use that to compute fsharpBinariesDir
2631-
// FUTURE: remove this, we only read the binary for the exception it raises
2632-
let fsharpBinariesDirValue =
2633-
// NOTE: It's not clear why this behaviour has been changed for the NETSTANDARD compilations of the F# compiler
2634-
#if NETSTANDARD
2635-
ignore ilGlobals
2636-
data.defaultFSharpBinariesDir
2637-
#else
2638-
match fslibExplicitFilenameOpt with
2639-
| Some fslibFilename ->
2640-
let filename = ComputeMakePathAbsolute data.implicitIncludeDir fslibFilename
2641-
if fslibReference.ProjectReference.IsNone then
2642-
try
2643-
use ilReader = OpenILBinary(filename, data.reduceMemoryUsage, ilGlobals, None, data.shadowCopyReferences, data.tryGetMetadataSnapshot)
2644-
()
2645-
with e ->
2646-
error(Error(FSComp.SR.buildErrorOpeningBinaryFile(filename, e.Message), rangeStartup))
2647-
2648-
let fslibRoot = Path.GetDirectoryName(FileSystem.GetFullPathShim filename)
2649-
fslibRoot
2650-
| _ ->
2651-
data.defaultFSharpBinariesDir
2652-
#endif
2653-
26542627
member x.primaryAssembly = data.primaryAssembly
26552628
member x.autoResolveOpenDirectivesToDlls = data.autoResolveOpenDirectivesToDlls
26562629
member x.noFeedback = data.noFeedback
26572630
member x.stackReserveSize = data.stackReserveSize
26582631
member x.implicitIncludeDir = data.implicitIncludeDir
26592632
member x.openDebugInformationForLaterStaticLinking = data.openDebugInformationForLaterStaticLinking
2660-
member x.fsharpBinariesDir = fsharpBinariesDirValue
2633+
member x.fsharpBinariesDir = data.defaultFSharpBinariesDir
26612634
member x.compilingFslib = data.compilingFslib
26622635
member x.useIncrementalBuilder = data.useIncrementalBuilder
26632636
member x.includes = data.includes

src/fsharp/FSComp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ lexIndentOffForML,"Consider using a file with extension '.ml' or '.mli' instead"
10851085
1219,tcUnionCaseNameConflictsWithGeneratedType,"The union case named '%s' conflicts with the generated type '%s'"
10861086
1220,chkNoReflectedDefinitionOnStructMember,"ReflectedDefinitionAttribute may not be applied to an instance member on a struct type, because the instance member takes an implicit 'this' byref parameter"
10871087
1221,tcDllImportNotAllowed,"DLLImport bindings must be static members in a class or function definitions in a module"
1088-
1222,buildExplicitCoreLibRequiresNoFramework,"When mscorlib.dll or FSharp.Core.dll is explicitly referenced the %s option must also be passed"
1088+
1222,buildExplicitCoreLibRequiresNoFramework,"When mscorlib.dll is explicitly referenced the %s option must also be passed"
10891089
1223,buildExpectedSigdataFile,"FSharp.Core.sigdata not found alongside FSharp.Core. File expected in %s. Consider upgrading to a more recent version of FSharp.Core, where this file is no longer be required."
10901090
1225,buildExpectedFileAlongSideFSharpCore,"File '%s' not found alongside FSharp.Core. File expected in %s. Consider upgrading to a more recent version of FSharp.Core, where this file is no longer be required."
10911091
1227,buildUnexpectedFileNameCharacter,"Filename '%s' contains invalid character '%s'"

0 commit comments

Comments
 (0)