Skip to content

Commit

Permalink
build: Make backtraces useable in release builds
Browse files Browse the repository at this point in the history
Having `strip = "symbols"` and omitting `-C force-unwind-tables` makes backtraces generated with `RUST_BACKTRACE=1` completely useless in release builds.

By adding the `-C force-unwind-tables` flag and setting `strip = "debuginfo"`, we make backtraces usable in release builds. This will help us debug issues we are unable to reproduce, since we can ask users to set `RUST_BACKTRACE=1` and provide the logs with this option.
  • Loading branch information
szokeasaurusrex committed Dec 20, 2024
1 parent 5bd1089 commit ed19a2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[build]
rustflags = ["-C", "force-unwind-tables"] # Make backtraces work.

[target.'cfg(all(windows, target_env = "msvc"))']
rustflags = ["-C", "target-feature=+crt-static"]
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ winapi = "0.3.9"
[profile.release]
opt-level = "z"
panic = "abort"
strip = true # Strip symbols from the binary.
codegen-units = 1 # Parallel compilation prevents some optimizations.
strip = "debuginfo" # Only strip debuginfo (not symbols) to keep backtraces useful.
codegen-units = 1 # Parallel compilation prevents some optimizations.
# We do not enable link-time optimizations (lto) because they cause the
# CLI to timeout when run in Xcode Cloud.

0 comments on commit ed19a2b

Please sign in to comment.