Skip to content

Commit fbf63ac

Browse files
authored
[wasm] native build flags (#119307)
1 parent b6127f9 commit fbf63ac

File tree

10 files changed

+37
-26
lines changed

10 files changed

+37
-26
lines changed

eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ jobs:
8383
nameSuffix: _Threading
8484
extraBuildArgs: /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
8585
extraHelixArguments: /p:WasmEnableThreads=true
86+
shouldContinueOnError: true
8687
isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
8788
isWasmOnlyBuild: ${{ parameters.isWasmOnlyBuild }}
8889
alwaysRun: ${{ parameters.isWasmOnlyBuild }}

eng/testing/tests.browser.targets

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
<!-- set this when provisioning emsdk on CI -->
1212
<EMSDK_PATH Condition="'$(EMSDK_PATH)' == '' and '$(ContinuousIntegrationBuild)' == 'true' and '$(MonoProjectRoot)' != ''">$([MSBuild]::NormalizeDirectory($(BrowserProjectRoot), 'emsdk'))</EMSDK_PATH>
1313

14-
<!--
15-
- For regular library tests, it will use the symbols file from the runtime pack.
16-
- for AOT library tests, we avoid WasmNativeDebugSymbols so that we don't run OOM on helix during wasm-opt
17-
-->
18-
<WasmNativeStrip Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(RunAOTCompilation)' == 'true'">true</WasmNativeStrip>
19-
<WasmNativeDebugSymbols Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(RunAOTCompilation)' == 'true'">false</WasmNativeDebugSymbols>
2014
<WasmEmitSymbolMap Condition="'$(WasmEmitSymbolMap)' == ''">true</WasmEmitSymbolMap>
2115

2216
<_WasmMainJSFileName Condition="'$(WasmMainJSPath)' != ''">$([System.IO.Path]::GetFileName('$(WasmMainJSPath)'))</_WasmMainJSFileName>
@@ -172,8 +166,6 @@
172166
<WasmMainHtmlPath>$(PublishDir)index.html</WasmMainHtmlPath>
173167
<WasmInvariantGlobalization>$(InvariantGlobalization)</WasmInvariantGlobalization>
174168
<WasmGenerateRunV8Script>true</WasmGenerateRunV8Script>
175-
176-
<WasmNativeDebugSymbols Condition="'$(DebuggerSupport)' == 'true' and '$(WasmNativeDebugSymbols)' == ''">true</WasmNativeDebugSymbols>
177169
</PropertyGroup>
178170

179171
<ItemGroup Condition="'$(IncludeSatelliteAssembliesInVFS)' == 'true' and '$(BuildAOTTestsOnHelix)' != 'true'">

eng/testing/tests.wasi.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
<PropertyGroup>
9797
<WasmAppDir>$(BundleDir)</WasmAppDir>
9898
<WasmInvariantGlobalization>$(InvariantGlobalization)</WasmInvariantGlobalization>
99-
100-
<WasmNativeDebugSymbols Condition="'$(DebuggerSupport)' == 'true' and '$(WasmNativeDebugSymbols)' == ''">true</WasmNativeDebugSymbols>
10199
</PropertyGroup>
102100

103101
<ItemGroup Condition="'$(IncludeSatelliteAssembliesInVFS)' == 'true' and '$(BuildAOTTestsOnHelix)' != 'true'">

eng/testing/tests.wasm.targets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
<WasmDebugLevel Condition="'$(Configuration)' == 'Debug' and '$(WasmDebugLevel)' == ''">-1</WasmDebugLevel>
1818
<WasmDebugLevel Condition="'$(WasmDebugLevel)' == ''">0</WasmDebugLevel>
1919

20+
<!--
21+
- For regular library tests, it will use the symbols file from the runtime pack.
22+
- for AOT library tests, we avoid WasmNativeDebugSymbols and we WasmNativeStrip so that we don't run OOM on helix during wasm-opt
23+
-->
24+
<WasmNativeStrip Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(RunAOTCompilation)' == 'true'">true</WasmNativeStrip>
25+
<WasmNativeDebugSymbols Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(RunAOTCompilation)' == 'true'">false</WasmNativeDebugSymbols>
26+
<WasmNativeDebugSymbols Condition="'$(DebuggerSupport)' == 'true' and '$(WasmNativeDebugSymbols)' == ''">true</WasmNativeDebugSymbols>
27+
2028
<TrimMode Condition="'$(TrimMode)' == ''">full</TrimMode>
2129
<JsonSerializerIsReflectionEnabledByDefault Condition="'$(JsonSerializerIsReflectionEnabledByDefault)' == ''">true</JsonSerializerIsReflectionEnabledByDefault>
2230

src/mono/wasi/build/WasiApp.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@
176176
<_MonoAotCrossCompilerPath>@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier','wasi-wasm'))</_MonoAotCrossCompilerPath>
177177
<_WasmDefaultFlagsRsp>$([MSBuild]::NormalizePath($(_WasmRuntimePackSrcDir), 'wasi-default.rsp'))</_WasmDefaultFlagsRsp>
178178
<_WasmDefaultLinkFlagsRsp>$([MSBuild]::NormalizePath($(_WasmRuntimePackSrcDir), 'wasi-link.rsp'))</_WasmDefaultLinkFlagsRsp>
179-
<WasmNativeDebugSymbols Condition="'$(WasmNativeDebugSymbols)' == ''">true</WasmNativeDebugSymbols>
180179
<WasmLinkIcalls Condition="'$(WasmLinkIcalls)' == ''">$(WasmBuildNative)</WasmLinkIcalls>
181180

182181
<_WasmICallTablePath>$(_WasmIntermediateOutputPath)icall-table.h</_WasmICallTablePath>
@@ -242,7 +241,6 @@
242241
<_WasiClangCommonFlags Include="$(WasiClangFlags)" />
243242
<_WasiClangCommonFlags Include="--sysroot=&quot;$(WASI_SDK_PATH.Replace('\', '/'))share/wasi-sysroot&quot;" />
244243
<_WasiClangCommonFlags Include="--target=wasm32-unknown-wasip2" />
245-
<_WasiClangCommonFlags Include="-g" Condition="'$(WasmNativeStrip)' == 'false'" />
246244
<_WasiClangCommonFlags Include="-v" Condition="'$(WasiClangVerbose)' != 'false'" />
247245
<!--<_WasiClangCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0" Condition="'$(WasmEnableExceptionHandling)' == 'false'" />-->
248246
<!--<_WasiClangCommonFlags Include="-fwasm-exceptions" Condition="'$(WasmEnableExceptionHandling)' == 'true'" />-->

src/mono/wasi/wasi.proj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<_WasiDefaultsRspPath>$(NativeBinDir)src\wasi-default.rsp</_WasiDefaultsRspPath>
1515
<_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp</_WasiCompileRspPath>
1616
<_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp</_WasiLinkRspPath>
17-
<WasmNativeStrip Condition="'$(ContinuousIntegrationBuild)' == 'true'">false</WasmNativeStrip>
1817
</PropertyGroup>
1918

2019
<Import Project="$(RepositoryEngineeringDir)AcquireWasiSdk.targets" />

src/mono/wasm/Wasm.Build.Tests/NativeRebuildTests/FlagsChangeRebuildTest.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ public async Task ExtraEmccFlagsSetButNoRealChange(Configuration config, bool ao
3535
ProjectInfo info = CopyTestAsset(config, aot, TestAsset.WasmBasicTestApp, "rebuild_flags");
3636
BuildPaths paths = await FirstNativeBuildAndRun(info, config, aot, requestNativeRelink: true, invariant: false);
3737
var pathsDict = GetFilesTable(info.ProjectName, aot, paths, unchanged: true);
38-
bool dotnetNativeFilesUnchanged = extraLDFlags.Length == 0;
38+
bool dotnetNativeFilesUnchanged = extraLDFlags.Length == 0 && extraCFlags.Length == 0;
3939
if (!dotnetNativeFilesUnchanged)
4040
pathsDict.UpdateTo(unchanged: false, "dotnet.native.wasm", "dotnet.native.js");
4141

42+
if (extraCFlags.Length != 0)
43+
pathsDict.UpdateTo(unchanged: false, "driver.o", "runtime.o", "corebindings.o", "pinvoke.o");
44+
4245
var originalStat = StatFiles(pathsDict);
4346

4447
// Rebuild
@@ -52,10 +55,10 @@ public async Task ExtraEmccFlagsSetButNoRealChange(Configuration config, bool ao
5255
// cflags: pinvoke get's compiled, but doesn't overwrite pinvoke.o
5356
// and thus doesn't cause relinking
5457
TestUtils.AssertSubstring("pinvoke.c -> pinvoke.o", output, contains: extraCFlags.Length > 0);
55-
56-
// ldflags: link step args change, so it should trigger relink
57-
TestUtils.AssertSubstring("Linking with emcc", output, contains: extraLDFlags.Length > 0);
58-
58+
59+
// ldflags or cflags: link step args change, so it should trigger relink
60+
TestUtils.AssertSubstring("Linking with emcc", output, contains: !dotnetNativeFilesUnchanged);
61+
5962
if (aot)
6063
{
6164
// ExtraEmccLDFlags does not affect .bc files

src/mono/wasm/Wasm.Build.Tests/WasmNativeDefaultsTests.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void WasmNativeStripDefaultWithBuild(Configuration config, string extraPr
144144
CheckPropertyValues(line,
145145
wasmBuildNative: expectedWasmBuildNativeValue,
146146
wasmNativeStrip: expectedWasmNativeStripValue,
147-
wasmNativeDebugSymbols: true,
147+
wasmNativeDebugSymbols: config == Configuration.Debug && !expectedWasmNativeStripValue,
148148
wasmBuildingForNestedPublish: null);
149149
}
150150

@@ -158,7 +158,7 @@ public void WasmNativeStripDefaultWithPublish(Configuration config, string extra
158158
CheckPropertyValues(line,
159159
wasmBuildNative: expectedWasmBuildNativeValue,
160160
wasmNativeStrip: expectedWasmNativeStripValue,
161-
wasmNativeDebugSymbols: true,
161+
wasmNativeDebugSymbols: false,
162162
wasmBuildingForNestedPublish: true);
163163
}
164164

@@ -225,12 +225,19 @@ public void WithNativeReference(Configuration config, string extraProperties, bo
225225
private void InferAndCheckPropertyValues(string? line, bool isPublish, bool wasmBuildNative, Configuration config)
226226
{
227227
bool expectedWasmNativeStripValue;
228+
bool expectedWasmNativeDebugSymbols;
228229
if (!isPublish && wasmBuildNative && config == Configuration.Debug)
230+
{
229231
expectedWasmNativeStripValue = false;
232+
expectedWasmNativeDebugSymbols = true;
233+
}
230234
else
235+
{
236+
expectedWasmNativeDebugSymbols = false;
231237
expectedWasmNativeStripValue = true;
238+
}
232239

233-
CheckPropertyValues(line, wasmBuildNative, expectedWasmNativeStripValue, /*wasmNativeDebugSymbols*/true, isPublish);
240+
CheckPropertyValues(line, wasmBuildNative, expectedWasmNativeStripValue, expectedWasmNativeDebugSymbols, isPublish);
234241
}
235242

236243
private void CheckPropertyValues(string? line, bool wasmBuildNative, bool wasmNativeStrip, bool wasmNativeDebugSymbols, bool? wasmBuildingForNestedPublish)
@@ -240,6 +247,11 @@ private void CheckPropertyValues(string? line, bool wasmBuildNative, bool wasmNa
240247
$"WasmNativeStrip: '{wasmNativeStrip.ToString().ToLower()}', " +
241248
$"WasmNativeDebugSymbols: '{wasmNativeDebugSymbols.ToString().ToLower()}', " +
242249
$"WasmBuildingForNestedPublish: '{(wasmBuildingForNestedPublish.HasValue && wasmBuildingForNestedPublish == true ? "true" : "")}'";
250+
if (!line.Contains(expected))
251+
{
252+
_testOutput.WriteLine($"Actual: {line}");
253+
_testOutput.WriteLine($"Expected: {expected}");
254+
}
243255
Assert.Contains(expected, line);
244256
}
245257
}

src/mono/wasm/build/WasmApp.Common.targets

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,13 +529,15 @@
529529
</PropertyGroup>
530530

531531
<!-- Default with nothing set: Build+relink+config=debug -->
532-
<PropertyGroup Condition="'$(WasmNativeDebugSymbols)' == '' and '$(WasmNativeStrip)' == '' and '$(WasmBuildingForNestedPublish)' != 'true' and '$(WasmBuildNative)' == 'true' and '$(Configuration)' == 'Debug'">
533-
<WasmNativeDebugSymbols>true</WasmNativeDebugSymbols>
532+
<PropertyGroup Condition="'$(WasmNativeDebugSymbols)' != 'false' and '$(WasmNativeStrip)' == '' and '$(WasmBuildingForNestedPublish)' != 'true' and '$(WasmBuildNative)' == 'true' and '$(Configuration)' == 'Debug'">
534533
<WasmNativeStrip>false</WasmNativeStrip>
535534
</PropertyGroup>
535+
<PropertyGroup Condition="'$(WasmNativeDebugSymbols)' == '' and '$(WasmNativeStrip)' == 'false' and '$(WasmBuildingForNestedPublish)' != 'true' and '$(WasmBuildNative)' == 'true' and '$(Configuration)' == 'Debug'">
536+
<WasmNativeDebugSymbols>true</WasmNativeDebugSymbols>
537+
</PropertyGroup>
536538

537539
<PropertyGroup>
538-
<WasmNativeDebugSymbols Condition="'$(WasmNativeDebugSymbols)' == ''">true</WasmNativeDebugSymbols>
540+
<WasmNativeDebugSymbols Condition="'$(WasmNativeDebugSymbols)' == ''">false</WasmNativeDebugSymbols>
539541
<WasmNativeStrip Condition="'$(WasmNativeStrip)' == ''">true</WasmNativeStrip>
540542
</PropertyGroup>
541543
</Target>

src/mono/wasm/data/aot-tests/ProxyProjectForAOTOnHelix.proj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
<IntermediateOutputPath>$(TestRootDir)\obj\</IntermediateOutputPath>
1313

1414
<WasmStripAOTAssemblies>false</WasmStripAOTAssemblies>
15-
<WasmNativeDebugSymbols>true</WasmNativeDebugSymbols>
16-
<WasmNativeStrip>false</WasmNativeStrip>
1715
<WasmBuildAppDependsOn>PrepareForWasmBuildApp;$(WasmBuildAppDependsOn)</WasmBuildAppDependsOn>
1816

1917
<_PropsFile>$(MSBuildThisFileDirectory)$(MSBuildThisFileName).props</_PropsFile>

0 commit comments

Comments
 (0)