Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed May 4, 2023
1 parent 2e17200 commit cac6aef
Show file tree
Hide file tree
Showing 108 changed files with 2,186 additions and 2,033 deletions.
8 changes: 5 additions & 3 deletions eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@
<LibrariesRuntimeFiles Condition="'$(TargetOS)' == 'browser'"
Include="
$(LibrariesNativeArtifactsPath)dotnet.js;
$(LibrariesNativeArtifactsPath)dotnet.native.js;
$(LibrariesNativeArtifactsPath)dotnet.runtime.js;
$(LibrariesNativeArtifactsPath)dotnet.d.ts;
$(LibrariesNativeArtifactsPath)dotnet-legacy.d.ts;
$(LibrariesNativeArtifactsPath)package.json;
$(LibrariesNativeArtifactsPath)dotnet.wasm;
$(LibrariesNativeArtifactsPath)dotnet.js.symbols;
$(LibrariesNativeArtifactsPath)dotnet.native.wasm;
$(LibrariesNativeArtifactsPath)dotnet.native.js.symbols;
$(LibrariesNativeArtifactsPath)*.dat;"
IsNative="true" />
<!-- for threaded wasm -->
Expand Down Expand Up @@ -231,7 +233,7 @@
<ItemGroup Label="Wasi" Condition="'$(TargetOS)' == 'wasi'">
<LibrariesRuntimeFiles
Include="
$(LibrariesNativeArtifactsPath)dotnet.wasm;
$(LibrariesNativeArtifactsPath)dotnet.native.wasm;
$(LibrariesNativeArtifactsPath)*.dat;"
IsNative="true" />

Expand Down
2 changes: 1 addition & 1 deletion eng/testing/tests.browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<_XHarnessArgs Condition="'$(IsFunctionalTest)' == 'true'" >$(_XHarnessArgs) --expected-exit-code=$(ExpectedExitCode)</_XHarnessArgs>
<_XHarnessArgs Condition="'$(WasmXHarnessArgs)' != ''" >$(_XHarnessArgs) $(WasmXHarnessArgs)</_XHarnessArgs>
<_XHarnessArgs Condition="('$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true') and '$(_XHarnessArs.Contains(&quot;--web-server-use-cop&quot;)' != 'true'">$(_XHarnessArgs) --web-server-use-cop</_XHarnessArgs>
<_XHarnessArgs >$(_XHarnessArgs) -s dotnet.js.symbols</_XHarnessArgs>
<_XHarnessArgs >$(_XHarnessArgs) -s dotnet.native.js.symbols</_XHarnessArgs>
<_XHarnessArgs Condition="'$(_UseWasmSymbolicator)' == 'true'" >$(_XHarnessArgs) --symbol-patterns wasm-symbol-patterns.txt</_XHarnessArgs>
<_XHarnessArgs Condition="'$(_UseWasmSymbolicator)' == 'true'" >$(_XHarnessArgs) --symbolicator WasmSymbolicator.dll,Microsoft.WebAssembly.Internal.SymbolicatorWrapperForXHarness</_XHarnessArgs>
<_XHarnessArgs Condition="'$(_WasmBrowserPathForTests)' != ''" >$(_XHarnessArgs) &quot;--browser-path=$(_WasmBrowserPathForTests)&quot;</_XHarnessArgs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,13 @@
<PlatformManifestFileEntry Include="libmono-wasm-eh-wasm.a" IsNative="true" />
<PlatformManifestFileEntry Include="wasm-bundled-timezones.a" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.worker.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.js.symbols" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.runtime.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.native.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.native.worker.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.native.js.symbols" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.d.ts" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet-legacy.d.ts" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.wasm" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.native.wasm" IsNative="true" />
<PlatformManifestFileEntry Include="icudt.dat" IsNative="true" />
<PlatformManifestFileEntry Include="icudt_no_CJK.dat" IsNative="true" />
<PlatformManifestFileEntry Include="icudt_CJK.dat" IsNative="true" />
Expand All @@ -250,7 +252,6 @@
<PlatformManifestFileEntry Include="icudt_optimal_no_CJK.dat" IsNative="true" />
<PlatformManifestFileEntry Include="package.json" IsNative="true" />
<PlatformManifestFileEntry Include="pal_random.lib.js" IsNative="true" />
<PlatformManifestFileEntry Include="runtime.es6.iffe.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.es6.pre.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.es6.lib.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.es6.extpost.js" IsNative="true" />
Expand All @@ -271,6 +272,7 @@
<PlatformManifestFileEntry Include="driver.h" IsNative="true" />
<PlatformManifestFileEntry Include="stubs.c" IsNative="true" />
<PlatformManifestFileEntry Include="synthetic-pthread.c" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.wasm" IsNative="true" />
<!-- ICU-specific files -->
<PlatformManifestFileEntry Include="libicudata.a" IsNative="true" />
<PlatformManifestFileEntry Include="libicui18n.a" IsNative="true" />
Expand Down
2 changes: 1 addition & 1 deletion src/mono/sample/wasm/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$(TargetFileName)
"
Outputs="
bin/$(Configuration)/AppBundle/dotnet.wasm;
bin/$(Configuration)/AppBundle/dotnet.native.wasm;
bin/$(Configuration)/AppBundle/$(_WasmMainJSFileName);
">
<PropertyGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/mono/sample/wasm/browser-advanced/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<script type='module' src="./main.js"></script>
<script type='module' src="./dotnet.js"></script>
<link rel="preload" href="./mono-config.json" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./dotnet.wasm" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./dotnet.native.js" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./dotnet.runtime.js" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./dotnet.native.wasm" as="fetch" crossorigin="anonymous">
<!-- users should consider if they optimize for the first load or subsequent load from memory snapshot -->
<link rel="prefetch" href="./icudt.dat" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./managed/System.Private.CoreLib.webcil" as="fetch" crossorigin="anonymous">
Expand Down
4 changes: 3 additions & 1 deletion src/mono/sample/wasm/browser-bench/appstart-frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<script type="module" src="./frame-main.js"></script>
<script type='module' src="./dotnet.js"></script>
<link rel="preload" href="./mono-config.json" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./dotnet.wasm" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./dotnet.native.js" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./dotnet.runtime.js" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./dotnet.native.wasm" as="fetch" crossorigin="anonymous">
<!-- users should consider if they optimize for the first load or subsequent load from memory snapshot -->
<link rel="prefetch" href="./managed/System.Private.CoreLib.dll" as="fetch" crossorigin="anonymous">
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@


