From b72c3ae6072e30b09735febbe72f545194da9314 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 13 Dec 2023 19:25:55 -0500 Subject: [PATCH 1/2] [wasm/wasi] Fix size regression Blazor size regression was fixed by: ``` commit ec31705ba2dcde3a7b464ae66741f524282076a9 Author: Ankit Jain Date: Wed Dec 6 05:36:59 2023 -0500 [wasm] Fix regressed file sizes for blazor (#92664) ``` .. but a subsequent PR created close to that undid some of the changes: ``` commit a128c1503a5ed423501cf35bcb051b814936027c Author: Ankit Jain Date: Mon Dec 11 15:45:58 2023 -0500 [wasm/wasi] Consolidate build targets (#95775) ``` Essentially, `-g` was being passed to the link, and compile-bc steps. Found in https://github.com/dotnet/perf-autofiling-issues/issues/25891 . --- src/mono/wasi/build/WasiApp.targets | 2 ++ src/mono/wasm/build/BrowserWasmApp.targets | 4 ++-- src/mono/wasm/build/WasmApp.Common.targets | 15 +++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/mono/wasi/build/WasiApp.targets b/src/mono/wasi/build/WasiApp.targets index 9e499a7c8029af..e54fbe4f89ac1a 100644 --- a/src/mono/wasi/build/WasiApp.targets +++ b/src/mono/wasi/build/WasiApp.targets @@ -190,6 +190,8 @@ <_WasiClangCFlags Include=""-I%(_WasmCommonIncludePaths.Identity)"" /> <_WasiClangCFlags Include="-I"$(MicrosoftNetCoreAppRuntimePackRidNativeDir.Replace('\', '/'))include"" /> + <_WasiClangCFlags Include="-g" Condition="'$(WasmNativeDebugSymbols)' == 'true'" /> + <_WasiClangCFlags Condition="'@(WasiAfterRuntimeLoadedDeclarations)' != ''" Include="-D WASI_AFTER_RUNTIME_LOADED_DECLARATIONS="@(WasiAfterRuntimeLoadedDeclarations, ' ')"" /> <_WasiClangCFlags Condition="'@(WasiAfterRuntimeLoadedCalls)' != ''" diff --git a/src/mono/wasm/build/BrowserWasmApp.targets b/src/mono/wasm/build/BrowserWasmApp.targets index 3135d39af31aa6..2e1c913b6c17e0 100644 --- a/src/mono/wasm/build/BrowserWasmApp.targets +++ b/src/mono/wasm/build/BrowserWasmApp.targets @@ -31,7 +31,6 @@ true true false - true false @@ -288,7 +287,7 @@ <_EmccCommonFlags Include="$(_DefaultEmccFlags)" /> <_EmccCommonFlags Include="$(EmccFlags)" /> - <_EmccCommonFlags Include="-g" Condition="'$(WasmNativeDebugSymbols)' == 'true'" /> + <_EmccCommonFlags Include="-g" Condition="'$(WasmNativeStrip)' == 'false'" /> <_EmccCommonFlags Include="-v" Condition="'$(EmccVerbose)' != 'false'" /> <_EmccCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0" Condition="'$(WasmEnableExceptionHandling)' == 'false'" /> <_EmccCommonFlags Include="-fwasm-exceptions" Condition="'$(WasmEnableExceptionHandling)' == 'true'" /> @@ -317,6 +316,7 @@ <_EmccCFlags Include="-emit-llvm" /> <_EmccCFlags Include=""-I%(_EmccIncludePaths.Identity)"" /> + <_EmccCFlags Include="-g" Condition="'$(WasmNativeDebugSymbols)' == 'true'" /> <_EmccLDFlags Include="$(WasmLinkOptimizationFlag)" /> diff --git a/src/mono/wasm/build/WasmApp.Common.targets b/src/mono/wasm/build/WasmApp.Common.targets index 9aee139f2df65a..ba7cf7f700ac31 100644 --- a/src/mono/wasm/build/WasmApp.Common.targets +++ b/src/mono/wasm/build/WasmApp.Common.targets @@ -117,7 +117,6 @@ $(PrepareInputsForWasmBuildDependsOn); _SetupToolchain; _SetWasmBuildNativeDefaults; - _SetWasmNativeStripDefault; _GetDefaultWasmAssembliesToBundle; _WasmGetRuntimeConfigPath; _ReadWasmProps; @@ -516,7 +515,6 @@ true true - false @@ -531,15 +529,20 @@ true + + false - - + + + true + false + + - - false + true true From 18732e7c306eaa0e01ddb47d9110a029af079b15 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 13 Dec 2023 21:34:08 -0500 Subject: [PATCH 2/2] [wasm] Add flag missed in the consolidate PR --- src/mono/wasm/build/BrowserWasmApp.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/build/BrowserWasmApp.targets b/src/mono/wasm/build/BrowserWasmApp.targets index 2e1c913b6c17e0..bded4ae2b44993 100644 --- a/src/mono/wasm/build/BrowserWasmApp.targets +++ b/src/mono/wasm/build/BrowserWasmApp.targets @@ -321,7 +321,7 @@ <_EmccLDFlags Include="$(WasmLinkOptimizationFlag)" /> <_EmccLDFlags Include="@(_EmccCommonFlags)" /> - <_EmccLDFlags Include="-s EXPORT_ES6=1" /> + <_EmccLDFlags Include="-s EXPORT_ES6=1 -lexports.js" /> <_EmccLDFlags Condition="'$(WasmEnableExceptionHandling)' != 'false'" Include="-s EXPORT_EXCEPTION_HANDLING_HELPERS=1" /> <_RuntimeCDependencies Include="$(_WasmPInvokeHPath);$(_WasmICallTablePath)" />