-
Notifications
You must be signed in to change notification settings - Fork 215
[NativeAOT LLVM] Integrate dotnet.js into ILCompiler.LLVM #2453
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
dd5e3bc
3c557bd
bdb6bd0
34462b4
f420313
8e5a903
014bdcb
1a55814
c19a2d7
6a2d69f
4affb5c
61a07da
73d85cf
e3bf8cb
4f6da2e
eb73eec
fc827a1
1017725
c065dda
77062d4
647f052
167f02e
0dcdc9e
a21a646
da0df9f
3333e5d
8eedfa7
df2cddc
dbf5adf
c672052
1897fd6
f9e9951
3868406
b0293dd
26adcea
cc6d39d
eabddff
4d4d1c4
c766fbc
d210293
ecb3f03
247c6bb
19431c9
9935515
1d32ee8
a105954
f796292
6597228
934b85c
30c0d98
d2a5528
42b12fe
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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
maraf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <PropertyGroup> | ||
| <LinkNativeDependsOn Condition="'$(_targetOS)' == 'browser' and '$(DotNetJsApi)' == 'true'">$(LinkNativeDependsOn);PrepareDotNetJsApiForLinking</LinkNativeDependsOn> | ||
| <NativeBinary>$(NativeOutputPath)dotnet.native.js</NativeBinary> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <EmccExportedFunction Include="_free" /> | ||
| <EmccExportedFunction Include="_htons" /> | ||
| <EmccExportedFunction Include="_malloc" /> | ||
| <EmccExportedFunction Include="_memalign" /> | ||
| <EmccExportedFunction Include="_memset" /> | ||
| <EmccExportedFunction Include="_ntohs" /> | ||
| <EmccExportedFunction Include="stackAlloc" /> | ||
| <EmccExportedFunction Include="stackRestore" /> | ||
| <EmccExportedFunction Include="stackSave" /> | ||
| <EmccExportedRuntimeMethod Include="FS" /> | ||
| <EmccExportedRuntimeMethod Include="out" /> | ||
| <EmccExportedRuntimeMethod Include="err" /> | ||
| <EmccExportedRuntimeMethod Include="ccall" /> | ||
| <EmccExportedRuntimeMethod Include="cwrap" /> | ||
| <EmccExportedRuntimeMethod Include="setValue" /> | ||
| <EmccExportedRuntimeMethod Include="getValue" /> | ||
| <EmccExportedRuntimeMethod Include="addRunDependency" /> | ||
| <EmccExportedRuntimeMethod Include="addFunction" /> | ||
| <EmccExportedRuntimeMethod Include="UTF8ToString" /> | ||
| <EmccExportedRuntimeMethod Include="UTF8ArrayToString" /> | ||
| <EmccExportedRuntimeMethod Include="stringToUTF8Array" /> | ||
| <EmccExportedRuntimeMethod Include="FS_createPath" /> | ||
| <EmccExportedRuntimeMethod Include="FS_createDataFile" /> | ||
| <EmccExportedRuntimeMethod Include="removeRunDependency" /> | ||
| <EmccExportedRuntimeMethod Include="safeSetTimeout" /> | ||
| <EmccExportedRuntimeMethod Include="runtimeKeepalivePush" /> | ||
| <EmccExportedRuntimeMethod Include="runtimeKeepalivePop" /> | ||
| <EmccExportedRuntimeMethod Include="callMain" /> | ||
| </ItemGroup> | ||
|
|
||
| <Target Name="PrepareDotNetJsApiForLinking"> | ||
| <PropertyGroup> | ||
| <_EmccExportedLibraryFunction>"[@(EmccExportedLibraryFunction -> '%27%(Identity)%27', ',')]"</_EmccExportedLibraryFunction> | ||
| <_EmccExportedRuntimeMethods>"[@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]"</_EmccExportedRuntimeMethods> | ||
| <_EmccExportedFunctions>@(EmccExportedFunction -> '%(Identity)',',')</_EmccExportedFunctions> | ||
maraf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <!-- Default values for flags passed from emscripten to dotnet/runtime.js. Left here only to minimize changes to typescript --> | ||
| <EmscriptenEnvVars Include="DISABLE_LEGACY_JS_INTEROP=1" /> | ||
| <EmscriptenEnvVars Include="WASM_ENABLE_SIMD=0" /> | ||
| <EmscriptenEnvVars Include="WASM_ENABLE_EH=1" /> | ||
| <EmscriptenEnvVars Include="ENABLE_AOT_PROFILER=0" /> | ||
| <EmscriptenEnvVars Include="ENABLE_BROWSER_PROFILER=0" /> | ||
| <EmscriptenEnvVars Include="RUN_AOT_COMPILATION=0" /> | ||
|
|
||
| <_DotNetJsLinkerFlag Include="-Wl,--export,__main_argc_argv" /><!-- Export main, a temporal solution until we have a way to export async main --> | ||
| <_DotNetJsLinkerFlag Include="-s EXPORT_ES6=1" /><!-- Produce ES6 module as expented by hosting API --> | ||
| <_DotNetJsLinkerFlag Include="-s MODULARIZE=1" /><!-- Produce ES6 module as expented by hosting API --> | ||
| <_DotNetJsLinkerFlag Include="-s INVOKE_RUN=0" /><!-- Don't automatically run main, it is called explicitly by ser --> | ||
| <_DotNetJsLinkerFlag Include="-s EXPORT_NAME="'createDotnetRuntime'"" /><!-- Export emscripten factory as 'createDotnetRuntime', as expented by hosting API --> | ||
| <_DotNetJsLinkerFlag Include="-s ENVIRONMENT="'web,webview,worker,node,shell'"" /><!-- Add support for all enviroments (default list is smaller) --> | ||
| <_DotNetJsLinkerFlag Condition="'$(EmccEnvironment)' != ''" Include="-s ENVIRONMENT="$(EmccEnvironment)"" /> | ||
| <_DotNetJsLinkerFlag Include="-s FORCE_FILESYSTEM=1" /><!-- We are using JS API for accessing FS --> | ||
| <_DotNetJsLinkerFlag Include="--emit-symbol-map" Condition="'$(WasmEmitSymbolMap)' == 'true'" /> | ||
|
|
||
| <!-- JavaScript modifications to javascript produced by emscripten --> | ||
| <JSFileType Include="extpre.js" Kind="extern-pre-js" /> | ||
| <JSFileType Include="iffe.js" Kind="extern-pre-js" /> | ||
| <JSFileType Include="pre.js" Kind="pre-js" /> | ||
| <JSFileType Include="lib.js" Kind="js-library" /> | ||
| <JSFileType Include="post.js" Kind="post-js" /> | ||
| <JSFileType Include="extpost.js" Kind="extern-post-js" /> | ||
| <_WasmExtraJSFile Include="$(IlcFrameworkNativePath)src\es6\*.%(JSFileType.Identity)" Kind="%(JSFileType.Kind)" /> | ||
| <_DotNetJsLinkerFlag Include="--%(_WasmExtraJSFile.Kind) "%(_WasmExtraJSFile.Identity)"" Condition="'%(_WasmExtraJSFile.Kind)' != ''" /> | ||
|
|
||
| <!-- Exported functions required by user or runtime API --> | ||
| <_DotNetJsLinkerFlag Include="-s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$(_EmccExportedLibraryFunction)" Condition="'$(_EmccExportedLibraryFunction)' != ''" /> | ||
| <_DotNetJsLinkerFlag Include="-s EXPORTED_RUNTIME_METHODS=$(_EmccExportedRuntimeMethods)" /> | ||
| <_DotNetJsLinkerFlag Include="-s EXPORTED_FUNCTIONS=$(_EmccExportedFunctions)" /> | ||
| <_DotNetJsLinkerFlag Include="$(EmccExtraLDFlags)" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <CustomLinkerArg Include="@(_DotNetJsLinkerFlag)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
| <Target Name="CopyDotnetJsAfterLinking" AfterTargets="LinkNativeLlvm"> | ||
| <ItemGroup> | ||
| <_FilesToCopyToNative Include="$(IlcFrameworkNativePath)\dotnet*.js" /> | ||
| <_FilesToCopyToNative Include="$(IlcFrameworkNativePath)\dotnet*.map" Condition="'$(WasmEmitSourceMap)' == 'true'" /> | ||
| <_FilesToCopyToNative Include="@(WasmExtraFilesToDeploy)" /><!-- Use defined extra files to be included in the build output --> | ||
maraf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </ItemGroup> | ||
| <Copy SourceFiles="@(_FilesToCopyToNative)" DestinationFolder="$(NativeOutputPath)" /> | ||
| </Target> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -2,5 +2,5 @@ if (_nativeModuleLoaded) throw new Error("Native module already loaded"); | |||
| _nativeModuleLoaded = true; | ||||
| // see https://github.com/emscripten-core/emscripten/issues/19832 | ||||
| Module["getMemory"] = function () { return wasmMemory; } | ||||
| createDotnetRuntime = Module = createDotnetRuntime(Module); | ||||
| moduleArg = Module = moduleArg(Module); | ||||
|
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. why ? 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. Emscripten 3.1.47 generates var createDotnetRuntime = (() => {
var _scriptDir = import.meta.url;
return (
async function(moduleArg = {}) {I dunno yet if that can be configured somehow and I'm missing that flag or whether it's in empscripten (main has 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. <_EmccLinkFlags Include="-s EXPORT_NAME="'createDotnetRuntime'"" /> 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. maybe it's worth replacing the whole wasm.proj with latest from main ? 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 already have this one
It produces the createDotnetRuntime, but the argument passed in is called moduleArg
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. Here is a sample dotnet.native.js that is generated by emcripten 3.1.47 dotnet.native.zip 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. hmmm, it seems we use |
||||
| Module["getMemory"] = function () { return wasmMemory; } | ||||
Uh oh!
There was an error while loading. Please reload this page.