<Target Name="CopyRelinkedPackage" AfterTargets="WasmBuildApp" DependsOnTargets="Build" Inputs="$(WasmAppDir)/dotnet.js;
$(WasmAppDir)/dotnet.wasm;
$(WasmAppDir)/dotnet.runtime.js;
$(WasmAppDir)/dotnet.native.js;
$(WasmAppDir)/dotnet.native.wasm;
$(MicrosoftNetCoreAppRuntimePackNativeDir)/dotnet.d.ts;
$(MicrosoftNetCoreAppRuntimePackNativeDir)/dotnet-legacy.d.ts;
$(MicrosoftNetCoreAppRuntimePackNativeDir)/package.json;" Outputs="bin/dotnet-runtime/.npm-stamp">
<ItemGroup>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.js"/>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.wasm"/>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.runtime.js"/>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.native.js"/>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.native.wasm"/>
<NpmPackageFiles Include="$(MicrosoftNetCoreAppRuntimePackNativeDir)/dotnet.d.ts"/>
<NpmPackageFiles Include="$(MicrosoftNetCoreAppRuntimePackNativeDir)/dotnet-legacy.d.ts"/>
<NpmPackageFiles Include="$(MicrosoftNetCoreAppRuntimePackNativeDir)/package.json"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
</PropertyGroup>

<Target Name="CopyRelinkedPackage" AfterTargets="WasmBuildApp" DependsOnTargets="Build" Inputs="$(WasmAppDir)/dotnet.js;
$(WasmAppDir)/dotnet.wasm;
$(WasmAppDir)/dotnet.runtime.js;
$(WasmAppDir)/dotnet.native.js;
$(WasmAppDir)/dotnet.native.wasm;
$(MicrosoftNetCoreAppRuntimePackNativeDir)/dotnet.d.ts;
$(MicrosoftNetCoreAppRuntimePackNativeDir)/dotnet-legacy.d.ts;
$(MicrosoftNetCoreAppRuntimePackNativeDir)/package.json;" Outputs="bin/dotnet-runtime/.npm-stamp">
<ItemGroup>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.js"/>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.wasm"/>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.runtime.js"/>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.native.js"/>
<NpmPackageFiles Include="$(WasmAppDir)/dotnet.native.wasm"/>
<NpmPackageFiles Include="$(MicrosoftNetCoreAppRuntimePackNativeDir)/dotnet.d.ts"/>
<NpmPackageFiles Include="$(MicrosoftNetCoreAppRuntimePackNativeDir)/dotnet-legacy.d.ts"/>
<NpmPackageFiles Include="$(MicrosoftNetCoreAppRuntimePackNativeDir)/package.json"/>
Expand Down
6 changes: 3 additions & 3 deletions src/mono/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ The wrapper script used to actually run these tests, accepts:

Exceptions thrown after the runtime starts get symbolicating from js itself. Exceptions before that, like asserts containing native traces get symbolicated by xharness using `src/mono/wasm/symbolicator`.

