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

Conversation

omajid
Copy link
Member

@omajid omajid commented Jul 13, 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 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:

@omajid
Copy link
Member Author

omajid commented Jul 13, 2020

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 omajid force-pushed the optional-dont-strip-debuginfo branch 2 times, most recently from 51f12b5 to e935340 Compare July 15, 2020 17:02
@omajid omajid force-pushed the optional-dont-strip-debuginfo branch from e935340 to 063a014 Compare July 17, 2020 19:19
@omajid
Copy link
Member Author

omajid commented Jul 21, 2020

Anyone willing to review this?

@dagood
Copy link
Member

dagood commented Jul 21, 2020

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

Copy link
Member

@dagood dagood left a comment

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.

eng/build.sh Outdated
@@ -74,6 +74,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 " --keepsymbols Optional argument: set to true to keep symbols/debuginfo in generated binaries."
Copy link
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
Member Author

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?

eng/build.sh Outdated Show resolved Hide resolved
@omajid omajid force-pushed the optional-dont-strip-debuginfo branch from 063a014 to 417e787 Compare July 21, 2020 19:05
Copy link
Member

@tmds tmds left a comment

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
Member Author

omajid commented Sep 21, 2020

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

Copy link
Member

@janvorli janvorli left a comment

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.

eng/build.sh Outdated
fi
passedKeepSymbols="$(echo "$2" | awk '{print tolower($0)}')"
if [ "$passedKeepSymbols" = true ]; then
cmakeargs="${cmakeargs} -cmakeargs -DCLR_KEEP_SYMBOLS=true"
Copy link
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
Member Author

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?

eng/build.sh Outdated
fi
passedKeepSymbols="$(echo "$2" | awk '{print tolower($0)}')"
if [ "$passedKeepSymbols" = true ]; then
cmakeargs="${cmakeargs} -cmakeargs -DCLR_KEEP_SYMBOLS=true"
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Done!

@omajid omajid force-pushed the optional-dont-strip-debuginfo branch from 417e787 to f23aca6 Compare September 25, 2020 20:55
Copy link
Member

@janvorli janvorli left a comment

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
Member Author

omajid commented Sep 25, 2020

@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
Member

Hmm, keepNativeSymbols sounds better to me.

@omajid omajid force-pushed the optional-dont-strip-debuginfo branch from f23aca6 to 2fcdb9d Compare September 28, 2020 15:28
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Sep 28, 2020
@omajid omajid closed this Sep 30, 2020
@omajid omajid 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 omajid force-pushed the optional-dont-strip-debuginfo branch from 2fcdb9d to 2ff2c5b Compare September 30, 2020 13:26
@omajid
Copy link
Member Author

omajid commented Sep 30, 2020

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
Member Author

omajid commented Sep 30, 2020

@janvorli Does this still look okay?

Copy link
Member

@janvorli janvorli left a comment

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
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:master Oct 1, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants