Skip to content
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

[browser] NativeAOT-LLVM support in browser-bench #110611

Merged
merged 8 commits into from
Dec 13, 2024
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
2 changes: 1 addition & 1 deletion src/mono/browser/build/WasmApp.InTree.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<WasmCommonTargetsPath Condition="'$(WasmCommonTargetsPath)' == ''">$([MSBuild]::NormalizeDirectory($(MonoProjectRoot), 'wasm', 'build'))</WasmCommonTargetsPath>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)BrowserWasmApp.props" />
<Import Project="$(MSBuildThisFileDirectory)BrowserWasmApp.props" Condition="'$(UsingNativeAOT)' != 'true'" />
<PropertyGroup>
<SelfContained>true</SelfContained>
<Platform>AnyCPU</Platform>
Expand Down
3 changes: 2 additions & 1 deletion src/mono/browser/build/WasmApp.InTree.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<!-- TODO: this breaks runtime tests on Helix due to the file not being there for some reason. Once this is fixed we can remove the UpdateRuntimePack target here -->
<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" Condition="'$(TargetingpacksTargetsImported)' != 'true' and '$(ImportTargetingPacksTargetsInWasmAppTargets)' == 'true'"/>
<Import Project="$(MSBuildThisFileDirectory)BrowserWasmApp.targets" />
<Import Project="$(MSBuildThisFileDirectory)BrowserWasmApp.targets" Condition="'$(UsingNativeAOT)' != 'true'" />
<Import Project="$(MSBuildThisFileDirectory)EmSdkRepo.Defaults.props" Condition="'$(UsingNativeAOT)' == 'true' and '$(EMSDK_PATH)' != ''" />

<!-- FIXME: use proper dependency -->
<Target Name="SetupAppHostConfig" BeforeTargets="_WasmGenerateAppBundle">
Expand Down
15 changes: 10 additions & 5 deletions src/mono/sample/wasm/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@
<_ScriptExt Condition="'$(OS)' == 'Windows_NT'">.cmd</_ScriptExt>
<_ScriptExt Condition="'$(OS)' != 'Windows_NT'">.sh</_ScriptExt>
<_Dotnet>$(RepoRoot)dotnet$(_ScriptExt)</_Dotnet>
<_AOTFlag Condition="'$(RunAOTCompilation)' != ''">/p:RunAOTCompilation=$(RunAOTCompilation)</_AOTFlag>
<_HybridGlobalizationFlag Condition="'$(HybridGlobalization)' != ''">/p:HybridGlobalization=$(HybridGlobalization)</_HybridGlobalizationFlag>
<_WasmEnableThreadsFlag Condition="'$(WasmEnableThreads)' != ''">/p:WasmEnableThreads=$(WasmEnableThreads)</_WasmEnableThreadsFlag>
<_SampleProject Condition="'$(_SampleProject)' == ''">$(MSBuildProjectFile)</_SampleProject>
<_SampleAssembly Condition="'$(_SampleAssembly)' == ''">$(TargetFileName)</_SampleAssembly>
<BuildAdditionalArgs Condition="'$(MonoDiagnosticsMock)' != ''">$(BuildAdditionalArgs) /p:MonoDiagnosticsMock=$(MonoDiagnosticsMock) </BuildAdditionalArgs>
</PropertyGroup>
<Exec Command="$(_Dotnet) publish -bl:publish-browser.binlog /p:Configuration=$(Configuration) /p:TargetArchitecture=wasm /p:TargetOS=browser $(_AOTFlag) $(_HybridGlobalizationFlag) $(_WasmEnableThreadsFlag) $(_SampleProject) $(BuildAdditionalArgs)" />
<ItemGroup>
<NestedBuildProperty Include="RunAOTCompilation" />
<NestedBuildProperty Include="HybridGlobalization" />
<NestedBuildProperty Include="InvariantGlobalization" />
<NestedBuildProperty Include="UsingNativeAOT" />
<NestedBuildProperty Include="WasmEnableThreads" />
<NestedBuildProperty Include="MonoDiagnosticsMock" />
<NestedBuildPropertyValue Include="/p:%(NestedBuildProperty.Identity)=$(%(NestedBuildProperty.Identity))" Condition="'$(%(NestedBuildProperty.Identity))' != '%(NestedBuildProperty.DefaultValue)'" />
</ItemGroup>
<Exec Command="$(_Dotnet) publish -bl:publish-browser.binlog /p:Configuration=$(Configuration) /p:TargetArchitecture=wasm /p:TargetOS=browser @(NestedBuildPropertyValue, ' ') $(_SampleProject) $(BuildAdditionalArgs)" />
</Target>
<Target Name="_ComputeMainJSFileName">
<Error Condition="'$(WasmMainJSPath)' == ''" Text="%24(WasmMainJSPath) property needs to be set" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,33 @@
<EnableAggressiveTrimming Condition="'$(EnableAOTAndTrimming)' != ''">$(EnableAOTAndTrimming)</EnableAggressiveTrimming>
<PublishTrimmed Condition="'$(EnableAOTAndTrimming)' != ''">$(EnableAOTAndTrimming)</PublishTrimmed>
<RunAOTCompilation Condition="'$(EnableAOTAndTrimming)' != ''">$(EnableAOTAndTrimming)</RunAOTCompilation>
<WasmRuntimeAssetsLocation>./</WasmRuntimeAssetsLocation>
</PropertyGroup>

<!-- NativeAOT -->
<PropertyGroup Condition="'$(UsingNativeAOT)' == 'true'">
<PublishTrimmed>true</PublishTrimmed>
<PublishDir>$(MSBuildThisFileDirectory)/bin/$(Configuration)/AppBundle</PublishDir>
<DebugType>none</DebugType>
<RestoreAdditionalProjectSources>$(RestoreAdditionalProjectSources);https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json</RestoreAdditionalProjectSources>
Copy link
Member

Choose a reason for hiding this comment

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

Can the reference to the dotnet-experimental feed be in the runtimelab branch only?

I understand that this is under a condition currently, but it makes auditing of dotnet/runtime more complicated and introduces risk of accidental dependencies of dotnet/rutime on runtimelab.

<UsingBrowserRuntimeWorkload>false</UsingBrowserRuntimeWorkload>
<UsingWasiRuntimeWorkload>false</UsingWasiRuntimeWorkload>
<UsingEmscriptenWorkload>true</UsingEmscriptenWorkload>
<DotNetJsApi>true</DotNetJsApi>
<_ExeExt Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">.exe</_ExeExt>
</PropertyGroup>
<ItemGroup Condition="'$(UsingNativeAOT)' == 'true'">
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="$(ProductVersion)-*" />
<PackageReference Include="runtime.$(ToolsRID).Microsoft.DotNet.ILCompiler.LLVM" Version="$(ProductVersion)-*" />
<!-- TODO: Can be removed when emscripten workload refactoring is aligned with NativeAOT -->
<EmscriptenEnvVars Include="DOTNET_EMSCRIPTEN_LLVM_ROOT=$(EmscriptenSdkToolsPath)bin" />
<EmscriptenEnvVars Include="DOTNET_EMSCRIPTEN_BINARYEN_ROOT=$(EmscriptenSdkToolsPath)" />
<EmscriptenEnvVars Include="DOTNET_EMSCRIPTEN_NODE_JS=$([MSBuild]::NormalizePath($(EmscriptenNodeToolsPath), 'bin', 'node$(_ExeExt)'))" />
<EmscriptenEnvVars Include="EM_FROZEN_CACHE=1" />
<EmscriptenEnvVars Include="EM_CACHE=$(WasmCachePath)" Condition="'$(WasmCachePath)' != ''" />
</ItemGroup>
<!-- /NativeAOT -->

<ItemGroup>
<WasmExtraFilesToDeploy Include="index.html" />
<WasmExtraFilesToDeploy Include="main.js" />
Expand Down
8 changes: 4 additions & 4 deletions src/mono/sample/wasm/browser-bench/appstart-frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="module" src="./frame-main.js"></script>
<script type='module' src="./_framework/dotnet.js"></script>
<link rel="preload" href="./_framework/blazor.boot.json" as="fetch" crossorigin="use-credentials">
<link rel="prefetch" href="./_framework/dotnet.native.js" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./_framework/dotnet.runtime.js" as="fetch" crossorigin="anonymous">
<script type='module' src="./dotnet.js"></script>
<link rel="preload" href="./blazor.boot.json" as="fetch" crossorigin="use-credentials">
<link rel="prefetch" href="./dotnet.native.js" as="fetch" crossorigin="anonymous">
<link rel="prefetch" href="./dotnet.runtime.js" as="fetch" crossorigin="anonymous">
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion src/mono/sample/wasm/browser-bench/frame-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

import { dotnet, exit } from './_framework/dotnet.js'
import { dotnet, exit } from './dotnet.js'
maraf marked this conversation as resolved.
Show resolved Hide resolved

class FrameApp {
async init({ getAssemblyExports }) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/sample/wasm/browser-bench/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

import { dotnet, exit } from './_framework/dotnet.js'
import { dotnet, exit } from './dotnet.js'

let runBenchmark;
let setTasks;
Expand Down
Loading