Skip to content

Commit 0a6cf6f

Browse files
KevinRansombaronfel
authored andcommitted
cleanup compilingFsLib (#7510)
1 parent 5d2bd22 commit 0a6cf6f

4 files changed

Lines changed: 17 additions & 105 deletions

File tree

src/fsharp/CompileOps.fs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,9 +2015,6 @@ type TcConfigBuilder =
20152015
mutable openDebugInformationForLaterStaticLinking: bool (* only for --standalone *)
20162016
defaultFSharpBinariesDir: string
20172017
mutable compilingFslib: bool
2018-
mutable compilingFslib20: string option
2019-
mutable compilingFslib40: bool
2020-
mutable compilingFslibNoBigInt: bool
20212018
mutable useIncrementalBuilder: bool
20222019
mutable includes: string list
20232020
mutable implicitOpens: string list
@@ -2180,9 +2177,6 @@ type TcConfigBuilder =
21802177
openDebugInformationForLaterStaticLinking = false
21812178
defaultFSharpBinariesDir = String.Empty
21822179
compilingFslib = false
2183-
compilingFslib20 = None
2184-
compilingFslib40 = false
2185-
compilingFslibNoBigInt = false
21862180
useIncrementalBuilder = false
21872181
useFsiAuxLib = false
21882182
implicitOpens = []
@@ -2665,9 +2659,6 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
26652659
member x.openDebugInformationForLaterStaticLinking = data.openDebugInformationForLaterStaticLinking
26662660
member x.fsharpBinariesDir = fsharpBinariesDirValue
26672661
member x.compilingFslib = data.compilingFslib
2668-
member x.compilingFslib20 = data.compilingFslib20
2669-
member x.compilingFslib40 = data.compilingFslib40
2670-
member x.compilingFslibNoBigInt = data.compilingFslibNoBigInt
26712662
member x.useIncrementalBuilder = data.useIncrementalBuilder
26722663
member x.includes = data.includes
26732664
member x.implicitOpens = data.implicitOpens

src/fsharp/CompileOps.fsi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,6 @@ type TcConfigBuilder =
256256
mutable openDebugInformationForLaterStaticLinking: bool
257257
defaultFSharpBinariesDir: string
258258
mutable compilingFslib: bool
259-
mutable compilingFslib20: string option
260-
mutable compilingFslib40: bool
261-
mutable compilingFslibNoBigInt: bool
262259
mutable useIncrementalBuilder: bool
263260
mutable includes: string list
264261
mutable implicitOpens: string list
@@ -424,9 +421,6 @@ type TcConfig =
424421
member openDebugInformationForLaterStaticLinking: bool
425422
member fsharpBinariesDir: string
426423
member compilingFslib: bool
427-
member compilingFslib20: string option
428-
member compilingFslib40: bool
429-
member compilingFslibNoBigInt: bool
430424
member useIncrementalBuilder: bool
431425
member includes: string list
432426
member implicitOpens: string list

src/fsharp/CompileOptions.fs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,10 +1217,9 @@ let internalFlags (tcConfigB:TcConfigBuilder) =
12171217
Some(InternalCommandLineOption("metadataversion", rangeCmdArgs)), None)
12181218
]
12191219

1220-
12211220
// OptionBlock: Deprecated flags (fsc, service only)
12221221
//--------------------------------------------------
1223-
1222+
12241223
let compilingFsLibFlag (tcConfigB: TcConfigBuilder) =
12251224
CompilerOption
12261225
("compiling-fslib", tagNone,
@@ -1231,23 +1230,14 @@ let compilingFsLibFlag (tcConfigB: TcConfigBuilder) =
12311230
IlxSettings.ilxCompilingFSharpCoreLib := true),
12321231
Some(InternalCommandLineOption("--compiling-fslib", rangeCmdArgs)), None)
12331232

1234-
let compilingFsLib20Flag (tcConfigB: TcConfigBuilder) =
1235-
CompilerOption
1236-
("compiling-fslib-20", tagNone,
1237-
OptionString (fun s -> tcConfigB.compilingFslib20 <- Some s ),
1238-
Some(InternalCommandLineOption("--compiling-fslib-20", rangeCmdArgs)), None)
1233+
let compilingFsLib20Flag =
1234+
CompilerOption ("compiling-fslib-20", tagNone, OptionString (fun _ -> () ), None, None)
12391235

1240-
let compilingFsLib40Flag (tcConfigB: TcConfigBuilder) =
1241-
CompilerOption
1242-
("compiling-fslib-40", tagNone,
1243-
OptionUnit (fun () -> tcConfigB.compilingFslib40 <- true ),
1244-
Some(InternalCommandLineOption("--compiling-fslib-40", rangeCmdArgs)), None)
1236+
let compilingFsLib40Flag =
1237+
CompilerOption ("compiling-fslib-40", tagNone, OptionUnit (fun () -> ()), None, None)
12451238

