diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 955ba969456..e329ba1fc91 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -2002,6 +2002,7 @@ type TcConfigBuilder = mutable compilingFslib: bool mutable compilingFslib20: string option mutable compilingFslib40: bool + mutable compilingFslibNoBigInt: bool mutable useIncrementalBuilder: bool mutable includes: string list mutable implicitOpens: string list @@ -2172,6 +2173,7 @@ type TcConfigBuilder = compilingFslib=false compilingFslib20=None compilingFslib40=false + compilingFslibNoBigInt=false useIncrementalBuilder=false useFsiAuxLib=false implicitOpens=[] @@ -2666,6 +2668,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = member x.compilingFslib = data.compilingFslib member x.compilingFslib20 = data.compilingFslib20 member x.compilingFslib40 = data.compilingFslib40 + member x.compilingFslibNoBigInt = data.compilingFslibNoBigInt member x.useIncrementalBuilder = data.useIncrementalBuilder member x.includes = data.includes member x.implicitOpens = data.implicitOpens @@ -5172,7 +5175,7 @@ let GetInitialTcState(m,ccuName,tcConfig:TcConfig,tcGlobals,tcImports:TcImports, // OK, is this is the FSharp.Core CCU then fix it up. if tcConfig.compilingFslib then tcGlobals.fslibCcu.Fixup(ccu) - + let rootSigs = Zmap.empty qnameOrder let rootImpls = Zset.empty qnameOrder let allSigModulTyp = NewEmptyModuleOrNamespaceType Namespace diff --git a/src/fsharp/CompileOps.fsi b/src/fsharp/CompileOps.fsi index 96d8998b259..3028f5b5bfb 100755 --- a/src/fsharp/CompileOps.fsi +++ b/src/fsharp/CompileOps.fsi @@ -219,7 +219,6 @@ type VersionFlag = member GetVersionInfo : implicitIncludeDir:string -> ILVersionInfo member GetVersionString : implicitIncludeDir:string -> string - type TcConfigBuilder = { mutable primaryAssembly : PrimaryAssembly mutable autoResolveOpenDirectivesToDlls: bool @@ -232,6 +231,7 @@ type TcConfigBuilder = mutable compilingFslib: bool mutable compilingFslib20: string option mutable compilingFslib40: bool + mutable compilingFslibNoBigInt: bool mutable useIncrementalBuilder: bool mutable includes: string list mutable implicitOpens: string list @@ -396,6 +396,7 @@ type TcConfig = member compilingFslib: bool member compilingFslib20: string option member compilingFslib40: bool + member compilingFslibNoBigInt: bool member useIncrementalBuilder: bool member includes: string list member implicitOpens: string list diff --git a/src/fsharp/CompileOptions.fs b/src/fsharp/CompileOptions.fs index ead3f4e381f..95314a02319 100644 --- a/src/fsharp/CompileOptions.fs +++ b/src/fsharp/CompileOptions.fs @@ -900,6 +900,9 @@ let compilingFsLib20Flag (tcConfigB : TcConfigBuilder) = CompilerOption("compiling-fslib-20", tagNone, OptionString (fun s -> tcConfigB.compilingFslib20 <- Some s ), Some(InternalCommandLineOption("--compiling-fslib-20", rangeCmdArgs)), None) let compilingFsLib40Flag (tcConfigB : TcConfigBuilder) = CompilerOption("compiling-fslib-40", tagNone, OptionUnit (fun () -> tcConfigB.compilingFslib40 <- true ), Some(InternalCommandLineOption("--compiling-fslib-40", rangeCmdArgs)), None) +let compilingFsLibNoBigIntFlag (tcConfigB : TcConfigBuilder) = + CompilerOption("compiling-fslib-nobigint", tagNone, OptionUnit (fun () -> tcConfigB.compilingFslibNoBigInt <- true ), Some(InternalCommandLineOption("--compiling-fslib-nobigint", rangeCmdArgs)), None) + let mlKeywordsFlag = CompilerOption("ml-keywords", tagNone, OptionUnit (fun () -> ()), Some(DeprecatedCommandLineOptionNoDescription("--ml-keywords", rangeCmdArgs)), None) @@ -926,6 +929,7 @@ let deprecatedFlagsFsc tcConfigB = (compilingFsLibFlag tcConfigB) (compilingFsLib20Flag tcConfigB) (compilingFsLib40Flag tcConfigB) + (compilingFsLibNoBigIntFlag tcConfigB) CompilerOption("version", tagString, OptionString (fun s -> tcConfigB.version <- VersionString s), Some(DeprecatedCommandLineOptionNoDescription("--version", rangeCmdArgs)), None) // "--clr-mscorlib", OptionString (fun s -> warning(Some(DeprecatedCommandLineOptionNoDescription("--clr-mscorlib", rangeCmdArgs))) tcConfigB.Build.mscorlib_assembly_name <- s), "\n\tThe name of mscorlib on the target CLR" CompilerOption("local-optimize", tagNone, OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with localOptUser = Some true }), Some(DeprecatedCommandLineOptionNoDescription("--local-optimize", rangeCmdArgs)), None) diff --git a/src/fsharp/FSharp.Core/FSharp.Core.fsproj b/src/fsharp/FSharp.Core/FSharp.Core.fsproj index 653358df643..9029b6a4fb9 100644 --- a/src/fsharp/FSharp.Core/FSharp.Core.fsproj +++ b/src/fsharp/FSharp.Core/FSharp.Core.fsproj @@ -16,20 +16,20 @@ true true true - $(OtherFlags) --warnon:1182 --compiling-fslib --maxerrors:20 --extraoptimizationloops:1 - $(OtherFlags) --compiling-fslib-20:"$(SystemRoot)\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" - $(OtherFlags) --compiling-fslib-40 - $(OtherFlags) --targetprofile:netcore - $(OtherFlags) --targetprofile:netcore - $(OtherFlags) --targetprofile:netcore - $(OtherFlags) --targetprofile:netcore + $(OtherFlags) --warnon:1182 --compiling-fslib --maxerrors:20 --extraoptimizationloops:1 + $(OtherFlags) --compiling-fslib-20:"$(SystemRoot)\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" + $(OtherFlags) --compiling-fslib-40 + $(OtherFlags) --compiling-fslib-40 --targetprofile:netcore + $(OtherFlags) --compiling-fslib-40 --targetprofile:netcore + $(OtherFlags) --compiling-fslib-40 --compiling-fslib-nobigint --targetprofile:netcore + $(OtherFlags) --compiling-fslib-40 --compiling-fslib-nobigint --targetprofile:netcore $(FSharpSourcesRoot)\..\loc\lcl\{Lang}\$(AssemblyName).dll.lcl $(FSharpSourcesRoot)\..\loc\lci\$(AssemblyName).dll.lci false - false + false diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index e9da539b7bf..a14634103d3 100644 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -933,29 +933,29 @@ let injectedCompatTypes = "System.Collections.IStructuralEquatable" ] let typesForwardedToMscorlib = - set [ "System.AggregateException" - "System.Threading.CancellationTokenRegistration" - "System.Threading.CancellationToken" - "System.Threading.CancellationTokenSource" - "System.Lazy`1" - "System.IObservable`1" - "System.IObserver`1" - ] + set [ "System.AggregateException" + "System.Threading.CancellationTokenRegistration" + "System.Threading.CancellationToken" + "System.Threading.CancellationTokenSource" + "System.Lazy`1" + "System.IObservable`1" + "System.IObserver`1" ] + let typesForwardedToSystemNumerics = - set [ "System.Numerics.BigInteger" ] - + set [ "System.Numerics.BigInteger" ] + let createMscorlibExportList tcGlobals = - // We want to write forwarders out for all injected types except for System.ITuple, which is internal - // Forwarding System.ITuple will cause FxCop failures on 4.0 - Set.union (Set.filter (fun t -> t <> "System.ITuple") injectedCompatTypes) typesForwardedToMscorlib |> - Seq.map (fun t -> - { ScopeRef = tcGlobals.sysCcu.ILScopeRef - Name = t - IsForwarder = true - Access = ILTypeDefAccess.Public - Nested = mkILNestedExportedTypes List.empty - CustomAttrs = mkILCustomAttrs List.empty }) |> - Seq.toList + // We want to write forwarders out for all injected types except for System.ITuple, which is internal + // Forwarding System.ITuple will cause FxCop failures on 4.0 + Set.union (Set.filter (fun t -> t <> "System.ITuple") injectedCompatTypes) typesForwardedToMscorlib |> + Seq.map (fun t -> + { ScopeRef = tcGlobals.sysCcu.ILScopeRef + Name = t + IsForwarder = true + Access = ILTypeDefAccess.Public + Nested = mkILNestedExportedTypes List.empty + CustomAttrs = mkILCustomAttrs List.empty }) |> + Seq.toList let createSystemNumericsExportList tcGlobals = let sysAssemblyRef = tcGlobals.sysCcu.ILScopeRef.AssemblyRef @@ -969,7 +969,7 @@ let createSystemNumericsExportList tcGlobals = Nested = mkILNestedExportedTypes List.empty CustomAttrs = mkILCustomAttrs List.empty }) |> Seq.toList - + module MainModuleBuilder = let fileVersion warn findStringAttr (assemblyVersion: ILVersionInfo) = @@ -1020,20 +1020,26 @@ module MainModuleBuilder = let hashAlg = AttributeHelpers.TryFindIntAttribute tcGlobals "System.Reflection.AssemblyAlgorithmIdAttribute" topAttrs.assemblyAttrs let locale = AttributeHelpers.TryFindStringAttribute tcGlobals "System.Reflection.AssemblyCultureAttribute" topAttrs.assemblyAttrs let flags = match AttributeHelpers.TryFindIntAttribute tcGlobals "System.Reflection.AssemblyFlagsAttribute" topAttrs.assemblyAttrs with | Some(f) -> f | _ -> 0x0 - + // You're only allowed to set a locale if the assembly is a library if (locale <> None && locale.Value <> "") && tcConfig.target <> Dll then error(Error(FSComp.SR.fscAssemblyCultureAttributeError(),rangeCmdArgs)) - + // Add the type forwarders to any .NET DLL post-.NET-2.0, to give binary compatibility - let exportedTypesList = if (tcConfig.compilingFslib && tcConfig.compilingFslib40) then (List.append (createMscorlibExportList tcGlobals) (createSystemNumericsExportList tcGlobals)) else [] - + let exportedTypesList = + if (tcConfig.compilingFslib && tcConfig.compilingFslib40) then + (List.append (createMscorlibExportList tcGlobals) + (if tcConfig.compilingFslibNoBigInt then [] else (createSystemNumericsExportList tcGlobals)) + ) + else + [] + mkILSimpleModule assemblyName (GetGeneratedILModuleName tcConfig.target assemblyName) (tcConfig.target = Dll || tcConfig.target = Module) tcConfig.subsystemVersion tcConfig.useHighEntropyVA ilTypeDefs hashAlg locale flags (mkILExportedTypes exportedTypesList) metadataVersion let disableJitOptimizations = not (tcConfig.optSettings.jitOpt()) - + let tcVersion = tcConfig.version.GetVersionInfo(tcConfig.implicitIncludeDir) - + let reflectedDefinitionAttrs, reflectedDefinitionResources = codegenResults.quotationResourceInfo |> List.map (fun (referencedTypeDefs, reflectedDefinitionBytes) ->