Skip to content

[Export] Linux, Windows: Support exporting with debug symbols - #114924

Open
AThousandShips wants to merge 1 commit into
godotengine:masterfrom
AThousandShips:export_debug_symbols
Open

AThousandShips wants to merge 1 commit into
godotengine:masterfrom
AThousandShips:export_debug_symbols

Conversation

@AThousandShips

@AThousandShips AThousandShips commented Jan 13, 2026

Copy link
Copy Markdown
Member

Copies debug symbols (.debugsymbols) from the template path, similar to the console wrapper for Windows.

Not sure how applicable this is for macOS, I can see .dSYM being created based on the build scripts but I don't have a macOS setup to check or a build environment. If a similar setup is possible for macOS I can expand it.

Ran into this as I was setting up builds with separate symbols and realized there was no simple way to bundle these without manually copying and changing the name, so implemented this for my own use.

This will also help with:

Comment thread editor/export/editor_export_platform_pc.cpp Outdated
@@ -26,6 +26,9 @@
<member name="debug/export_console_wrapper" type="int" setter="" getter="">
If [code]true[/code], a console wrapper is exported alongside the main executable, which allows running the project with enabled console output.
</member>
<member name="debug/export_debug_symbols" type="int" setter="" getter="">
If [code]true[/code], a debug symbol file ([code].debugsymbols[/code]) is exported alongside the main executable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Might want to add a note to this (and the console wrapper one for Windows) about where it is from and how to make it, but not sure

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.

It probably should be mentioned in the https://docs.godotengine.org/en/latest/engine_details/development/compiling/index.html, since other export template relates stuff is there.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed, will make a PR for that when this has progressed further, there's a section there about debug symbols and separate ones

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.

If absolutely needed, you could then... [url] tag to this specific section in the docs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ultimately most of the details are here, and will add some general details in the manual, but don't think a link here is necessary as most users won't be compiling their own builds and if they do they should know where to look

@akien-mga
akien-mga self-requested a review January 13, 2026 15:59
@bruvzg

bruvzg commented Jan 13, 2026

Copy link
Copy Markdown
Member

Not sure how applicable this is for macOS, I can see .dSYM being created based on the build scripts but I don't have a macOS setup to check or a build environment. If a similar setup is possible for macOS I can expand it.

It is the same, only difference is that .dSYN is a folder not file (link most macOS stuff). And likely will require renaming some internal files (and editing .plist) to match the export name.

@AThousandShips

Copy link
Copy Markdown
Member Author

Then I might leave that to a follow-up so someone with macOS can test and develop it specifically

@AThousandShips
AThousandShips force-pushed the export_debug_symbols branch 2 times, most recently from 07c6b43 to b0ac291 Compare January 14, 2026 10:06
@Repiteo
Repiteo requested a review from a team as a code owner February 17, 2026 20:09
@AThousandShips
AThousandShips force-pushed the export_debug_symbols branch from c167d93 to 9c12f3f Compare May 14, 2026 14:08
@AThousandShips
AThousandShips force-pushed the export_debug_symbols branch 2 times, most recently from 59e4f6c to 6337c44 Compare June 19, 2026 17:49
Comment on lines +204 to +218
if (err == OK && copy_debug_symbols) {
const String debug_symbols_path = template_path + ".debugsymbols";
if (FileAccess::exists(debug_symbols_path)) {
err = da->copy(debug_symbols_path, p_path + ".debugsymbols");
}
if (err == OK && copy_wrapper) {
for (int i = 0; wrapper_extensions[i]; ++i) {
const String wrapper_path = template_path.get_basename() + wrapper_extensions[i] + ".debugsymbols";
if (FileAccess::exists(wrapper_path)) {
err = da->copy(wrapper_path, p_path.get_basename() + ".console.exe.debugsymbols");
break;
}
}
}
}

@Calinou Calinou Jul 20, 2026

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.

Windows export templates compiled with MSVC use a .pdb extension, so I would also check for that (after .debugsymbols).

This is not needed for official export templates as they use MinGW, but it can be needed for custom export templates.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is that fetched automatically like the .debugsymbols file? Is it an alternative to the debug symbols or a replacement?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We have this rename check for the .debugsymbols file to ensure renames work, not sure if that works out of the box with the .pdb file, I haven't built with msvc lately so can't test currently but can set up and test

if (FileAccess::exists(exec_path + ".debugsymbols")) {
exec_path = exec_path + ".debugsymbols";
}

Would this need a different check for that case?

@Calinou Calinou Jul 20, 2026

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.

Is it an alternative to the debug symbols or a replacement?

It's an alternative; you can't have both .debugsymbols and .pdb for a single build.

Note that MSVC debug symbols are always separate as .pdb, while MinGW debug symbols can be embedded into the .exe.

Would this need a different check for that case?

Yes, as this check is only intended to find separate MinGW debug symbols.

There is another issue we'll probably need to tackle with MSVC debug symbols: the executable finds the PDB location with a path defined in the .exe, which is written as absolute in Godot. This means that if you export the project to any location that isn't the same path as the location the project was built, the debug symbols won't be recognized automatically.

