diff --git a/Directory.Build.props b/Directory.Build.props
index dc11cc1b9f1308..6a688d500c4cc2 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -107,6 +107,8 @@
true
+
+ false
Properties
diff --git a/eng/build.sh b/eng/build.sh
index f271bb0ca76278..1179f8efd27a12 100755
--- a/eng/build.sh
+++ b/eng/build.sh
@@ -76,6 +76,7 @@ usage()
echo " --gcc Optional argument to build using gcc in PATH (default)."
echo " --gccx.y Optional argument to build using gcc version x.y."
echo " --portablebuild Optional argument: set to false to force a non-portable build."
+ echo " --keepnativesymbols Optional argument: set to true to keep native symbols/debuginfo in generated binaries."
echo ""
echo "Command line arguments starting with '/p:' are passed through to MSBuild."
@@ -402,6 +403,18 @@ while [[ $# > 0 ]]; do
shift 2
;;
+ -keepnativesymbols)
+ if [ -z ${2+x} ]; then
+ echo "No value for keepNativeSymbols is supplied. See help (--help) for supported values." 1>&2
+ exit 1
+ fi
+ passedKeepNativeSymbols="$(echo "$2" | awk '{print tolower($0)}')"
+ if [ "$passedKeepNativeSymbols" = true ]; then
+ arguments="$arguments /p:KeepNativeSymbols=true"
+ fi
+ shift 2
+ ;;
+
*)
extraargs="$extraargs $1"
shift 1
diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh
index 877ef003bbe1e3..2e94d68fe692f2 100755
--- a/eng/native/build-commons.sh
+++ b/eng/native/build-commons.sh
@@ -225,6 +225,7 @@ usage()
echo "-portablebuild: pass -portablebuild=false to force a non-portable build."
echo "-skipconfigure: skip build configuration."
echo "-skipgenerateversion: disable version generation even if MSBuild is supported."
+ echo "-keepnativesymbols: keep native/unmanaged debug symbols."
echo "-verbose: optional argument to enable verbose build output."
echo ""
echo "Additional Options:"
@@ -354,6 +355,10 @@ while :; do
__CompilerMinorVersion="${parts[1]}"
;;
+ keepnativesymbols|-keepnativesymbols)
+ __CMakeArgs="$__CMakeArgs -DCLR_CMAKE_KEEP_NATIVE_SYMBOLS=true"
+ ;;
+
msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
__msbuildonunsupportedplatform=1
;;
diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake
index 525c289d988101..27396aa5bb5ff0 100644
--- a/eng/native/functions.cmake
+++ b/eng/native/functions.cmake
@@ -336,8 +336,10 @@ function(strip_symbols targetName outputFilename)
endfunction()
function(install_with_stripped_symbols targetName kind destination)
- strip_symbols(${targetName} symbol_file)
- install_symbols(${symbol_file} ${destination})
+ if(NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS)
+ strip_symbols(${targetName} symbol_file)
+ install_symbols(${symbol_file} ${destination})
+ endif()
if ("${kind}" STREQUAL "TARGETS")
set(install_source ${targetName})
elseif("${kind}" STREQUAL "PROGRAMS")
@@ -374,13 +376,17 @@ function(install_clr)
foreach(targetName ${INSTALL_CLR_TARGETS})
list(FIND CLR_CROSS_COMPONENTS_LIST ${targetName} INDEX)
if (NOT DEFINED CLR_CROSS_COMPONENTS_LIST OR NOT ${INDEX} EQUAL -1)
- strip_symbols(${targetName} symbol_file)
+ if (NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS)
+ strip_symbols(${targetName} symbol_file)
+ endif()
foreach(destination ${destinations})
# We don't need to install the export libraries for our DLLs
# since they won't be directly linked against.
install(PROGRAMS $ DESTINATION ${destination})
- install_symbols(${symbol_file} ${destination})
+ if (NOT CLR_CMAKE_KEEP_NATIVE_SYMBOLS)
+ install_symbols(${symbol_file} ${destination})
+ endif()
if(CLR_CMAKE_PGO_INSTRUMENT)
if(WIN32)
diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj
index 79b99c1649eb05..0422ba17afdf6b 100644
--- a/src/coreclr/runtime.proj
+++ b/src/coreclr/runtime.proj
@@ -11,6 +11,7 @@
<_CoreClrBuildArg Condition="'$(ContinuousIntegrationBuild)' == 'true'" Include="-ci" />
<_CoreClrBuildArg Condition="'$(CrossBuild)' == 'true'" Include="-cross" />
<_CoreClrBuildArg Condition="'$(PortableBuild)' != 'true'" Include="-portablebuild=false" />
+ <_CoreClrBuildArg Condition="'$(KeepNativeSymbols)' != 'false'" Include="-keepnativesymbols" />
<_CoreClrBuildArg Condition="!$([MSBuild]::IsOsPlatform(Windows))" Include="-os $(TargetOS)" />
<_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and
diff --git a/src/installer/corehost/corehost.proj b/src/installer/corehost/corehost.proj
index 69927e8304b1d8..38c104ca005c9e 100644
--- a/src/installer/corehost/corehost.proj
+++ b/src/installer/corehost/corehost.proj
@@ -30,6 +30,7 @@
$(Configuration) $(TargetArchitecture) -apphostver "$(AppHostVersion)" -hostver "$(HostVersion)" -fxrver "$(HostResolverVersion)" -policyver "$(HostPolicyVersion)" -commithash "$(LatestCommit)" -os $(TargetOS)
$(BuildArgs) -cmakeargs "-DVERSION_FILE_PATH=$(NativeVersionFile)"
$(BuildArgs) -portablebuild=false
+ $(BuildArgs) -keepnativesymbols
$(BuildArgs) -cross
$(BuildArgs) $(Compiler)
$(BuildArgs) $(CMakeArgs)
diff --git a/src/libraries/Native/build-native.proj b/src/libraries/Native/build-native.proj
index beaf3098745007..6f3d4aa0892b47 100644
--- a/src/libraries/Native/build-native.proj
+++ b/src/libraries/Native/build-native.proj
@@ -24,6 +24,7 @@
<_ProcessorCountArg> -numproc $(MSBuildNodeCount)
<_PortableBuildArg Condition="'$(PortableBuild)' != 'true'"> -portablebuild=false
<_CrossBuildArg Condition="'$(CrossBuild)' == 'true'"> -cross
+ <_KeepNativeSymbolsBuildArg Condition="'$(KeepNativeSymbols)' != 'false'"> -keepnativesymbols
<_CMakeArgs Condition="'$(CMakeArgs)' != ''"> $(CMakeArgs)
<_BuildNativeCompilerArg Condition="'$(BuildNativeCompiler)' != ''"> $(BuildNativeCompiler)
- <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_CMakeArgs) $(Compiler)
+ <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs) $(Compiler)