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
5 changes: 4 additions & 1 deletion src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2172,6 +2173,7 @@ type TcConfigBuilder =
compilingFslib=false
compilingFslib20=None
compilingFslib40=false
compilingFslibNoBigInt=false
useIncrementalBuilder=false
useFsiAuxLib=false
implicitOpens=[]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/fsharp/CompileOps.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ type VersionFlag =
member GetVersionInfo : implicitIncludeDir:string -> ILVersionInfo
member GetVersionString : implicitIncludeDir:string -> string


type TcConfigBuilder =
{ mutable primaryAssembly : PrimaryAssembly
mutable autoResolveOpenDirectivesToDlls: bool
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/fsharp/CompileOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions src/fsharp/FSharp.Core/FSharp.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
<CompilingFsLib>true</CompilingFsLib>
<AllowCrossTargeting>true</AllowCrossTargeting>
<FX_NO_LOADER>true</FX_NO_LOADER>
<OtherFlags>$(OtherFlags) --warnon:1182 --compiling-fslib --maxerrors:20 --extraoptimizationloops:1 </OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='net20'">$(OtherFlags) --compiling-fslib-20:"$(SystemRoot)\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" </OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='net40'">$(OtherFlags) --compiling-fslib-40</OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='coreclr'">$(OtherFlags) --targetprofile:netcore</OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='portable7'">$(OtherFlags) --targetprofile:netcore</OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='portable78'">$(OtherFlags) --targetprofile:netcore</OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='portable259'">$(OtherFlags) --targetprofile:netcore</OtherFlags>
<OtherFlags>$(OtherFlags) --warnon:1182 --compiling-fslib --maxerrors:20 --extraoptimizationloops:1 </OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='net20'">$(OtherFlags) --compiling-fslib-20:"$(SystemRoot)\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" </OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='net40'">$(OtherFlags) --compiling-fslib-40</OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='coreclr'">$(OtherFlags) --compiling-fslib-40 --targetprofile:netcore</OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='portable7'">$(OtherFlags) --compiling-fslib-40 --targetprofile:netcore</OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='portable78'">$(OtherFlags) --compiling-fslib-40 --compiling-fslib-nobigint --targetprofile:netcore</OtherFlags>
<OtherFlags Condition=" '$(TargetFramework)'=='portable259'">$(OtherFlags) --compiling-fslib-40 --compiling-fslib-nobigint --targetprofile:netcore</OtherFlags>
</PropertyGroup>
<ItemGroup>
<FilesToLocalize Include="$(OutDir)$(AssemblyName).dll">
<TranslationFile>$(FSharpSourcesRoot)\..\loc\lcl\{Lang}\$(AssemblyName).dll.lcl</TranslationFile>
<LciCommentFile>$(FSharpSourcesRoot)\..\loc\lci\$(AssemblyName).dll.lci</LciCommentFile>
<HasLceComments>false</HasLceComments>
<InProject>false</InProject>
<InProject>false</InProject>
</FilesToLocalize>
</ItemGroup>
<ItemGroup>
Expand Down
62 changes: 34 additions & 28 deletions src/fsharp/fsc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ILNestedExportedType>
CustomAttrs = mkILCustomAttrs List.empty<ILAttribute> }) |>
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<ILNestedExportedType>
CustomAttrs = mkILCustomAttrs List.empty<ILAttribute> }) |>
Seq.toList

let createSystemNumericsExportList tcGlobals =
let sysAssemblyRef = tcGlobals.sysCcu.ILScopeRef.AssemblyRef
Expand All @@ -969,7 +969,7 @@ let createSystemNumericsExportList tcGlobals =
Nested = mkILNestedExportedTypes List.empty<ILNestedExportedType>
CustomAttrs = mkILCustomAttrs List.empty<ILAttribute> }) |>
Seq.toList

module MainModuleBuilder =

let fileVersion warn findStringAttr (assemblyVersion: ILVersionInfo) =
Expand Down Expand Up @@ -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) ->
Expand Down