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

How to handle (native) debug info? #267

Closed
omajid opened this issue Oct 30, 2017 · 11 comments
Closed

How to handle (native) debug info? #267

omajid opened this issue Oct 30, 2017 · 11 comments

Comments

@omajid
Copy link
Member

omajid commented Oct 30, 2017

In the context of packaging for various Linux distributions, the topic of (native) debuginfo comes up.

Here is what many linux distributions do:

  1. Build a package with full debuginfo (-g with gcc/clang, RelWithDebInfo for cmake)
  2. Run a separate tool to find all debuginfo, strip it and move it to a separate package (-debuginfo for Fedora/RHEL/CentOS, -dbgsym for Debian/Ubuntu).

Now if users want to just run .NET Core, they install dotnet. If they want to use the debug symbols, they need to install dotnet-debuginfo or dotnet-dbgsym (or the variant used by the distro).

Neither source-build nor the current official build accounts for this. These builds just strip out everything that leaves the package build process nothing to work with. For example, see https://github.com/dotnet/core-setup/issues/1607

I would like to "fix" this in source-build. Should I just remove the various invocations to strip debug info? Is there a need to make this conditional depending on the current platform? Or even build type?

@omajid
Copy link
Member Author

omajid commented Oct 30, 2017

Here is what an unconditional fix looks like for coreclr: https://gist.github.com/omajid/149e7df053fcaced9a717dee8a67f4f8

@dagood
Copy link
Member

dagood commented Oct 30, 2017

I'm surprised we're stripping symbols in source-build in the first place--packaging for distros is a big reason that flag exists rather than it being hard-coded one way or the other in the repo. Your patch LGTM.

@karajas, was that added intentionally in 4b935bc#diff-704fa01630c38f6175a0a426554e9825R5?

@karajas
Copy link
Member

karajas commented Oct 30, 2017

I believe at the time, we weren't sure how to handle core-setup symbols. If this is something that the official builds do, I think we should duplicate the same behavior.

@dagood
Copy link
Member

dagood commented Oct 30, 2017

Official builds are targeting Microsoft-style symbol servers, which is an area that source-build and the official build need to differ in the short term, IMO.

The work to have the official builds strip symbols after the builds are all done seems large to me--similar to the work to move signing to a post-step.

@omajid
Copy link
Member Author

omajid commented Oct 30, 2017

We could also introduce another RepoAPI parameter to control whether or not to strip binaries at build time. I dont know which is easier.

@dagood
Copy link
Member

dagood commented Oct 30, 2017

Yeah, all we need is to decide on name (should clarify it by adding native somewhere), make both repos use it, and then we're got a Repo API. 😄

However, I think as far as source-build's concerned, it will never be used. Worth standardizing if we plan on using it for a long time for Microsoft product builds, but otherwise (e.g. if we move stripping to the end) maybe not.

@omajid
Copy link
Member Author

omajid commented Oct 31, 2017

Okay, then I will keep things unconditional for now.

Btw, I looked into all native objects built as part of source-build and only corefx needs additional fixes. Basically a port of dotnet/coreclr#3445 from coreclr to corefx.

@dleeapho
Copy link
Contributor

/cc @mikeharder in case asp.net core needs similar changes.

@mikeharder
Copy link

/cc @natemcmaster

@natemcmaster
Copy link

At the moment, the only native library aspnetcore builds is libuv. See https://github.com/aspnet/libuv-build. cc @moozzyk

@moozzyk
Copy link

moozzyk commented Nov 1, 2017

The libuv build includes full debugging info for Linux builds. The size of the output is ~460 KB.

jkotas pushed a commit to dotnet/corefx that referenced this issue Nov 1, 2017
The windows build already includes /Zi /Zl as part of commit 920fd2f
(PR #7840). It looks like it was simply missed on Unix.

This change also makes the native debug information closer to what
CoreCLR does on all platforms. See
dotnet/coreclr#3445 for more information.

This is also needed for the end-to-end debuginfo generation as part of
source-build. See dotnet/source-build#267
omajid added a commit to omajid/dotnet-runtime that referenced this issue 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
jkotas pushed a commit to dotnet/runtime that referenced this issue Oct 1, 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 #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
picenka21 pushed a commit to picenka21/runtime that referenced this issue Feb 18, 2022
)

The windows build already includes /Zi /Zl as part of commit 920fd2f
(PR dotnet/corefx#7840). It looks like it was simply missed on Unix.

This change also makes the native debug information closer to what
CoreCLR does on all platforms. See
dotnet/coreclr#3445 for more information.

This is also needed for the end-to-end debuginfo generation as part of
source-build. See dotnet/source-build#267

Commit migrated from dotnet/corefx@efe7652
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants