Skip to content

Improve Linux/macOS debug symbol setup#860

Open
skottmckay wants to merge 2 commits into
mainfrom
skottmckay/CreateSeparateSymbolsFileOnLinuxAndMacOS
Open

Improve Linux/macOS debug symbol setup#860
skottmckay wants to merge 2 commits into
mainfrom
skottmckay/CreateSeparateSymbolsFileOnLinuxAndMacOS

Conversation

@skottmckay

Copy link
Copy Markdown
Collaborator

Separate/create symbols file for linux and macos to replicate Windows setup where the release library binary is small but the symbols are available for debugging issues.

Linux — three-step GNU toolchain sequence:

  1. objcopy --only-keep-debuglibfoundry_local.so.dbg (DWARF only)
  2. strip --strip-debug → removes DWARF sections from the .so, keeps the exported symbol table (needed for dlopen)
  3. objcopy --add-gnu-debuglink=libfoundry_local.so.dbg → embeds the filename + CRC into a .gnu_debuglink section. GDB/LLDB read this and auto-discover the .dbg file when it's in the same directory. Zero developer friction.

macOS — two-step Apple toolchain sequence (order matters):

  1. dsymutil first — harvests DWARF from all .o files (still present at POST_BUILD time) into libfoundry_local.dylib.dSYM/ — a self-contained relocatable bundle
  2. strip -S second — removes the now-redundant N_OSO stab entries. LLDB/Xcode find the .dSYM automatically by UUID when it sits alongside the .dylib.

… setup where the release library binary is small but the symbols are available for debugging issues.
Copilot AI review requested due to automatic review settings July 1, 2026 22:04
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment Jul 1, 2026 10:31pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes Linux and macOS RelWithDebInfo builds produce split debug symbols, mirroring the existing Windows behavior (small shipped binary + separately available symbols). A new CMake module wires up POST_BUILD symbol extraction, and the Linux/macOS pipeline build steps stage the resulting companion files as artifacts.

Changes:

  • Add cmake/SplitDebugSymbols.cmake to split symbols for RelWithDebInfo: Linux uses objcopy --only-keep-debug + strip --strip-debug + --add-gnu-debuglink; macOS uses dsymutil then strip -S.
  • Include the new module from sdk_v2/cpp/CMakeLists.txt.
  • Stage libfoundry_local.so.dbg (Linux) and libfoundry_local.dylib.dSYM (macOS) into the native build artifact.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
sdk_v2/cpp/cmake/SplitDebugSymbols.cmake New CMake module performing platform-appropriate debug-symbol splitting for RelWithDebInfo only.
sdk_v2/cpp/CMakeLists.txt Includes the new module after the shared/interface targets are defined.
.pipelines/v2/templates/steps-build-linux.yml Stages the .dbg companion into the shared native artifact.
.pipelines/v2/templates/steps-build-macos.yml Stages the .dSYM bundle into the shared native artifact.

Notable concern: the .dbg/.dSYM are staged into the same cpp-native-<rid> artifact that the Python wheel build copies wholesale, so the macOS .dSYM bundle collides with the real dylib in the wheel and the Linux .dbg bloats the wheel — contrary to the PR's "small shipped binary" goal.

Comment on lines +108 to +111
dsym="$src/libfoundry_local.dylib.dSYM"
if [ -d "$dsym" ]; then
cp -r "$dsym" "$dst/"
echo " staged libfoundry_local.dylib.dSYM"
Comment thread .pipelines/v2/templates/steps-build-linux.yml
@prathikr

prathikr commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Do we want to include these symbols/debug files in the tgz files of the cpp sdk? Will need some changes under .pipelines\v2\templates\steps-pack-cpp-sdk.yml to add symbols into the tgz files.

@skottmckay

Copy link
Copy Markdown
Collaborator Author

Do we want to include these symbols/debug files in the tgz files of the cpp sdk? Will need some changes under .pipelines\v2\templates\steps-pack-cpp-sdk.yml to add symbols into the tgz files.

I think so. We don't want the symbols in the packages, but we do want them to be available for direct download. We also need to publish the pdb to the windows symbol server I believe.

Can you add the required changes to this branch or point me to what needs updating?

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

Successfully merging this pull request may close these issues.

4 participants