-
Notifications
You must be signed in to change notification settings - Fork 846
Simple changes to make it compatible with WASM #8722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,6 +189,10 @@ module internal FSharpEnvironment = | |
| // Check for an app.config setting to redirect the default compiler location | ||
| // Like fsharp-compiler-location | ||
| try | ||
| // We let you set FSHARP_COMPILER_BIN. I've rarely seen this used and its not documented in the install instructions. | ||
| match Environment.GetEnvironmentVariable("FSHARP_COMPILER_BIN") with | ||
| | result when not (String.IsNullOrWhiteSpace result) -> Some result | ||
| |_-> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer if you intend the following code block to prevent any confusion.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was following the style already in use there which followed the pattern Although admittedly in the end it broke it by indenting the final If you still prefer multiple indents I will change that section so its consistent. |
||
| // FSharp.Compiler support setting an appKey for compiler location. I've never seen this used. | ||
| let result = tryAppConfig "fsharp-compiler-location" | ||
| match result with | ||
|
|
@@ -201,11 +205,6 @@ module internal FSharpEnvironment = | |
| match probePoint with | ||
| | Some p when safeExists (Path.Combine(p,"FSharp.Core.dll")) -> Some p | ||
| | _ -> | ||
| // We let you set FSHARP_COMPILER_BIN. I've rarely seen this used and its not documented in the install instructions. | ||
| let result = Environment.GetEnvironmentVariable("FSHARP_COMPILER_BIN") | ||
| if not (String.IsNullOrEmpty(result)) then | ||
| Some result | ||
| else | ||
| // For the prototype compiler, we can just use the current domain | ||
| tryCurrentDomain() | ||
| with e -> None | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add additional explanation for that change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in Mono-Wasm
typeof<obj>.Assembly.Location="mscorlib.dll"with no path and soPath.GetDirectoryName(typeof<obj>.Assembly.Location)=""which causes an exception later on. In this case I am usingfSharpCompilerLocationwhich was resolved in the prior point.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amieres can you put a repro of something that fails on a GitHub repo somewhere. I certainly want to think about this.
The notion that assemblies are loaded from streams, plays havoc with the a couple of our commonly held invariants.
I think it is a good scenario for us to handle, but I would rather we think about what the solution looks like rather than a few targeted bug fixes. Although in the end it may just turn out to be soluble that way.
I think probably we might want to look at what fable does too since they may encounter and have solved similar issues.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KevinRansom
I created a website where different Assemblies for FCS can be tested:
https://amieres.github.io/WASM.html
After the initial load there is an option to select the set of Assemblies to use
with WASM:
The first one is the only that works. It is actually a fork of FCS 25.0 created for this purpose:
https://github.com/fsbolero/FSharp.Compiler.Service
Version 33.0 would work if the 2 issues in this PR were solved (plus a third one, that I don't quite recall right now).
Version 34.0 introduced a new issue by using
AssemblyLoadContextwhich is not supported by Mono WASM because according to the documentation it is not supposed to be NetStandard, but only NetCore. OTOH, the packageSystem.Runtime.Loaderis published in Nuget.org as .NETStandard 1.5. I do not know who is right (the documentation or the nuget package), but the end result is that version 34 wont work with WASM until WASM goes to NetCore.Let me know if this helps you in any way.
When you try to compile the snippets you will see the exceptions produced in each case.