Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2782802
Introduce `separate_debug_symbols` option, separate symbols on macOS &
limbonaut Sep 30, 2025
6a3580a
Simplify separation code, update help
limbonaut Sep 30, 2025
4811f4f
Add error handling
limbonaut Sep 30, 2025
a770906
Whitespace
limbonaut Sep 30, 2025
d18846e
Add support for splitting symbols on Linux
limbonaut Oct 1, 2025
e12fc36
Decode error code with WEXITSTATUS
limbonaut Oct 1, 2025
4e4e202
Use zlib
limbonaut Oct 1, 2025
5bf28f0
Whitespace
limbonaut Oct 1, 2025
18aaa09
Remove splitting symbols step as it is handled by the build system
limbonaut Oct 1, 2025
32d2309
Split symbols for crashpad_handler
limbonaut Oct 1, 2025
3240475
Move debug symbol separation logic to utils module
limbonaut Oct 1, 2025
9ebe48d
Clean up debug symbol handling and build options
limbonaut Oct 1, 2025
569b4f7
Style fix
limbonaut Oct 1, 2025
d93bd8c
Add SCons tool for debug symbol separation
limbonaut Oct 1, 2025
899dc10
Delete utils.py
limbonaut Oct 1, 2025
af02a7b
Clean up
limbonaut Oct 1, 2025
44111e5
Missing imports
limbonaut Oct 1, 2025
205d21b
Fix syntax error
limbonaut Oct 1, 2025
1311518
Remove unused import
limbonaut Oct 1, 2025
af21a46
Add meaningful message
limbonaut Oct 1, 2025
594def6
Decouple separate symbols tool from paths
limbonaut Oct 1, 2025
c716ff2
Only separate if debug_symbols option is ON
limbonaut Oct 1, 2025
0d45b60
Clean up code
limbonaut Oct 1, 2025
8b55bcf
Update CHANGELOG.md
limbonaut Oct 1, 2025
05e9fd0
Merge branch 'main' into build/separate-symbols-option
limbonaut Oct 1, 2025
a65e538
Clean up
limbonaut Oct 1, 2025
b6a7c86
Revert "Clean up"
limbonaut Oct 1, 2025
ad26f7c
Missing include
limbonaut Oct 1, 2025
8367cd4
Style fix
limbonaut Oct 2, 2025
130f38c
Merge branch 'main' into build/separate-symbols-option
limbonaut Oct 2, 2025
708a671
Remove unused variable
limbonaut Oct 2, 2025
18daabf
Remove unused variable
limbonaut Oct 2, 2025
eb88a4e
Remove another unused var
limbonaut Oct 2, 2025
261e95b
Remove unused import
limbonaut Oct 2, 2025
02e3f1b
Remove more unused imports
limbonaut Oct 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .github/workflows/build_gdextension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,22 +291,6 @@ jobs:
run: |
scons platform=${{matrix.platform}} target=${{matrix.target}} arch=${{matrix.arch}} ${{matrix.scons-flags}}