@bruvzg Any ideas?

@AThousandShips AThousandShips Jul 20, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Then I think we can leave that as a follow-up including code to integrate that into the system (official builds are made with gcc so will only be relevant for custom builds with msvc)

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.

Official templates are not using MSVC, so I think it's OK to skip it for now.

I think path can be set to relative using /PDBALTPATH:, but it still will need change when exporting.
See WindowsUtils::copy_and_rename_pdb which is doing the PDB renaming for GDExtension dlls, something similar probably can be done for the export.

Comment thread platform/linuxbsd/doc_classes/EditorExportPlatformLinuxBSD.xml
Comment thread platform/windows/doc_classes/EditorExportPlatformWindows.xml Outdated
@AThousandShips
AThousandShips force-pushed the export_debug_symbols branch 3 times, most recently from db34f75 to 49451e7 Compare July 20, 2026 19:13

@Calinou Calinou 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.

Tested locally with custom export templates, it works as expected. Code looks good to me.

However, this will not work with official export templates until we start distributing those .debugsymbols files for Windows and Linux binaries. If we merge this, we should make sure we start doing so in the same minor release the PR is merged in, so that the feature can work out of the box. This will significantly increase the size of Windows/Linux export template downloads, but now that platforms can be selected individually, it should be acceptable.

In a future PR, when we make debug symbols available for the editor, we could add a button somewhere in the editor to download debug symbols for it (and place them next to the editor binary). This will greatly help in troubleshooting crashes in bug reports, and should hopefully make https://github.com/Calinou/godot-debug-builds no longer needed 🙂

@AThousandShips

Copy link
Copy Markdown
Member Author

I think Akien has been working on making symbols available for official builds but haven't kept up with the details

@AThousandShips

Copy link
Copy Markdown
Member Author

Integrated these changes and some fixes and works with custom templates (manually selected) will test with templates placed in the official folder as well and push the changes soon

@AThousandShips

AThousandShips commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

There! Validated the improvements and it all works well now!

Will do a pass over the documentation to add the details about zip when we've settled on the solution and do some cleaning of the code in some places but otherwise it works correctly!

Haven't tested with gdb directly yet but the dwarf link works correctly with this PR so it should work as long as it already works in master

Comment thread editor/export/editor_export_platform_pc.cpp Outdated
@akien-mga

Copy link
Copy Markdown
Member

Awesome! So how should I name the .debugsymbols files for official distribution?

@AThousandShips

AThousandShips commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

So for the new naming should simply be the same as the executable plus .debugsymbols and be compressed to a .zip with the same name plus .zip, so for example linux_release.x86_64, linux_release.x86_64.debugsymbols, and linux_release.x86_64.debugsymbols.zip, one zip per debugsymbols, so separate for windows_release_x86_64_console.exe, windows_release_x86_64_console.exe.debugsymbols, windows_release_x86_64_console.exe.debugsymbols.zip

