Skip to content

--standalone type forwarding#7462

Merged
KevinRansom merged 7 commits intodotnet:masterfrom
KevinRansom:StandaloneTypeForwarding
Sep 4, 2019
Merged

--standalone type forwarding#7462
KevinRansom merged 7 commits intodotnet:masterfrom
KevinRansom:StandaloneTypeForwarding

Conversation

@KevinRansom
Copy link
Copy Markdown
Contributor

There has long been a bug with the coreclr version of the compiler:

Fixes: #3924 : Support for --standalone on .NET Core

This happens because --standalone takes the Il from FSharp.Core and embeds it in the binary being built. When FSharp.Core references framework assemblies and those assemblies rely on type forwarders to get to the correct type the compiler does not know how to unify the generated method signatures with the type forwarded ones.

The fix in this PR is to follow the type forwarders for everything in thethe generated code and embedded code.
This only happens in the static linker, and so will have no impact to the majority of applications.

Static linking occurs for:

  1. Apps compiled with --standalone
  2. Apps that rely on generative type providers
  3. Apps that use --staticlink: to link multiple assemblies into a single dll

This fix is also necessary for us to move to a single netstandard 2.0 version of FSharp.Core rather than dual desktop and netstandard versions. Because even the desktop --standalone which has always work would start failing for that scenario.

Note:
The pr also contains this fix: #7461

let typeForwardILTypeRef (tref: ILTypeRef) =
let scoref1 = tref.Scope
let scoref2 = followTypeForwardForILTypeRef tref
if scoref1 === scoref2 then tref
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

===

wat

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-)
I read that operator as "is the same as"
It is defined here: https://github.com/dotnet/fsharp/blob/master/src/absil/illib.fs#L44

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, so it's objEq (box x) (box y)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not =?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not instance equality, it's are the contents equal.

@KevinRansom KevinRansom merged commit 321296b into dotnet:master Sep 4, 2019
@KevinRansom KevinRansom deleted the StandaloneTypeForwarding branch October 2, 2019 22:40
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
* Add type forwarding to static linker

* Type forward using simple matches when required

* Fix native resource issue with emptry streams

* reduce churn

* Use typeref morpher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for --standalone on .NET Core

4 participants