- name: Separate debug symbols on Linux
if: matrix.platform == 'linux'
env:
BUILD_TYPE: ${{matrix.target == 'template_release' && 'release' || 'debug'}}
shell: bash
run: |
if [ -d "project/addons/sentry/bin/linux/${{matrix.arch}}" ]; then
cd project/addons/sentry/bin/linux/${{matrix.arch}}
else
cd project/addons/sentry/bin/noop
fi
lib=libsentry.${{matrix.platform}}.${BUILD_TYPE}.${{matrix.arch}}.so
objcopy --only-keep-debug ${lib} ${lib}.debug
objcopy --add-gnu-debuglink ${lib}.debug ${lib}
strip --strip-debug ${lib}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Set device.name to OS hostname on Windows/Linux dedicated servers ([#391](https://github.com/getsentry/sentry-godot/pull/391))
- Prevent usage of Godot logger during crash handling on Windows/Linux ([#398](https://github.com/getsentry/sentry-godot/pull/398))
- Add missing Cocoa SDK symbols to builds ([#401](https://github.com/getsentry/sentry-godot/pull/401))
- Add build option to separate debug symbols for GDExtension and crashpad_handler, and do it in the official builds ([#399](https://github.com/getsentry/sentry-godot/pull/399))

### Fixes

Expand Down
52 changes: 35 additions & 17 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def add_custom_bool_option(name, description, default=False):
# Define our custom options
add_custom_bool_option("generate_ios_framework", "Generate iOS xcframework from static libraries", False)
add_custom_bool_option("build_android_lib", "Build Android bridge library", False)
add_custom_bool_option("separate_debug_symbols", "Separate debug symbols (supported on macOS, iOS, Linux)", True)

# Workaround: Remove custom options from ARGUMENTS to avoid warnings from godot-cpp.
# Godot complains about variables it does not recognize. See: https://github.com/godotengine/godot-cpp/issues/1334
Expand All @@ -78,6 +79,7 @@ arch = env["arch"]

# Register tools
env.Tool("copy")
env.Tool("separate_debug_symbols")

# Restore original ARGUMENTS and add custom options to environment
ARGUMENTS.clear()
Expand Down Expand Up @@ -134,6 +136,11 @@ if internal_sdk == SDK.NATIVE:
deploy_crashpad_handler = env.CopyCrashpadHandler(out_dir)
Default(deploy_crashpad_handler)

if env["separate_debug_symbols"] and platform == "linux":
handler_path = str(deploy_crashpad_handler[0])
symbols_path = f"{handler_path}.debug"
Default(env.SeparateDebugSymbols(File(symbols_path), File(handler_path)))


# *** Utilize sentry-cocoa.

Expand Down Expand Up @@ -190,15 +197,11 @@ if platform == "ios":
extra += ".simulator"

temp_dir = "project/addons/sentry/bin/ios/temp"
lib_path = f"{temp_dir}/libsentry.{platform}.{build_type}.{arch}{extra}.dylib"

library = env.SharedLibrary(
lib_path,
source=sources,
)
lib_name = f"libsentry.{platform}.{build_type}.{arch}{extra}"
lib_path = f"{temp_dir}/{lib_name}.dylib"

library = env.SharedLibrary(lib_path, source=sources)
Default(library)
Clean(library, File(lib_path))

# Generate XCFramework for iOS GDExtension libs if requested
device_lib = f"{temp_dir}/libsentry.{platform}.{build_type}.arm64.dylib"
Expand All @@ -211,17 +214,17 @@ if platform == "ios":
)
Alias("ios_framework", ios_framework)

if env.get("generate_ios_framework", False):
if env["generate_ios_framework"]:
env.Depends(ios_framework, library)
Default(ios_framework)

elif platform == "macos":
# *** Build macOS shared library.

library = env.SharedLibrary(
f"{out_dir}/libsentry.{platform}.{build_type}.framework/libsentry.{platform}.{build_type}{extra}",
source=sources,
)
lib_name = f"libsentry.{platform}.{build_type}{extra}"
lib_path = f"{out_dir}/{lib_name}.framework/{lib_name}"

library = env.SharedLibrary(lib_path, source=sources)
Default(library)

else:
Expand All @@ -231,12 +234,27 @@ else:
if env["threads"] is False:
extra += ".nothreads"

library = env.SharedLibrary(
f"{out_dir}/libsentry.{platform}.{build_type}.{arch}{extra}{shlib_suffix}",
source=sources,
)
lib_name = f"libsentry.{platform}.{build_type}.{arch}{extra}"
lib_path = f"{out_dir}/{lib_name}{shlib_suffix}"

library = env.SharedLibrary(lib_path, source=sources)
Default(library)


# *** Separate GDExtension debug symbols

if env["debug_symbols"] and env["separate_debug_symbols"]:
# Note: Windows/MSVC separates by default.
if platform in ["macos", "ios"]:
dsym_path = f"{out_dir}/dSYMs/{lib_name}.framework.dSYM"
separate_symbols = env.SeparateDebugSymbols(Dir(dsym_path), File(lib_path))
Default(separate_symbols)
elif platform == "linux":
symbols_path = f"{lib_path}.debug"
separate_symbols = env.SeparateDebugSymbols(File(symbols_path), File(lib_path))
Default(separate_symbols)


# *** Build Android lib

if sys.platform.startswith("win"):
Expand All @@ -260,7 +278,7 @@ env_gradle.AlwaysBuild(android_lib)

Alias("android_lib", android_lib)

if env.get("build_android_lib", False):
if env["build_android_lib"]:
Default(android_lib)
Depends(android_lib, library)

Expand Down
64 changes: 64 additions & 0 deletions site_scons/site_tools/separate_debug_symbols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""
Tool to separate debug symbols.
"""

from SCons.Script import Clean, Exit, Action
import os


def separate_debug_symbols(target, source, env):
platform = env["platform"]

target_path = str(target[0])
source_path = str(source[0])

def run(cmd):
err = os.system(cmd)
return os.WEXITSTATUS(err)

if platform in ["macos", "ios"]:
err = run(f'dsymutil "{source_path}" -o "{target_path}"')
if err != 0:
print(f"ERROR: Failed to split debug symbols (exit code {err})")
Exit(1)

err = run(f'strip -u -r "{source_path}"')
if err != 0:
print(f"ERROR: Failed to strip debug symbols (exit code {err})")
Exit(1)
elif platform == "linux":
err = run(f'objcopy --only-keep-debug --compress-debug-sections=zlib "{source_path}" "{target_path}"')
if err != 0:
print(f"ERROR: Failed to split debug symbols (exit code {err})")
Exit(1)

err = run(f'strip --strip-debug --strip-unneeded "{source_path}"')
if err != 0:
print(f"ERROR: Failed to strip debug symbols (exit code {err})")
Exit(1)

err = run(f'objcopy --add-gnu-debuglink="{target_path}" "{source_path}"')
if err != 0:
print(f"ERROR: Failed to add debug link (exit code {err})")
Exit(1)
else:
print("ERROR: Can't separate debug symbols on this platform")
Exit(1)


def command(env, target, source):
result = env.Command(
target,
source,
Action(separate_debug_symbols, cmdstr="Separating debug symbols: $SOURCE -> $TARGET")
)
Clean(target, target)
return result


def generate(env):
env.AddMethod(command, "SeparateDebugSymbols")


def exists(env):
return True