Skip to content

Add an option to keep native debug symbols - #39203

Merged
jkotas merged 1 commit into
dotnet:masterfrom
omajid:optional-dont-strip-debuginfo
Oct 1, 2020
Merged

Add an option to keep native debug symbols#39203
jkotas merged 1 commit into
dotnet:masterfrom
omajid:optional-dont-strip-debuginfo

Conversation

@omajid

Copy link
Copy Markdown
Member

When packaging .NET for Linux distributions, the package builders generally use a different workflow for shipping symbols to users:

  1. The package maintainer builds code with the debug flags (such as -g) to generate full native debug info and symbols.

  2. Nothing is stripped from build by the package maintainer.

  3. The build system (rpmbuild, debuild) removes the debug info (or debug symbols) from the code and creates separate -debuginfo or -debug packages that contain just the debug symbols.

  4. These debug packages are then distributed along with the normal packages using the normal Linux distribution mechanisms. This letsusers install the exact set of debug symbols matching their other package.

To support this workflow in dotnet/runtime, we need to add optional support for not stripping debug symbols. I used it has follows:

CFLAGS=-g CXXFLAGS=-g ./build.sh --keepsymbols true

After this build, the built binaries include all debug symbols.

I can then rely on the distro package build system to identify, strip, package and ship the debug info/symbols separately.

See #3781 and dotnet/source-build#267 for more details on the background and motivation.

For some related fixes, see:

@Dotnet-GitSync-BotDotnet-GitSync-Bot added the area-Infrastructure-coreclr Only use for closed issues label Jul 13, 2020
@omajid

Copy link
Copy Markdown
MemberAuthor

This is a bit of a regression from the equivalent support in dotnet/coreclr and dotnet/corefx

CC'ing some folks who were part of the conversation last time around: @dagood@dleeapho@eerhardt@jkotas@tmds@weshaggard

@omajid
omajidforce-pushed the optional-dont-strip-debuginfo branch 2 times, most recently from 51f12b5 to e935340CompareJuly 15, 2020 17:02
@omajid
omajidforce-pushed the optional-dont-strip-debuginfo branch from e935340 to 063a014CompareJuly 17, 2020 19:19
@omajid

Copy link
Copy Markdown
MemberAuthor

Anyone willing to review this?

@dagood

Copy link
Copy Markdown
Member

@jkoritzinsky maybe you'd like to review this change--cmake conditions and new build script arg.

@dagooddagood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems very reasonable. One suggestion and one comment about the context--I'm not particularly familiar with this area.

Comment threadeng/build.sh Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help message doesn't mention it takes an argument, but it seems to take true/false and reject nothingness. 😕 But it looks like this is also the case with other settings, so this PR appears to be consistent to me.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I take a stab at fixing up the other settings too?

Comment threadeng/build.sh Outdated
@omajid
omajidforce-pushed the optional-dont-strip-debuginfo branch from 063a014 to 417e787CompareJuly 21, 2020 19:05

@tmdstmds left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@omajid

Copy link
Copy Markdown
MemberAuthor

@janvorli hey, can you help me find some reviewers for this PR? Thanks in advance!

@janvorlijanvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to ask you to change few things.

Comment threadeng/build.sh Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer creating a msbuild property for this instead of passing it in the cmakeargs. We do that e.g. for the -portablebuild option, so I'd like to use unified way for all of them. You would then add this option to eng/build-commons.sh, which is used to parse the common options for coreclr, libraries and installer .sh scripts and add the cmake arg there. You'll need to update src/coreclr/runtime.proj, src/installer/corehost/corehost.proj and src/libraries/Native/build-native.proj to convert the msbuild property to the -keepsymbols option passed to the respective .sh scripts.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the updated patch match what you had in mind?

Comment threadeng/build.sh Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit - based on various cmake args settings in coreclr, I'd prefer this to be named CLR_CMAKE_KEEP_SYMBOLS to keep things unified.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@omajid
omajidforce-pushed the optional-dont-strip-debuginfo branch from 417e787 to f23aca6CompareSeptember 25, 2020 20:55

@janvorlijanvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@omajid

Copy link
Copy Markdown
MemberAuthor

@janvorli Does the "keepSymbols" name appear clear enough to you? Should I look at disambiguating it to "keepNativeSymbols" or "keepUnmanagedSymbols" or something similar?

@janvorli

Copy link
Copy Markdown
Member

Hmm, keepNativeSymbols sounds better to me.

@omajid
omajidforce-pushed the optional-dont-strip-debuginfo branch from f23aca6 to 2fcdb9dCompareSeptember 28, 2020 15:28
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Sep 28, 2020
@omajidomajid closed this Sep 30, 2020
@omajidomajid reopened this Sep 30, 2020
When packaging .NET for Linux distributions, the package builders
generally use a different workflow for shipping symbols to users:
1. The package maintainer builds code with the debug flags (such as
`-g`) to generate full native debug info and symbols.
2. Nothing is stripped from build by the package maintainer.
3. The build system (`rpmbuild`, `debuild`) removes the debug
info (or debug symbols) from the code and creates separate
`-debuginfo` or `-debug` packages that contain just the debug
symbols.
4. These debug packages are then distributed along with the normal
packages using the normal Linux distribution mechanisms. This lets
users install the exact set of debug symbols matching their other
package.
To support this workflow in dotnet/runtime, we need to add optional
support for not stripping debug symbols. I used it has follows:
CFLAGS=-g CXXFLAGS=-g ./build.sh --keepnativesymbols true
After this build, the built binaries include all debug symbols.
I can then rely on the distro package build system to identify, strip,
package and ship the debug info/symbols separately.
See dotnet#3781 and
dotnet/source-build#267 for more details on
the background and motivation.
For some related fixes, see:
- dotnet/coreclr#3445
- dotnet/corefx#24979
@omajid
omajidforce-pushed the optional-dont-strip-debuginfo branch from 2fcdb9d to 2ff2c5bCompareSeptember 30, 2020 13:26
@omajid

Copy link
Copy Markdown
MemberAuthor

The CI failures look unrelated to my changes (json tests and mono build issues) but I have rebased this branch onto master to see if that fixes the CI failures.

@omajid

Copy link
Copy Markdown
MemberAuthor

@janvorli Does this still look okay?

@janvorlijanvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the latest updates.

@janvorli

Copy link
Copy Markdown
Member

I'll still re-run the runtime tests to see the runtime (Installer Build and Test coreclr Linux_arm Debug) not to timeout.

@jkotas
jkotas merged commit 2f1694e into dotnet:masterOct 1, 2020
@ghostghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Infrastructure-coreclrOnly use for closed issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@omajid@dagood@janvorli@tmds@jkotas@Dotnet-GitSync-Bot