If you need to symbolicate some traces manually, then you need the corresponding `dotnet.js.symbols` file. Then:
If you need to symbolicate some traces manually, then you need the corresponding `dotnet.native.js.symbols` file. Then:

```console
src/mono/wasm/symbolicator$ dotnet run /path/to/dotnet.js.symbols /path/to/file/with/traces
src/mono/wasm/symbolicator$ dotnet run /path/to/dotnet.native.js.symbols /path/to/file/with/traces
```

When not relinking, or not building with AOT, you can find `dotnet.js.symbols` in the runtime pack.
When not relinking, or not building with AOT, you can find `dotnet.native.js.symbols` in the runtime pack.

## Debugger tests on macOS

Expand Down
42 changes: 22 additions & 20 deletions src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ protected void AssertDotNetNativeFiles(NativeFilesType type, string config, bool
_ => throw new ArgumentOutOfRangeException(nameof(type))
};

AssertSameFile(Path.Combine(srcDir, "dotnet.wasm"), Path.Combine(binFrameworkDir, "dotnet.wasm"), label);
AssertSameFile(Path.Combine(srcDir, "dotnet.native.wasm"), Path.Combine(binFrameworkDir, "dotnet.native.wasm"), label);

// find dotnet*js
string? dotnetJsPath = Directory.EnumerateFiles(binFrameworkDir)
Expand All @@ -630,13 +630,13 @@ protected void AssertDotNetNativeFiles(NativeFilesType type, string config, bool
.SingleOrDefault();

Assert.True(!string.IsNullOrEmpty(dotnetJsPath), $"[{label}] Expected to find dotnet*js in {binFrameworkDir}");
AssertSameFile(Path.Combine(srcDir, "dotnet.js"), dotnetJsPath!, label);
AssertSameFile(Path.Combine(srcDir, "dotnet.native.js"), dotnetJsPath!, label);

if (type != NativeFilesType.FromRuntimePack)
{
// check that the files are *not* from runtime pack
AssertNotSameFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.wasm"), Path.Combine(binFrameworkDir, "dotnet.wasm"), label);
AssertNotSameFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.js"), dotnetJsPath!, label);
AssertNotSameFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.native.wasm"), Path.Combine(binFrameworkDir, "dotnet.native.wasm"), label);
AssertNotSameFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.native.js"), dotnetJsPath!, label);
}
}

Expand Down Expand Up @@ -667,9 +667,11 @@ protected static void AssertBasicAppBundle(string bundleDir,
var filesToExist = new List<string>()
{
mainJS,
"dotnet.wasm",
"dotnet.native.wasm",
"mono-config.json",
"dotnet.js"
"dotnet.js",
"dotnet.native.js",
"dotnet.runtime.js"
};

if (isBrowserProject)
Expand Down Expand Up @@ -751,20 +753,20 @@ void AssertIcuAssets()

protected static void AssertDotNetWasmJs(string bundleDir, bool fromRuntimePack, string targetFramework)
{
AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.wasm"),
Path.Combine(bundleDir, "dotnet.wasm"),
"Expected dotnet.wasm to be same as the runtime pack",
AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.native.wasm"),
Path.Combine(bundleDir, "dotnet.native.wasm"),
"Expected dotnet.native.wasm to be same as the runtime pack",
same: fromRuntimePack);

AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.js"),
Path.Combine(bundleDir, "dotnet.js"),
"Expected dotnet.js to be same as the runtime pack",
AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.native.js"),
Path.Combine(bundleDir, "dotnet.native.js"),
"Expected dotnet.native.js to be same as the runtime pack",
same: fromRuntimePack);
}

protected static void AssertDotNetJsSymbols(string bundleDir, bool fromRuntimePack, string targetFramework)
=> AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.js.symbols"),
Path.Combine(bundleDir, "dotnet.js.symbols"),
=> AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.native.js.symbols"),
Path.Combine(bundleDir, "dotnet.native.js.symbols"),
same: fromRuntimePack);

protected static void AssertFilesDontExist(string dir, string[] filenames, string? label = null)
Expand Down Expand Up @@ -820,17 +822,17 @@ protected void AssertBlazorBundle(string config, bool isPublish, bool dotnetWasm
binFrameworkDir ??= FindBlazorBinFrameworkDir(config, isPublish, targetFramework);

AssertBlazorBootJson(config, isPublish, targetFramework, binFrameworkDir: binFrameworkDir);
AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.wasm"),
Path.Combine(binFrameworkDir, "dotnet.wasm"),
"Expected dotnet.wasm to be same as the runtime pack",
AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.native.wasm"),
Path.Combine(binFrameworkDir, "dotnet.native.wasm"),
"Expected dotnet.native.wasm to be same as the runtime pack",
same: dotnetWasmFromRuntimePack);

string? dotnetJsPath = Directory.EnumerateFiles(binFrameworkDir, "dotnet.*.js").FirstOrDefault();
Assert.True(dotnetJsPath != null, $"Could not find blazor's dotnet*js in {binFrameworkDir}");

AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.js"),
AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.native.js"),
dotnetJsPath!,
"Expected dotnet.js to be same as the runtime pack",
"Expected dotnet.native.js to be same as the runtime pack",
same: dotnetWasmFromRuntimePack);
}

Expand All @@ -847,7 +849,7 @@ protected void AssertBlazorBootJson(string config, bool isPublish, string target
Assert.NotNull(runtimeObj);

string msgPrefix=$"[{( isPublish ? "publish" : "build" )}]";
Assert.True(runtimeObj!.Where(kvp => kvp.Key == "dotnet.wasm").Any(), $"{msgPrefix} Could not find dotnet.wasm entry in blazor.boot.json");
Assert.True(runtimeObj!.Where(kvp => kvp.Key == "dotnet.native.wasm").Any(), $"{msgPrefix} Could not find dotnet.native.wasm entry in blazor.boot.json");
Assert.True(runtimeObj!.Where(kvp => kvp.Key.StartsWith("dotnet.", StringComparison.OrdinalIgnoreCase) &&
kvp.Key.EndsWith(".js", StringComparison.OrdinalIgnoreCase)).Any(),
$"{msgPrefix} Could not find dotnet.*js in {bootJson}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void ExtraEmccFlagsSetButNoRealChange(BuildArgs buildArgs, string extraCF
(buildArgs, BuildPaths paths) = FirstNativeBuild(s_mainReturns42, nativeRelink: true, invariant: false, buildArgs, id);
var pathsDict = GetFilesTable(buildArgs, paths, unchanged: true);
if (extraLDFlags.Length > 0)
pathsDict.UpdateTo(unchanged: false, "dotnet.wasm", "dotnet.js");
pathsDict.UpdateTo(unchanged: false, "dotnet.native.wasm", "dotnet.native.js");

var originalStat = StatFiles(pathsDict.Select(kvp => kvp.Value.fullPath));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ internal void CompareStat(IDictionary<string, FileStat> oldStat, IDictionary<str
Path.Combine(paths.ObjWasmDir, "pinvoke-table.h"),
Path.Combine(paths.ObjWasmDir, "driver-gen.c"),

Path.Combine(paths.BundleDir, "dotnet.wasm"),
Path.Combine(paths.BundleDir, "dotnet.js")
Path.Combine(paths.BundleDir, "dotnet.native.wasm"),
Path.Combine(paths.BundleDir, "dotnet.js"),
Path.Combine(paths.BundleDir, "dotnet.runtime.js"),
Path.Combine(paths.BundleDir, "dotnet.native.js"),
};

if (buildArgs.AOT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void BlazorOnlyLinkRebuild(string config)

var pathsDict = GetFilesTable(true, objDir);
pathsDict.Remove("runtime-icall-table.h");
pathsDict.UpdateTo(unchanged: false, "dotnet.wasm", "dotnet.js", "emcc-link.rsp");
pathsDict.UpdateTo(unchanged: false, "dotnet.native.wasm", "dotnet.native.js", "emcc-link.rsp");

var originalStat = StatFiles(pathsDict.Select(kvp => kvp.Value.fullPath));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void SimpleStringChangeInSource(BuildArgs buildArgs, bool nativeRelink, b
string mainAssembly = $"{buildArgs.ProjectName}.dll";
var pathsDict = GetFilesTable(buildArgs, paths, unchanged: true);
pathsDict.UpdateTo(unchanged: false, mainAssembly);
pathsDict.UpdateTo(unchanged: !buildArgs.AOT, "dotnet.wasm", "dotnet.js");
pathsDict.UpdateTo(unchanged: !buildArgs.AOT, "dotnet.native.wasm", "dotnet.native.js");

if (buildArgs.AOT)
pathsDict.UpdateTo(unchanged: false, $"{mainAssembly}.bc", $"{mainAssembly}.o");
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/Wasm.Build.Tests/WasmTemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public void ConsolePublishAndRun(string config, bool aot, bool relinking)
}
else
{
AssertFilesDontExist(Path.Combine(GetBinDir(config), "AppBundle"), new[] { "dotnet.js.symbols" });
AssertFilesDontExist(Path.Combine(GetBinDir(config), "AppBundle"), new[] { "dotnet.native.js.symbols" });
}

string runArgs = $"run --no-build -c {config}";
Expand Down
Loading

0 comments on commit cac6aef

Please sign in to comment.