diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
index 243754c302297..e4a0f1aecbb0b 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
@@ -17,10 +17,11 @@ The .NET Foundation licenses this file to you under the MIT license.
true
clang
gcc
- $(CppCompilerAndLinker)
$(CppCompilerAndLinker)
ar
--flat
+ objcopy
+ llvm-objcopy
@@ -105,17 +106,16 @@ The .NET Foundation licenses this file to you under the MIT license.
-
+
-
+
$(CppCompilerAndLinkerAlternative)
- $(CppCompilerAndLinker)
$(CppCompilerAndLinker)
<_WhereLinker>0
@@ -126,11 +126,11 @@ The .NET Foundation licenses this file to you under the MIT license.
-
+
+ Text="Symbol stripping tool ('$(ObjCopyName)') not found in PATH. Make sure 'objcopy' is available in PATH" />
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets
index 39d3057494516..8229ecb0c5ae9 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets
@@ -14,7 +14,6 @@ The .NET Foundation licenses this file to you under the MIT license.
-->
- cl
link
lib
.lib
@@ -109,9 +108,8 @@ The .NET Foundation licenses this file to you under the MIT license.
<_CppToolsDirectory>$(_FindVCVarsallOutput.Split(`#`)[0])
- "$(_CppToolsDirectory)cl.exe"
- "$(_CppToolsDirectory)link.exe"
- "$(_CppToolsDirectory)lib.exe"
+ $(_CppToolsDirectory)link.exe
+ $(_CppToolsDirectory)lib.exe
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
index bb0e29145f419..1c99b64ea4296 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
@@ -336,23 +336,25 @@ The .NET Foundation licenses this file to you under the MIT license.
<_IgnoreLinkerWarnings Condition="'$(TargetOS)' == 'OSX'">true
-
-
+
+
-
+
-
+
+ "$(ObjCopyName)" --only-keep-debug "$(NativeBinary)" "$(NativeBinary)$(NativeSymbolExt)" &&
+ "$(ObjCopyName)" --strip-debug --strip-unneeded "$(NativeBinary)" &&
+ "$(ObjCopyName)" --add-gnu-debuglink="$(NativeBinary)$(NativeSymbolExt)" "$(NativeBinary)"" />
-
-
+
-
-
+
+