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

Why do we build compiler-rt/libcxx/libcxxabi with RelWithDebugInfo? #281

Open
TerrorJack opened this issue Jan 4, 2023 · 11 comments
Open

Comments

@TerrorJack
Copy link
Contributor

Why are we building them with RelWithDebugInfo instead of Release? Apart from lower optimization level, it causes dwarf sections to be linked into the final wasm with default linking flags, which IMHO is not desirable for most wasi-sdk users.

@sbc100
Copy link
Member

sbc100 commented Jan 4, 2023

I think if you don't want debug info in your binary you probably want to either link with -Wl,--strip or run strip (llvm-strip really) on the final binary.

The alternative is that we ship two copies of all the libraries, one with debug and one without, but that adds complexity we probably don't want.

@TerrorJack
Copy link
Contributor Author

It seems to me that consumers of debug flavored sysroot will tend to build their own sysroot anyway (with Debug, and other custom flags). So simply changing to Release seems to be the best thing to do here?

@sbc100
Copy link
Member

sbc100 commented Jan 4, 2023

I don't have a strong opinion. It does main that anyone who builds a debug binary won't be able to step into any system functions, but maybe that fine/normal/expected?

@TerrorJack
Copy link
Contributor Author

It does main that anyone who builds a debug binary won't be able to step into any system functions

Note that wasi-libc is already built sans debug info, and that's where most important system functions live.

@sbc100
Copy link
Member

sbc100 commented Jan 4, 2023

It does main that anyone who builds a debug binary won't be able to step into any system functions

Note that wasi-libc is already built sans debug info, and that's where most important system functions live.

I see, perhaps that should be built with debug info then? In emscripten we chose to build all libraries with debug info, and have the linker strip it when a release build is desired. It really depends how many wasi-sdk users will end up wanting to debug system library level stuff.

@TerrorJack
Copy link
Contributor Author

Yes, the strip-at-link-time approach is reasonable. It's just that when debug info is enabled (at least via cmake RelWithDebugInfo compared to Release), the optimization level is lower and that impacts code quality for users who don't debug the sysroot.

@sbc100
Copy link
Member

sbc100 commented Jan 4, 2023

Really? I thought that point of RelWithDebugInfo was that it was the same as Release in terms of opt level but with debug into? Maybe I'm wrong?

@TerrorJack
Copy link
Contributor Author

Really. See https://github.com/Kitware/CMake/blob/master/Modules/Compiler/GNU.cmake#L59, by default Release is -O3 -DNDEBUG, while RelWithDebInfo is -O2 -g -DNDEBUG. And this is another place where wasi-libc build flags is inconsistent with the rest of toolchain, currently wasi-libc is built with -O2 -DNDEBUG. We should at least make it consistent with rest of the sysroot.

@sbc100
Copy link
Member

sbc100 commented Jan 5, 2023

We should probably be consistent about shipping debug info or not for all libraries.

Being consistent about optimization levels isn't critical I think, but it should be done deliberately. There may be some part of libc/compiler-rt/libc++ that would be best built with -O2, -O3 or -Oz.

@TerrorJack
Copy link
Contributor Author

One thing I forgot to mention in the previous discussions: shipping sysroots with debug info doesn't really allow one to debug them, because the dwarf sections do not embed the source code (even with -g3), and only refer to source absolute paths. They are not present in the wasi-sdk tarball anyway.

@SamB
Copy link

SamB commented Mar 22, 2024

One thing I forgot to mention in the previous discussions: shipping sysroots with debug info doesn't really allow one to debug them, because the dwarf sections do not embed the source code (even with -g3), and only refer to source absolute paths. They are not present in the wasi-sdk tarball anyway.

Okay, so that is inconvenient, but when you're trying to make sense of a stack trace you don't absolutely need to see source files in your debugger.

(Note to self: figure out how debian could ship source suitable for debugging sometime...)

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

3 participants