Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Align Cargo and Bazel Rust debug information defaults (#47748)

Ahmed Ibrahima16381c4457e
diff --git a/MODULE.bazel b/MODULE.bazel
index b247afd108..f668f235bf 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -189,6 +189,7 @@ single_version_override(
patch_strip = 1,
patches = [
"//patches:rules_rs_build_script_deps_annotation.patch",
+ "//patches:rules_rs_rust_debug_modes.patch",
"//patches:rules_rs_windows_msvc_linker.patch",
"//patches:rules_rs_zlib_snapshot_urls.patch",
],
diff --git a/codex-rs/Cargo.toml b/codex-rs/Cargo.toml
index 4b10699320..3d06aea813 100644
--- a/codex-rs/Cargo.toml
+++ b/codex-rs/Cargo.toml
@@ -598,9 +598,9 @@ ignored = [
]
[profile.dev]
-# Keep line tables/backtraces while avoiding expensive full variable debug info
-# across local dev builds.
-debug = "limited"
+# The test profile inherits dev. Keep source locations in ordinary builds;
+# use CARGO_PROFILE_DEV_DEBUG=full (or CARGO_PROFILE_TEST_DEBUG=full) for locals.
+debug = "line-tables-only"
[profile.dev-small]
inherits = "dev"
@@ -627,7 +627,6 @@ strip = false
[profile.ci-test]
# Reduce binary size to reduce disk pressure.
-debug = "limited"
inherits = "test"
opt-level = 0
diff --git a/patches/BUILD.bazel b/patches/BUILD.bazel
index 7b58251d8a..60181eef90 100644
--- a/patches/BUILD.bazel
+++ b/patches/BUILD.bazel
@@ -14,6 +14,7 @@ exports_files([
"rules_foreign_cc_make_xcompile.patch",
"rules_foreign_cc_make_msvc_stdint.patch",
"rules_rs_build_script_deps_annotation.patch",
+ "rules_rs_rust_debug_modes.patch",
"rules_rs_windows_msvc_linker.patch",
"rules_rs_zlib_snapshot_urls.patch",
"rusty_v8_prebuilt_out_dir.patch",
diff --git a/patches/rules_rs_rust_debug_modes.patch b/patches/rules_rs_rust_debug_modes.patch
new file mode 100644
index 0000000000..e655ba7a56
--- /dev/null
+++ b/patches/rules_rs_rust_debug_modes.patch
@@ -0,0 +1,42 @@
+diff --git a/rs/toolchains/declare_rustc_toolchains.bzl b/rs/toolchains/declare_rustc_toolchains.bzl
+--- a/rs/toolchains/declare_rustc_toolchains.bzl
++++ b/rs/toolchains/declare_rustc_toolchains.bzl
+@@ -45,6 +45,14 @@
+ },
+ )
+ source_stdlib_building_select[config_setting] = "@rules_rs//rs/private:empty_stdlib"
++
++ # Apple targets default to packed dSYMs and invoke dsymutil at link time.
++ # The Linux remote Rust action has no dsymutil. Match Cargo release's
++ # split-debuginfo policy so line/full info remains available before packaging.
++ darwin_debug_flags = select({
++ "@platforms//os:macos": ["-Csplit-debuginfo=off"],
++ "//conditions:default": [],
++ })
+-
++
+ for triple in execs:
+ exec_triple = _parse_triple(triple)
+@@ -152,8 +160,20 @@
+ "//conditions:default": [],
+ }),
+ default_edition = edition,
+- extra_exec_rustc_flags = _rustc_flags_to_select(extra_exec_rustc_flags),
+- extra_rustc_flags = _rustc_flags_to_select(extra_rustc_flags),
++ extra_exec_rustc_flags = _rustc_flags_to_select(extra_exec_rustc_flags) + darwin_debug_flags,
++ extra_rustc_flags = _rustc_flags_to_select(extra_rustc_flags) + darwin_debug_flags,
++ # Retain source locations through linking; release packaging owns
++ # extracting and stripping symbols. Keep -c dbg for full debugging.
++ debug_info = {
++ "dbg": "full",
++ "fastbuild": "line-tables-only",
++ "opt": "line-tables-only",
++ },
++ strip_level = {
++ "dbg": "none",
++ "fastbuild": "none",
++ "opt": "none",
++ },
+ exec_triple = triple,
+ target_triple = select(target_triple_select),
+ visibility = ["//visibility:public"],