1246-
let compilingFsLibNoBigIntFlag (tcConfigB: TcConfigBuilder) =
1247-
CompilerOption
1248-
("compiling-fslib-nobigint", tagNone,
1249-
OptionUnit (fun () -> tcConfigB.compilingFslibNoBigInt <- true ),
1250-
Some(InternalCommandLineOption("--compiling-fslib-nobigint", rangeCmdArgs)), None)
1239+
let compilingFsLibNoBigIntFlag =
1240+
CompilerOption ("compiling-fslib-nobigint", tagNone, OptionUnit (fun () -> () ), None, None)
12511241

12521242
let mlKeywordsFlag =
12531243
CompilerOption
@@ -1262,7 +1252,7 @@ let gnuStyleErrorsFlag tcConfigB =
12621252
Some(DeprecatedCommandLineOptionNoDescription("--gnu-style-errors", rangeCmdArgs)), None)
12631253

12641254
let deprecatedFlagsBoth tcConfigB =
1265-
[
1255+
[
12661256
CompilerOption
12671257
("light", tagNone,
12681258
OptionUnit (fun () -> tcConfigB.light <- Some true),
@@ -1278,7 +1268,7 @@ let deprecatedFlagsBoth tcConfigB =
12781268
OptionUnit (fun () -> tcConfigB.light <- Some false),
12791269
Some(DeprecatedCommandLineOptionNoDescription("--no-indentation-syntax", rangeCmdArgs)), None)
12801270
]
1281-
1271+
12821272
let deprecatedFlagsFsi tcConfigB = deprecatedFlagsBoth tcConfigB
12831273

12841274
let deprecatedFlagsFsc tcConfigB =
@@ -1311,9 +1301,9 @@ let deprecatedFlagsFsc tcConfigB =
13111301
Some(DeprecatedCommandLineOptionNoDescription("--progress", rangeCmdArgs)), None)
13121302

13131303
compilingFsLibFlag tcConfigB
1314-
compilingFsLib20Flag tcConfigB
1315-
compilingFsLib40Flag tcConfigB
1316-
compilingFsLibNoBigIntFlag tcConfigB
1304+
compilingFsLib20Flag
1305+
compilingFsLib40Flag
1306+
compilingFsLibNoBigIntFlag
13171307

