mirror of
https://github.com/openai/codex.git
synced 2026-10-29 19:08:43 +00:00
codex: drop dead Bazel v8 workarounds (#14225)
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -12,8 +12,5 @@ rust_library(
|
||||
"@crates//:serde",
|
||||
"@crates//:serde_json",
|
||||
],
|
||||
rustc_env = {
|
||||
"BAZEL_PACKAGE": "codex-rs/code-mode",
|
||||
},
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 <pthread.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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<uint8_t*>(base) + size;
|
||||
}
|
||||
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user