Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to keep native debug symbols #39203

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
<PropertyGroup>
<!-- Default to portable build if not explicitly set -->
<PortableBuild Condition="'$(PortableBuild)' == ''">true</PortableBuild>
<!-- Default to discarding symbols if not explicitly set -->
<KeepNativeSymbols Condition="'$(KeepNativeSymbols)' == ''">false</KeepNativeSymbols>
<!-- Used for launchSettings.json and runtime config files. -->
<AppDesignerFolder>Properties</AppDesignerFolder>
<!-- Determine what architecture we are building on. -->
Expand Down
13 changes: 13 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down Expand Up @@ -354,6 +355,10 @@ while :; do
__CompilerMinorVersion="${parts[1]}"
;;

keepnativesymbols|-keepnativesymbols)
__CMakeArgs="$__CMakeArgs -DCLR_CMAKE_KEEP_NATIVE_SYMBOLS=true"
;;

msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
__msbuildonunsupportedplatform=1
;;
Expand Down
14 changes: 10 additions & 4 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 $<TARGET_FILE:${targetName}> 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)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/installer/corehost/corehost.proj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<BuildArgs>$(Configuration) $(TargetArchitecture) -apphostver "$(AppHostVersion)" -hostver "$(HostVersion)" -fxrver "$(HostResolverVersion)" -policyver "$(HostPolicyVersion)" -commithash "$(LatestCommit)" -os $(TargetOS)</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DVERSION_FILE_PATH=$(NativeVersionFile)"</BuildArgs>
<BuildArgs Condition="'$(PortableBuild)' != 'true'">$(BuildArgs) -portablebuild=false</BuildArgs>
<BuildArgs Condition="'$(KeepNativeSymbols)' != 'false'">$(BuildArgs) -keepnativesymbols</BuildArgs>
<BuildArgs Condition="'$(CrossBuild)' == 'true'">$(BuildArgs) -cross</BuildArgs>
<BuildArgs Condition="'$(Compiler)' != ''">$(BuildArgs) $(Compiler)</BuildArgs>
<BuildArgs Condition="'$(CMakeArgs)' != ''">$(BuildArgs) $(CMakeArgs)</BuildArgs>
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/Native/build-native.proj
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
<_ProcessorCountArg> -numproc $(MSBuildNodeCount)</_ProcessorCountArg>
<_PortableBuildArg Condition="'$(PortableBuild)' != 'true'"> -portablebuild=false</_PortableBuildArg>
<_CrossBuildArg Condition="'$(CrossBuild)' == 'true'"> -cross</_CrossBuildArg>
<_KeepNativeSymbolsBuildArg Condition="'$(KeepNativeSymbols)' != 'false'"> -keepnativesymbols</_KeepNativeSymbolsBuildArg>
<_CMakeArgs Condition="'$(CMakeArgs)' != ''"> $(CMakeArgs)</_CMakeArgs>

<!--
BuildNativeCompiler is a pass-through argument, to pass an argument to build-native.sh. It is intended to be
used to force a specific compiler toolset.
-->
<_BuildNativeCompilerArg Condition="'$(BuildNativeCompiler)' != ''"> $(BuildNativeCompiler)</_BuildNativeCompilerArg>
<_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_CMakeArgs) $(Compiler)</_BuildNativeUnixArgs>
<_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs) $(Compiler)</_BuildNativeUnixArgs>
</PropertyGroup>

<Message Text="$(MSBuildThisFileDirectory)build-native.sh $(_BuildNativeUnixArgs)" Importance="High"/>
Expand Down