13181308
CompilerOption
13191309
("version", tagString,

src/fsharp/fsc.fs

Lines changed: 5 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -869,11 +869,9 @@ module MainModuleBuilder =
869869
error(Error(FSComp.SR.fscAssemblyCultureAttributeError(), rangeCmdArgs))
870870

871871
// Add the type forwarders to any .NET DLL post-.NET-2.0, to give binary compatibility
872-
let exportedTypesList =
873-
if (tcConfig.compilingFslib && tcConfig.compilingFslib40) then
874-
(List.append (createMscorlibExportList tcGlobals)
875-
(if tcConfig.compilingFslibNoBigInt then [] else (createSystemNumericsExportList tcConfig tcImports))
876-
)
872+
let exportedTypesList =
873+
if tcConfig.compilingFslib then
874+
List.append (createMscorlibExportList tcGlobals) (createSystemNumericsExportList tcConfig tcImports)
877875
else
878876
[]
879877

@@ -1279,64 +1277,6 @@ module StaticLinker =
12791277

12801278
ilxMainModule, rewriteExternalRefsToLocalRefs
12811279

1282-
1283-
// LEGACY: This is only used when compiling an FSharp.Core for .NET 2.0 (FSharp.Core 2.3.0.0). We no longer
1284-
// build new FSharp.Core for that configuration.
1285-
//
1286-
// Find all IL modules that are to be statically linked given the static linking roots.
1287-
let LegacyFindAndAddMscorlibTypesForStaticLinkingIntoFSharpCoreLibraryForNet20 (tcConfig: TcConfig, ilGlobals: ILGlobals, ilxMainModule) =
1288-
let mscorlib40 = tcConfig.compilingFslib20.Value
1289-
1290-
let ilBinaryReader =
1291-
let ilGlobals = mkILGlobals ILScopeRef.Local
1292-
let opts : ILReaderOptions =
1293-
{ ilGlobals = ilGlobals
1294-
reduceMemoryUsage = tcConfig.reduceMemoryUsage
1295-
metadataOnly = MetadataOnlyFlag.No
1296-
tryGetMetadataSnapshot = (fun _ -> None)
1297-
pdbDirPath = None }
1298-
ILBinaryReader.OpenILModuleReader mscorlib40 opts
1299-
1300-
let tdefs1 = ilxMainModule.TypeDefs.AsList |> List.filter (fun td -> not (MainModuleBuilder.injectedCompatTypes.Contains(td.Name)))
1301-
let tdefs2 = ilBinaryReader.ILModuleDef.TypeDefs.AsList |> List.filter (fun td -> MainModuleBuilder.injectedCompatTypes.Contains(td.Name))
1302-
//printfn "tdefs2 = %A" (tdefs2 |> List.map (fun tdef -> tdef.Name))
1303-
1304-
// rewrite the mscorlib references
1305-
let tdefs2 =
1306-
let fakeModule = mkILSimpleModule "" "" true (4, 0) false (mkILTypeDefs tdefs2) None None 0 (mkILExportedTypes []) ""
1307-
let fakeModule =
1308-
fakeModule |> Morphs.morphILTypeRefsInILModuleMemoized ilGlobals (fun tref ->
1309-
if MainModuleBuilder.injectedCompatTypes.Contains(tref.Name) || (tref.Enclosing |> List.exists (fun x -> MainModuleBuilder.injectedCompatTypes.Contains x)) then
1310-
tref
1311-
//|> Morphs.morphILScopeRefsInILTypeRef (function ILScopeRef.Local -> ilGlobals.mscorlibScopeRef | x -> x)
1312-
// The implementations of Tuple use two private methods from System.Environment to get a resource string. Remap it
1313-
elif tref.Name = "System.Environment" then
1314-
ILTypeRef.Create(ILScopeRef.Local, [], "Microsoft.FSharp.Core.PrivateEnvironment") //|> Morphs.morphILScopeRefsInILTypeRef (function ILScopeRef.Local -> ilGlobals.mscorlibScopeRef | x -> x)
1315-
else
1316-
tref |> Morphs.morphILScopeRefsInILTypeRef (fun _ -> ilGlobals.primaryAssemblyScopeRef) )
1317-
1318-
// strip out System.Runtime.TargetedPatchingOptOutAttribute, which doesn't exist for 2.0
1319-
let fakeModule =
1320-
{fakeModule with
1321-
TypeDefs =
1322-
mkILTypeDefs
1323-
([ for td in fakeModule.TypeDefs do
1324-
let meths = td.Methods.AsList
1325-
|> List.map (fun md ->
1326-
md.With(customAttrs =
1327-
mkILCustomAttrs (td.CustomAttrs.AsList |> List.filter (fun ilattr ->
1328-
ilattr.Method.DeclaringType.TypeRef.FullName <> "System.Runtime.TargetedPatchingOptOutAttribute"))))
1329-
|> mkILMethods
1330-
let td = td.With(methods=meths)
1331-
yield td.With(methods=meths) ])}
1332-
//ILAsciiWriter.output_module stdout fakeModule
1333-
fakeModule.TypeDefs.AsList
1334-
1335-
let ilxMainModule =
1336-
{ ilxMainModule with
1337-
TypeDefs = mkILTypeDefs (tdefs1 @ tdefs2) }
1338-
ilxMainModule
1339-
13401280
[<NoEquality; NoComparison>]
13411281
type Node =
13421282
{ name: string
@@ -1481,7 +1421,7 @@ module StaticLinker =
14811421
let StaticLink (ctok, tcConfig: TcConfig, tcImports: TcImports, ilGlobals: ILGlobals) =
14821422

14831423
#if !NO_EXTENSIONTYPING
1484-
let providerGeneratedAssemblies =
1424+
let providerGeneratedAssemblies =
14851425

14861426
[ // Add all EST-generated assemblies into the static linking set
14871427
for KeyValue(_, importedBinary: ImportedBinary) in tcImports.DllTable do
@@ -1490,10 +1430,7 @@ module StaticLinker =
14901430
| None -> ()
14911431
| Some provAssemStaticLinkInfo -> yield (importedBinary, provAssemStaticLinkInfo) ]
14921432
#endif
1493-
if tcConfig.compilingFslib && tcConfig.compilingFslib20.IsSome then
1494-
(fun ilxMainModule -> LegacyFindAndAddMscorlibTypesForStaticLinkingIntoFSharpCoreLibraryForNet20 (tcConfig, ilGlobals, ilxMainModule))
1495-
1496-
elif not tcConfig.standalone && tcConfig.extraStaticLinkRoots.IsEmpty
1433+
if not tcConfig.standalone && tcConfig.extraStaticLinkRoots.IsEmpty
14971434
#if !NO_EXTENSIONTYPING
14981435
&& providerGeneratedAssemblies.IsEmpty
14991436
#endif

0 commit comments

Comments
 (0)