|
188 | 188 | <_EmccLinkRsp>$(_WasmIntermediateOutputPath)emcc-link.rsp</_EmccLinkRsp>
|
189 | 189 |
|
190 | 190 | <EmccInitialHeapSize Condition="'$(EmccInitialHeapSize)' == ''">$(EmccTotalMemory)</EmccInitialHeapSize>
|
191 |
| - <EmccInitialHeapSize Condition="'$(EmccInitialHeapSize)' == ''">536870912</EmccInitialHeapSize> |
192 | 191 | </PropertyGroup>
|
193 | 192 |
|
194 | 193 | <ItemGroup>
|
|
231 | 230 | <_EmccLDFlags Include="-s ASSERTIONS=$(_EmccAssertionLevelDefault)" Condition="'$(_WasmDevel)' == 'true'" />
|
232 | 231 | <_EmccLDFlags Include="@(_EmccCommonFlags)" />
|
233 | 232 | <_EmccLDSFlags Include="-Wl,--allow-undefined" />
|
234 |
| - <_EmccLDSFlags Include="-s INITIAL_MEMORY=$(EmccInitialHeapSize)" /> |
235 | 233 |
|
236 | 234 | <!-- ILLinker should have removed unused imports, so error for Publish -->
|
237 | 235 | <_EmccLDSFlags Include="-s ERROR_ON_UNDEFINED_SYMBOLS=0" Condition="'$(WasmBuildingForNestedPublish)' != 'true'" />
|
|
372 | 370 | </ItemGroup>
|
373 | 371 | </Target>
|
374 | 372 |
|
375 |
| - <Target Name="_WasmWriteRspFilesForLinking" DependsOnTargets="_CheckEmccIsExpectedVersion"> |
| 373 | + <Target Name="_WasmCalculateInitialHeapSize" |
| 374 | + Condition="'$(EmccInitialHeapSize)' == ''" |
| 375 | + DependsOnTargets="_CheckEmccIsExpectedVersion"> |
| 376 | + <ItemGroup> |
| 377 | + <_AOTObjectFile Include="%(_BitcodeFile.ObjectFile)" /> |
| 378 | + </ItemGroup> |
| 379 | + |
| 380 | + <!-- for AOT builds we use llvm-size tool to collect size of the DATA segment in each object file --> |
| 381 | + <Exec Command="llvm-size$(_ExeExt) -d --format=sysv @(_AOTObjectFile, ' ')" |
| 382 | + Condition="'$(_WasmShouldAOT)' == 'true'" |
| 383 | + IgnoreStandardErrorWarningFormat="true" |
| 384 | + ConsoleToMsBuild="true" |
| 385 | + StandardOutputImportance="low" StandardErrorImportance="low" |
| 386 | + EnvironmentVariables="@(EmscriptenEnvVars)" > |
| 387 | + <Output TaskParameter="ConsoleOutput" ItemName="LlvmAotSizeOutput" /> |
| 388 | + </Exec> |
| 389 | + <ItemGroup Condition="'$(_WasmShouldAOT)' == 'true'"> |
| 390 | + <_AOTDataSegmentSize Condition="$([System.String]::Copy('%(LlvmAotSizeOutput.Identity)').StartsWith('DATA '))" |
| 391 | + Include="$([System.String]::Copy('%(LlvmAotSizeOutput.Identity)').Replace("DATA ", "").Replace(" 0", "").Trim())" /> |
| 392 | + </ItemGroup> |
| 393 | + |
| 394 | + <WasmCalculateInitialHeapSize |
| 395 | + Assemblies="@(WasmAssembliesToBundle)" |
| 396 | + AOTDataSegmentSizes="@(_AOTDataSegmentSize)"> |
| 397 | + <Output TaskParameter="InitialHeapSize" PropertyName="_WasmCalculatedInitialHeapSize" /> |
| 398 | + </WasmCalculateInitialHeapSize> |
| 399 | + <PropertyGroup> |
| 400 | + <EmccInitialHeapSize Condition="'$(EmccInitialHeapSize)' == '' and '$(_WasmCalculatedInitialHeapSize)' != '' and $(_WasmCalculatedInitialHeapSize) > 16777216">$(_WasmCalculatedInitialHeapSize)</EmccInitialHeapSize> |
| 401 | + <EmccInitialHeapSize Condition="'$(EmccInitialHeapSize)' == ''">16777216</EmccInitialHeapSize> |
| 402 | + </PropertyGroup> |
| 403 | + </Target> |
| 404 | + |
| 405 | + <Target Name="_WasmWriteRspFilesForLinking" DependsOnTargets="_CheckEmccIsExpectedVersion;_WasmCalculateInitialHeapSize"> |
376 | 406 | <PropertyGroup>
|
377 | 407 | <_WasmEHLib Condition="'$(WasmEnableExceptionHandling)' == 'true'">libmono-wasm-eh-wasm.a</_WasmEHLib>
|
378 | 408 | <_WasmEHLib Condition="'$(WasmEnableExceptionHandling)' != 'true'">libmono-wasm-eh-js.a</_WasmEHLib>
|
|
383 | 413 | </PropertyGroup>
|
384 | 414 | <ItemGroup>
|
385 | 415 | <!-- order matters -->
|
| 416 | + <_EmccLDSFlags Include="-s INITIAL_MEMORY=$(EmccInitialHeapSize)" /> |
| 417 | + |
386 | 418 | <_WasmNativeFileForLinking Include="%(_BitcodeFile.ObjectFile)" />
|
387 | 419 | <_WasmNativeFileForLinking Include="%(_WasmSourceFileToCompile.ObjectFile)" />
|
388 | 420 |
|
|
0 commit comments