From ce7c72db251c04649449ae3a5db9e3f49c72c530 Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Wed, 11 Mar 2026 11:54:46 -0700 Subject: [PATCH] codex: drop dead Bazel v8 workarounds (#14225) --- MODULE.bazel | 8 --- codex-rs/code-mode/BUILD.bazel | 3 -- codex-rs/code-mode/src/bazel_stub.rs | 9 +--- codex-rs/code-mode/src/libc_stack_end_shim.cc | 25 ---------- defs.bzl | 13 ++--- .../v8_relative_prebuilt_binding_path.patch | 49 ------------------- 6 files changed, 5 insertions(+), 102 deletions(-) delete mode 100644 codex-rs/code-mode/src/libc_stack_end_shim.cc delete mode 100644 patches/v8_relative_prebuilt_binding_path.patch diff --git a/MODULE.bazel b/MODULE.bazel index c4bcd33e22..f55bd1f26d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -88,14 +88,6 @@ crate.annotation( ], ) -crate.annotation( - crate = "v8", - patch_args = ["-p1"], - patches = [ - "//patches:v8_relative_prebuilt_binding_path.patch", - ], -) - inject_repo(crate, "zstd") bazel_dep(name = "bzip2", version = "1.0.8.bcr.3") diff --git a/codex-rs/code-mode/BUILD.bazel b/codex-rs/code-mode/BUILD.bazel index 51ae5bbb14..0de939e6b5 100644 --- a/codex-rs/code-mode/BUILD.bazel +++ b/codex-rs/code-mode/BUILD.bazel @@ -12,8 +12,5 @@ rust_library( "@crates//:serde", "@crates//:serde_json", ], - rustc_env = { - "BAZEL_PACKAGE": "codex-rs/code-mode", - }, visibility = ["//visibility:public"], ) diff --git a/codex-rs/code-mode/src/bazel_stub.rs b/codex-rs/code-mode/src/bazel_stub.rs index f70e912345..2253bc0d82 100644 --- a/codex-rs/code-mode/src/bazel_stub.rs +++ b/codex-rs/code-mode/src/bazel_stub.rs @@ -8,19 +8,14 @@ pub use api::ExecutionResult; pub use api::ToolCallHandler; pub use api::ToolKind; -const BAZEL_BUILD: bool = option_env!("BAZEL_PACKAGE").is_some(); const BAZEL_UNSUPPORTED_REASON: &str = "code_mode is unavailable in Bazel builds"; pub const fn is_supported() -> bool { - !BAZEL_BUILD + false } pub fn unsupported_reason() -> Option<&'static str> { - if BAZEL_BUILD { - Some(BAZEL_UNSUPPORTED_REASON) - } else { - None - } + Some(BAZEL_UNSUPPORTED_REASON) } pub fn execute( diff --git a/codex-rs/code-mode/src/libc_stack_end_shim.cc b/codex-rs/code-mode/src/libc_stack_end_shim.cc deleted file mode 100644 index 9e5ba6441e..0000000000 --- a/codex-rs/code-mode/src/libc_stack_end_shim.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Bazel's Linux linker setup does not currently resolve V8's -// `__libc_stack_end` reference from the system runtime. Provide a weak -// definition and initialize it from the current thread's stack bounds so the -// prebuilt archive can link and main-thread stack probing still has a sensible -// fallback. -#include -#include -#include - -extern "C" __attribute__((weak)) void* __libc_stack_end = nullptr; - -__attribute__((constructor)) static void init_libc_stack_end() { - pthread_attr_t attr; - if (pthread_getattr_np(pthread_self(), &attr) != 0) { - return; - } - - void* base = nullptr; - size_t size = 0; - if (pthread_attr_getstack(&attr, &base, &size) == 0 && base != nullptr) { - __libc_stack_end = static_cast(base) + size; - } - - pthread_attr_destroy(&attr); -} diff --git a/defs.bzl b/defs.bzl index 22ea527231..058c1906a8 100644 --- a/defs.bzl +++ b/defs.bzl @@ -149,13 +149,6 @@ def codex_rust_crate( "BAZEL_PACKAGE": native.package_name(), } | rustc_env - linux_allow_multiple_definitions_flags = select({ - "@platforms//os:linux": [ - "-Clink-arg=-Wl,--allow-multiple-definition", - ], - "//conditions:default": [], - }) - binaries = DEP_DATA.get(native.package_name())["binaries"] lib_srcs = crate_srcs or native.glob(["src/**/*.rs"], exclude = binaries.values(), allow_empty = True) @@ -202,7 +195,7 @@ def codex_rust_crate( rustc_flags = rustc_flags_extra + [ "--remap-path-prefix=../codex-rs=", "--remap-path-prefix=codex-rs=", - ] + linux_allow_multiple_definitions_flags, + ], rustc_env = rustc_env, data = test_data_extra, tags = test_tags + ["manual"], @@ -231,7 +224,7 @@ def codex_rust_crate( crate_root = main, deps = all_crate_deps() + maybe_deps + deps_extra, edition = crate_edition, - rustc_flags = rustc_flags_extra + linux_allow_multiple_definitions_flags, + rustc_flags = rustc_flags_extra, srcs = native.glob(["src/**/*.rs"]), visibility = ["//visibility:public"], ) @@ -262,7 +255,7 @@ def codex_rust_crate( rustc_flags = rustc_flags_extra + [ "--remap-path-prefix=../codex-rs=", "--remap-path-prefix=codex-rs=", - ] + linux_allow_multiple_definitions_flags, + ], rustc_env = rustc_env, # Important: do not merge `test_env` here. Its unit-test-only # `INSTA_WORKSPACE_ROOT="codex-rs"` is tuned for unit tests that diff --git a/patches/v8_relative_prebuilt_binding_path.patch b/patches/v8_relative_prebuilt_binding_path.patch deleted file mode 100644 index f621dff4e8..0000000000 --- a/patches/v8_relative_prebuilt_binding_path.patch +++ /dev/null @@ -1,49 +0,0 @@ -diff --git a/build.rs b/build.rs ---- a/build.rs -+++ b/build.rs -@@ -578,6 +578,16 @@ - } - - fn static_lib_dir() -> PathBuf { -+ if let Some(out_dir) = env::var_os("OUT_DIR") { -+ let out_dir = PathBuf::from(out_dir); -+ if out_dir -+ .components() -+ .any(|component| component.as_os_str() == "bazel-out") -+ { -+ return out_dir; -+ } -+ } -+ - build_dir().join("gn_out").join("obj") - } - -@@ -591,6 +601,13 @@ - ); - let out_dir_abs = cwd.join(out_dir); - -+ if out_dir_abs -+ .components() -+ .any(|component| component.as_os_str() == "bazel-out") -+ { -+ return out_dir_abs.parent().unwrap().to_path_buf(); -+ } -+ - // This would be `target/debug` or `target/release` - out_dir_abs - .parent() -@@ -861,9 +878,13 @@ - download_file(&url, &src_binding_path); - } - -+ // `src/binding.rs` includes this path directly, so keep it relative to that -+ // source file instead of the build script's synthetic runfiles directory. -+ let include_path = Path::new("..").join("gen").join(name); -+ - println!( - "cargo:rustc-env=RUSTY_V8_SRC_BINDING_PATH={}", -- src_binding_path.display() -+ include_path.display() - ); - } -