Skip to content

Commit

Permalink
[wasm] Enable dedup by default. (#80260)
Browse files Browse the repository at this point in the history
* [wasm] Enable dedup by default.

* [wasm] Enable symbol map for AOT tests too

* MonoAOTCompiler: Fix up the path for the output items if they had been

.. copied to `aot-in` for the compilation step.

Example:
- when using WasmDedup=true, we get the main assemblies in `publish`
directory after linking, but `aot-instances.dll` is in different directory.
- this causes `MonoAOTCompiler` to copy all of them to a temporary `aot-in` dir for compiling with `mono-aot-cross`.
- And when the output items are set, we get:

```
 Output Item(s):
     _WasmAssembliesInternal=
         obj/Debug/net8.0/browser-wasm/wasm/for-publish/aot-in/Debug_u4nbxx3i.gc5.dll
                 LlvmBitcodeFile=obj/Debug/net8.0/browser-wasm/wasm/for-publish/Debug_u4nbxx3i.gc5.dll.bc
```

- here the `ItemSpec` is incorrectly set to the temporary `aot-in` path
- which can cause build failures in the following build steps

* WBT: remove redundant case

Co-authored-by: Ankit Jain <radical@gmail.com>
  • Loading branch information
vargaz and radical authored Jan 18, 2023
1 parent 559aa0e commit f3af676
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion eng/testing/tests.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- for AOT library tests, we use WasmNativeStrip=false, so we already have symbols
-->
<WasmNativeStrip Condition="'$(WasmNativeStrip)' == ''">false</WasmNativeStrip>
<WasmEmitSymbolMap Condition="'$(WasmEmitSymbolMap)' == '' and '$(RunAOTCompilation)' != 'true'">true</WasmEmitSymbolMap>
<WasmEmitSymbolMap Condition="'$(WasmEmitSymbolMap)' == ''">true</WasmEmitSymbolMap>

<!-- Run only if previous command succeeded -->
<_ShellCommandSeparator Condition="'$(OS)' == 'Windows_NT'">&amp;&amp;</_ShellCommandSeparator>
Expand Down
1 change: 0 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/WasmTemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ public static TheoryData<string, bool, bool> TestDataForConsolePublishAndRun()
{
var data = new TheoryData<string, bool, bool>();
data.Add("Debug", false, false);
data.Add("Debug", false, false);
data.Add("Debug", false, true);
data.Add("Release", false, false); // Release relinks by default

Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
-->

<PropertyGroup>
<WasmDedup Condition="'$(WasmDedup)' == ''">false</WasmDedup>
<WasmDedup Condition="'$(WasmDedup)' == ''">true</WasmDedup>
<WasmEnableExceptionHandling Condition="'$(WasmEnableExceptionHandling)' == ''">false</WasmEnableExceptionHandling>
<WasmEnableSIMD Condition="'$(WasmEnableSIMD)' == ''">false</WasmEnableSIMD>

Expand Down
12 changes: 9 additions & 3 deletions src/tasks/AotCompilerTask/MonoAOTCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ private IEnumerable<ITaskItem> EnsureAllAssembliesInTheSameDir(IEnumerable<ITask

ITaskItem newAsm = new TaskItem(newPath);
asmItem.CopyMetadataTo(newAsm);
asmItem.SetMetadata(s_originalFullPathMetadataName, asmPath);
newAsm.SetMetadata(s_originalFullPathMetadataName, asmPath);
newAssemblies.Add(newAsm);
}

Expand Down Expand Up @@ -1076,8 +1076,14 @@ private static List<ITaskItem> ConvertAssembliesDictToOrderedList(ConcurrentDict
List<ITaskItem> outItems = new(originalAssemblies.Count);
foreach (ITaskItem item in originalAssemblies)
{
if (dict.TryGetValue(item.GetMetadata("FullPath"), out ITaskItem? dictItem))
outItems.Add(dictItem);
if (!dict.TryGetValue(item.GetMetadata("FullPath"), out ITaskItem? dictItem))
continue;

string originalFullPath = item.GetMetadata(s_originalFullPathMetadataName);
if (!string.IsNullOrEmpty(originalFullPath))
dictItem.ItemSpec = originalFullPath;

outItems.Add(dictItem);
}
return outItems;
}
Expand Down

0 comments on commit f3af676

Please sign in to comment.