One thing to consider for the official templates with debug symbols for the editor is that currently we link it to a file based on the export name, which should be godot.linuxbsd.editor.{arch}, so it will link to ``godot.linuxbsd.editor.{arch}.debugsymbols, which then gets broken when we rename them to godot_linux.{arch}`

This won't really matter for export templates as we fix them with this PR, but the editor might not work correctly if we distribute debug symbols with it, so we'd need to fix those files similarly to this script

Will add notes in the manual side on this for what is required for the crash handler and gdb respectively for different scenarios when we've settled on this PR, but in short:

The crash handler and gdb will work if a .debugsymbols file exists in the same directory as the executable and either:

  • The debug symbols match the name it was exported with with this setting on, plus .debugsymbols
  • The debug symbols match the executable name when built if exported without this option, i.e. manually copied (this won't work with official templates if the debugsymbols are renamed, unless also fixed)

The crash handler additionally works if the debug symbols match the executable plus just .debugsymbols, i.e. if both are renamed together

(Will go for lunch and will check in after)

For ease of access, for linux:

  • linux_{target}.{arch}
  • linux_{target}.{arch}.debugsymbols.zip
    • linux_{target}.{arch}.debugsymbols

And Windows:

  • windows_{target}_{arch}.exe
  • windows_{target}_{arch}.exe.debugsymbols.zip
    • windows_{target}_{arch}.exe.debugsymbols
  • windows_{target}_{arch}_console.exe
  • windows_{target}_{arch}_console.exe.debugsymbols.zip
    • windows_{target}_{arch}_console.exe.debugsymbols

}
}
}
if (err == OK && copy_debug_symbols) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This section along with the wrapper is getting a bit cluttered but I think it'd be something to clean up in a follow-up PR, properly moving the console wrapper code into the windows platform code to make it easier to maintain

return OK;
}

bool EditorExportPlatformPC::_copy_debugsymbols(Ref<DirAccess> &p_da, const String &p_path, const String &p_symbols_path, Error &r_err) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This could be made into a virtual method but as there's no difference currently I've left it a local method, as it got a bit cluttered with the different options, some of these paths should probably be collapsed and cleaned up

@AThousandShips

AThousandShips commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

An additional step for the build process in the build server to ensure the debug symbols will work when copied directly is to do:

strip --remove-section=".gnu_debuglink" linux_${TARGET}.${ARCH}
objcopy --add-gnu-debuglink=linux_${TARGET}.${ARCH}.debugsymbols linux_${TARGET}.${ARCH}

As part of the export rename process, as well as for the editor with the same appropriate name, as well as for Windows

This requires the build tools for the respective platform though so a bit of an additional step, but it'll make sure that especially the editor will link correctly when distributed with symbols, could be done as part of the build step as well but would require moving the renaming step into that instead of the finishing up step

It's not critical for the templates but would be required for the editor symbols to work if they aren't left as the original build output name

Edit: for the linux builds this requires the specific buildroot strip/objcopy files like in the build process itself, using the relevant SDK paths, and for Windows it requires the build environment from the same, including using the llvm-root ones for arm builds

Not critical but making these adjustments for the resulting files means that you will be able to simply copy the debug symbols from the distribution directly into the exported project without renaming which is useful

For the editor it is necessary for those to work correctly though

@AThousandShips
AThousandShips marked this pull request as draft August 20, 2026 16:47
@AThousandShips

AThousandShips commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

Ran into a crash when testing this so will do some testing on that

Edit: Seems to be unrelated to these changes, will see if I can replicate it more clearly later and report it if it hasn't been reported already

@AThousandShips
AThousandShips marked this pull request as ready for review August 20, 2026 16:57
@AThousandShips

Copy link
Copy Markdown
Member Author

So an update:
I realized that the debug symbols are only used for the crash handler when the name matches the executable, it ignores the debug link

This won't really matter currently as we adjust it with this export feature, but I'm looking into how to fetch that and use it as a backup for the name if missed, shouldn't be too difficult to just load the section, but it'd help

Longer term I'm also considering looking at leveraging the gdb lookup system to fetch the debug symbols, as it looks in a few different locations, and potentially leveraging the debuginfod system as that would allow us to provide a server for this and provide downloads on-demand, I've played around a bit with this during the weekend for my own use in my own network and it seems to work though the build system needs some adjustments I believe

But if we are happy with the way this works now I will update the class reference to reflect where it looks for the debug symbols, and start writing the details for the manual, outlining the (current) conditions for finding the relevant handlers etc.

@AThousandShips

AThousandShips commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

Actually made significant progress on integrating the .gnu_debuglink section into the crash handler on Linux, will look at doing the Windows side as well but will open a draft PR for it today if I don't run into more issues with the Linux side and implement the Windows side hopefully before the end of this week

This would make a lot more parity with the gdb system and match what is expected for debugging on the Linux side

Will work on the documentation side for this tomorrow or on Wednesday

Edit: PR open #122764

@AThousandShips

AThousandShips commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

Amended and adjusted the class reference, should be good to go now, I will create a documentation PR for this as well as #122764 as soon as I am able but as we don't really have any details about the crash handler currently I'd say it'd be better to make one adjustment to fit both

Edit: opened a very bare bones manual PR for this:

@AThousandShips

AThousandShips commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

To reiterate the scope of follow-up changes:

  • Add macOS implementation (already claimed by bruvzg above)
  • Integrate support for this into the template manager (depends on the specific organization of the debug symbol files in the release)
  • Finalize and integrate debug symbol generation into the build scripts (Add support for releasing debug symbols godot-build-scripts#103)

Longer term goals:

  • Consider alternatives for compression, would require adding built-in support for other compression algorithms
  • Consider providing the debug symbols through other means like debuginfod, hosting them somewhere (either self hosted or on some existing repository, I am not familiar with what exists already for this, would probably be on a per-platform basis), this could be done either as a prompt in the crash handler message (see below) or as an interactive prompt "do you wish to download them now", this would at minimum involve adding further lookup paths in the crash handlers (see Linux, Windows: Expand .debugsymbols search in crash handler #122764), as well as other platform solutions like Windows debug servers of some kind
  • Integrate clear note about how to access the debug symbols into the crash handler message, currently this is only really applicable to the editor side I'd say rather than exported distributed projects so out of scope for this PR

More broadly and not directly related:

  • Provide ways to dump the stack trace and symbolicize it later, not familiar with how this would work so can't comment on it. But I can see options like support for replaying stack traces directly in the engine, or providing an online tool for this, this could potentially work with plaintext crash traces assuming the specific version and build is available

Comment thread platform/linuxbsd/doc_classes/EditorExportPlatformLinuxBSD.xml Outdated
Comment thread editor/export/editor_export_platform_pc.cpp Outdated
Copies debug symbols (`.debugsymbols`) from the template path, similar to the console wrapper for Windows.

Co-authored-by: Pāvels Nadtočajevs <7645683+bruvzg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants