From 7f08572f716b6c9ed687f93d6f6c0179e69be54d Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Thu, 30 Jun 2022 19:43:44 +0300 Subject: [PATCH 1/6] Use llvm-objcopy with StripSymbols=true and clang --- .../BuildIntegration/Microsoft.NETCore.Native.Unix.targets | 6 ++++-- .../BuildIntegration/Microsoft.NETCore.Native.targets | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 243754c302297b..52331ba70c77cc 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -21,6 +21,8 @@ The .NET Foundation licenses this file to you under the MIT license. $(CppCompilerAndLinker) ar --flat + objcopy + llvm-objcopy @@ -126,11 +128,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.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index bb0e29145f4193..2e90fde67740ec 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -347,9 +347,9 @@ The .NET Foundation licenses this file to you under the MIT license. + $(ObjCopyName) --only-keep-debug "$(NativeBinary)" "$(NativeBinary)$(NativeSymbolExt)" && + $(ObjCopyName) --strip-debug --strip-unneeded "$(NativeBinary)" && + $(ObjCopyName) --add-gnu-debuglink="$(NativeBinary)$(NativeSymbolExt)" "$(NativeBinary)"" /> From 2ebcc5e7f6e2e1a782aa8e387db267d36727996e Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Thu, 30 Jun 2022 20:31:41 +0300 Subject: [PATCH 2/6] Allow user to override ObjCopyName property --- .../BuildIntegration/Microsoft.NETCore.Native.Unix.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 52331ba70c77cc..99280310cbe4ee 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -21,8 +21,8 @@ The .NET Foundation licenses this file to you under the MIT license. $(CppCompilerAndLinker) ar --flat - objcopy - llvm-objcopy + objcopy + llvm-objcopy From fe3232f03511056a2a2948564f4f07db95a7e572 Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:04:31 +0300 Subject: [PATCH 3/6] Quote utilities in Exec calls --- .../Microsoft.NETCore.Native.Unix.targets | 6 ++--- .../Microsoft.NETCore.Native.targets | 24 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 99280310cbe4ee..f7ba4f221b59bc 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -107,11 +107,11 @@ The .NET Foundation licenses this file to you under the MIT license. - + - + @@ -128,7 +128,7 @@ The .NET Foundation licenses this file to you under the MIT license. - + true - - + + - + - + + "$(ObjCopyName)" --only-keep-debug "$(NativeBinary)" "$(NativeBinary)$(NativeSymbolExt)" && + "$(ObjCopyName)" --strip-debug --strip-unneeded "$(NativeBinary)" && + "$(ObjCopyName)" --add-gnu-debuglink="$(NativeBinary)$(NativeSymbolExt)" "$(NativeBinary)"" /> - - + - - + + From 5c24d8e56e19d4da9c3ea595786ad4d0f7c7de37 Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Thu, 30 Jun 2022 22:02:50 +0300 Subject: [PATCH 4/6] Remove extra quotes from Windows targets --- .../BuildIntegration/Microsoft.NETCore.Native.Windows.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets index 39d30574945162..9162d44f78b528 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets @@ -110,7 +110,7 @@ The .NET Foundation licenses this file to you under the MIT license. <_CppToolsDirectory>$(_FindVCVarsallOutput.Split(`#`)[0]) "$(_CppToolsDirectory)cl.exe" - "$(_CppToolsDirectory)link.exe" + $(_CppToolsDirectory)link.exe "$(_CppToolsDirectory)lib.exe" From f2b5a91fbfaf12c32e7ad7c79b193625ffdf17dc Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Thu, 30 Jun 2022 22:50:14 +0300 Subject: [PATCH 5/6] Address CR feedback --- .../BuildIntegration/Microsoft.NETCore.Native.Windows.targets | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets index 9162d44f78b528..8229ecb0c5ae9c 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)lib.exe From d718c5a0a2b6df5279e6ad5a572e21494249bde4 Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Thu, 30 Jun 2022 23:10:13 +0300 Subject: [PATCH 6/6] Delete CppCompiler property --- .../BuildIntegration/Microsoft.NETCore.Native.Unix.targets | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index f7ba4f221b59bc..e4a0f1aecbb0bd 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -17,7 +17,6 @@ The .NET Foundation licenses this file to you under the MIT license. true clang gcc - $(CppCompilerAndLinker) $(CppCompilerAndLinker) ar --flat @@ -117,7 +116,6 @@ The .NET Foundation licenses this file to you under the MIT license. $(CppCompilerAndLinkerAlternative) - $(CppCompilerAndLinker) $(CppCompilerAndLinker) <_WhereLinker>0