diff --git a/tools/dotnet-linker/Steps/ComputeNativeBuildFlagsStep.cs b/tools/dotnet-linker/Steps/ComputeNativeBuildFlagsStep.cs index 923218285f21..54c67098cd7d 100644 --- a/tools/dotnet-linker/Steps/ComputeNativeBuildFlagsStep.cs +++ b/tools/dotnet-linker/Steps/ComputeNativeBuildFlagsStep.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Xamarin.Utils; +using Xamarin.Bundler; #nullable enable @@ -51,7 +52,8 @@ protected override void TryEndProcess () Configuration.Application.DeadStrip = false; var mainLinkerFlags = new List (); - if (Configuration.Application.DeadStrip) { + // 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) { mainLinkerFlags.Add (new MSBuildItem ("-dead_strip")); } Configuration.WriteOutputForMSBuild ("_AssemblyLinkerFlags", mainLinkerFlags);