Skip to content

Commit

Permalink
NativeAOT: Reenable -dead_strip platform linker optimization by def…
Browse files Browse the repository at this point in the history
…ault (#20796)

### Description

NativeAOT now properly marks all symbols as non-deadstrippable in the object file it generates: dotnet/runtime@d9a6607
And uses `-dead_strip` as the default build option.

In this PR we are doing the same - reenabling the `-dead_strip` as the default platform linker switch.
This reverts previous workaround introduced in: f212f6b 

### Size savings

| MySingleView | Main | This PR | diff (%) |
|--------------|------|---------|----------|
| SOD (MB)     | 2,87 | 2,70    | -5,99%   |
|,ipa (MB)    | 1,22 | 1,17    | -4,61%   |

Even though this brings `4-5%` size reduction for a MySingleView app, the size savings are not proportional to the app size, as the savings are coming from stripping native libraries only. 
Based on measurements reported in dotnet/runtime@d9a6607 the actual expected savings for a MAUI app are around `~1.5%`.

---
Fixes #18605 and dotnet/runtime#88032

---------

Co-authored-by: Ivan Povazan <ivan.povazan@gmail.com>
  • Loading branch information
ivanpovazan and ivanpovazan authored Jul 3, 2024
1 parent 68897de commit 1ca69f3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions tools/dotnet-linker/Steps/ComputeNativeBuildFlagsStep.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;

using Xamarin.Utils;
using Xamarin.Bundler;

#nullable enable

Expand Down Expand Up @@ -52,8 +51,7 @@ protected override void TryEndProcess ()
Configuration.Application.DeadStrip = false;

var mainLinkerFlags = new List<MSBuildItem> ();
// Do not pass -dead_strip to the native linker with object files generated by NativeAOT compiler as it can cause the linker to seg fault
if (Configuration.Application.DeadStrip && Configuration.Application.XamarinRuntime != XamarinRuntime.NativeAOT) {
if (Configuration.Application.DeadStrip) {
mainLinkerFlags.Add (new MSBuildItem ("-dead_strip"));
}
Configuration.WriteOutputForMSBuild ("_AssemblyLinkerFlags", mainLinkerFlags);
Expand Down

6 comments on commit 1ca69f3

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

💻 [CI Build] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 1ca69f3ab58bc5d79651372dfbb1c1cbb66cb155 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

💻 [CI Build] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 1ca69f3ab58bc5d79651372dfbb1c1cbb66cb155 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ [CI Build] Windows Integration Tests failed ❌

❌ Failed ❌

Pipeline on Agent
Hash: 1ca69f3ab58bc5d79651372dfbb1c1cbb66cb155 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 1ca69f3ab58bc5d79651372dfbb1c1cbb66cb155 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ API diff for current PR / commit

Legacy Xamarin (No breaking changes)
  • iOS (no change detected)
  • tvOS (no change detected)
  • watchOS (no change detected)
  • macOS (no change detected)
NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

Legacy Xamarin (No breaking changes)
.NET (No breaking changes)
Legacy Xamarin (stable) vs .NET

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 1ca69f3ab58bc5d79651372dfbb1c1cbb66cb155 [CI build]

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.