Closed vaind closed 10 months ago
Hi, @vaind!
The full PDB is a product of the linker. The linker is not involved when building a static library, so no full PDB is generated. The PDB you're seeing is the last of the compiler's partial PDBs for each translation unit (= object file).
We can use the /Z7
flag for static libraries to embed the debug information in the lib
, but I am unsure if sentry-cli
supports that format. Of course, if you link your static library with an executable or shared library, the generated PDB for that build artifact will contain all the debug information, and you should be able to upload it.
What is the scenario? There may be a better way to package the artifact.
if you link your static library with an executable or shared library, the generated PDB for that build artifact will contain all the debug information, and you should be able to upload it.
Would that be the case when we use the /z7
flag or already with how the static lib is built now?
What is the scenario? There may be a better way to package the artifact.
This is for .net SDK native AOT support
if you link your static library with an executable or shared library, the generated PDB for that build artifact will contain all the debug information, and you should be able to upload it.
Would that be the case when we use the
/z7
flag or already with how the static lib is built now?
If you need to distribute the static library, then we'd need to use /Z7
. If you build the follow-up artifact on the same machine then the way it is built now should be enough.
This is for .net SDK native AOT support
Okay, but which requirements of this use case lead you to build it in this specific way (why static vs dynamic, why static runtime, etc.)?
If you need to distribute the static library, then we'd need to use /Z7.
Yes, the library is zipped up to a .nuget package and then used by users. I guess it should be possible to add this flag when calling cmake
to configure the project, right? Probably no need to change this in sentry-native (and wait for a release). Unless it's useful for others in the future.
Okay, but which requirements of this use case lead you to build it in this specific way (why static vs dynamic, why static runtime, etc.)?
With .NET Native AOT (which is a new thing), the final app that integrates Sentry is compiled as a single standalone native executable (for example for server-side symbolication, I got to use native debug images, not what we originally got from .NET). The idea is that providing a static library, it gets compiled into the final executable - this actually all works fine, I'm just figuring out what to do with the generated PDB and was scratching my head for a bit why it didn't get picked up by sentry-cli during upload (you know it's a new code on the .net side so at first I thought I was doing something wrong...).
Yes, the library is zipped up to a .nuget package and then used by users. I guess it should be possible to add this flag when calling
cmake
to configure the project, right? Probably no need to change this in sentry-native (and wait for a release). Unless it's useful for others in the future.
I have no problem adding a CMake variable/option to let users choose the debug format. If you want to validate this first, you can do so by modifying the initial C/C++ flags for RelWithDebInfo
by supplying a preload-script to populate the CMake cache before project()
loads the toolchain-specific flags:
relwithdebinfo_init_flags.cmake
(or something; the actual name/path is insignificant). This is your initial cache file./Z7
instead of /Zi
):
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Z7 /O2 /Ob1 /DNDEBUG" CACHE STRING "C Flags for RelWithDebInfo" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Z7 /O2 /Ob1 /DNDEBUG" CACHE STRING "CXX Flags for RelWithDebInfo" FORCE)
cmake -B build -S . ^
-D SENTRY_SDK_NAME=sentry.native.dotnet ^
-D SENTRY_BUILD_SHARED_LIBS=0 ^
-D SENTRY_BUILD_RUNTIMESTATIC=1 ^
-D SENTRY_BACKEND=none ^
-D SENTRY_TRANSPORT=none ^
-C .\relwithdebinfo_init_flags.cmake
--verbose
, you will see /Z7
used during compilation). The output will no longer contain a PDB, and the resulting static library will grow accordingly.With .NET Native AOT (which is a new thing), the final app that integrates Sentry is compiled as a single standalone native executable (for example for server-side symbolication, I got to use native debug images, not what we originally got from .NET). The idea is that providing a static library, it gets compiled into the final executable - this actually all works fine, I'm just figuring out what to do with the generated PDB and was scratching my head for a bit why it didn't get picked up by sentry-cli during upload (you know it's a new code on the .net side so at first I thought I was doing something wrong...).
Okay, thanks for the insight. Sounds like a static library makes the most sense as a first step.
Thanks @supervacuus I'll give it a try in the dotnet repo first
Building as suggested did change what's created although I can't really tell whether there are debug symbols in the static lib or not. https://github.com/getsentry/sentry-dotnet/pull/2765
I can't really tell whether there are debug symbols in the static lib or not. getsentry/sentry-dotnet#2765
Yes, you will only be able to verify this when building an AOT
target, and it produces a PDB
. The upside of creating a DLL
instead of static library - even for the AOT use-case - would be to have a PDB
before that build (which is also relevant when you want to provide the debug-info for all users once instead of letting them do the upload as part of their project).
Description
When I build a static library, a PDB file is produced but this PDB file doesn't get picked up by sentry-cli during symbol upload. Although this may be a CLI issue, it feels more like a build setting issue. Maybe related to this: https://stackoverflow.com/questions/7575298/static-library-debug-symbols
When does the problem happen
Environment
Steps To Reproduce
Log output