From c0c3e5838a595e4e250e2b86974a1b155a06fcac Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 11:14:08 -0700 Subject: [PATCH 01/13] codex: wire WebRTC media into Bazel Remove the codex_bazel native stub and build the realtime WebRTC crate through the normal Bazel crate macro. Share the macOS -ObjC link flag with the Bazel binaries/tests that can pull libwebrtc in. Co-authored-by: Codex --- MODULE.bazel | 16 +++++++++++++ codex-rs/cli/BUILD.bazel | 3 ++- codex-rs/realtime-webrtc/BUILD.bazel | 11 +++------ codex-rs/realtime-webrtc/src/lib.rs | 14 +++++------ codex-rs/tui/BUILD.bazel | 3 ++- defs.bzl | 10 ++++++++ .../webrtc-sys_hermetic_darwin_sysroot.patch | 23 +++++++++++++++++++ 7 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 patches/webrtc-sys_hermetic_darwin_sysroot.patch diff --git a/MODULE.bazel b/MODULE.bazel index bcc4ec076c5..e59855a3bd7 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -345,6 +345,22 @@ crate.annotation( inject_repo(crate, "llvm", "llvm-project", "macos_sdk") +crate.annotation( + # Provide the hermetic SDK path so the build script doesn't try to invoke an unavailable `xcrun --show-sdk-path`. + build_script_data = [ + "@macos_sdk//sysroot", + ], + build_script_env = { + "WEBRTC_SYS_DARWIN_SDK_PATH": "$(location @macos_sdk//sysroot)", + }, + crate = "webrtc-sys", + gen_build_script = "on", + patch_args = ["-p1"], + patches = [ + "//patches:webrtc-sys_hermetic_darwin_sysroot.patch", + ], +) + # Fix readme inclusions crate.annotation( crate = "windows-link", diff --git a/codex-rs/cli/BUILD.bazel b/codex-rs/cli/BUILD.bazel index 8998d759de4..a8a97cef004 100644 --- a/codex-rs/cli/BUILD.bazel +++ b/codex-rs/cli/BUILD.bazel @@ -1,8 +1,9 @@ -load("//:defs.bzl", "codex_rust_crate", "multiplatform_binaries") +load("//:defs.bzl", "MACOS_WEBRTC_RUSTC_LINK_FLAGS", "codex_rust_crate", "multiplatform_binaries") codex_rust_crate( name = "cli", crate_name = "codex_cli", + rustc_flags_extra = MACOS_WEBRTC_RUSTC_LINK_FLAGS, ) multiplatform_binaries( diff --git a/codex-rs/realtime-webrtc/BUILD.bazel b/codex-rs/realtime-webrtc/BUILD.bazel index 3e37dd62a84..1be89f035d9 100644 --- a/codex-rs/realtime-webrtc/BUILD.bazel +++ b/codex-rs/realtime-webrtc/BUILD.bazel @@ -1,12 +1,7 @@ -load("@rules_rust//rust:defs.bzl", "rust_library") +load("//:defs.bzl", "MACOS_WEBRTC_RUSTC_LINK_FLAGS", "codex_rust_crate") -rust_library( +codex_rust_crate( name = "realtime-webrtc", crate_name = "codex_realtime_webrtc", - crate_root = "src/lib.rs", - srcs = ["src/lib.rs"], - edition = "2024", - rustc_flags = ["--cfg=codex_bazel"], - deps = ["@crates//:thiserror"], - visibility = ["//visibility:public"], + rustc_flags_extra = MACOS_WEBRTC_RUSTC_LINK_FLAGS, ) diff --git a/codex-rs/realtime-webrtc/src/lib.rs b/codex-rs/realtime-webrtc/src/lib.rs index b6eb5000099..69761ecd5c5 100644 --- a/codex-rs/realtime-webrtc/src/lib.rs +++ b/codex-rs/realtime-webrtc/src/lib.rs @@ -1,4 +1,4 @@ -#[cfg(all(target_os = "macos", not(codex_bazel)))] +#[cfg(target_os = "macos")] mod native; use std::fmt; @@ -31,7 +31,7 @@ pub struct StartedRealtimeWebrtcSession { } pub struct RealtimeWebrtcSessionHandle { - #[cfg(all(target_os = "macos", not(codex_bazel)))] + #[cfg(target_os = "macos")] inner: native::SessionHandle, local_audio_peak: Arc, } @@ -45,11 +45,11 @@ impl fmt::Debug for RealtimeWebrtcSessionHandle { impl RealtimeWebrtcSessionHandle { pub fn apply_answer_sdp(&self, answer_sdp: String) -> Result<()> { - #[cfg(all(target_os = "macos", not(codex_bazel)))] + #[cfg(target_os = "macos")] { self.inner.apply_answer_sdp(answer_sdp) } - #[cfg(any(not(target_os = "macos"), codex_bazel))] + #[cfg(not(target_os = "macos"))] { let _ = answer_sdp; Err(RealtimeWebrtcError::UnsupportedPlatform) @@ -57,7 +57,7 @@ impl RealtimeWebrtcSessionHandle { } pub fn close(&self) { - #[cfg(all(target_os = "macos", not(codex_bazel)))] + #[cfg(target_os = "macos")] self.inner.close(); } @@ -70,7 +70,7 @@ pub struct RealtimeWebrtcSession; impl RealtimeWebrtcSession { pub fn start() -> Result { - #[cfg(all(target_os = "macos", not(codex_bazel)))] + #[cfg(target_os = "macos")] { let started = native::start()?; Ok(StartedRealtimeWebrtcSession { @@ -82,7 +82,7 @@ impl RealtimeWebrtcSession { events: started.events, }) } - #[cfg(any(not(target_os = "macos"), codex_bazel))] + #[cfg(not(target_os = "macos"))] { Err(RealtimeWebrtcError::UnsupportedPlatform) } diff --git a/codex-rs/tui/BUILD.bazel b/codex-rs/tui/BUILD.bazel index ef6866293ab..33cc1334318 100644 --- a/codex-rs/tui/BUILD.bazel +++ b/codex-rs/tui/BUILD.bazel @@ -1,4 +1,4 @@ -load("//:defs.bzl", "codex_rust_crate") +load("//:defs.bzl", "MACOS_WEBRTC_RUSTC_LINK_FLAGS", "codex_rust_crate") codex_rust_crate( name = "tui", @@ -23,4 +23,5 @@ codex_rust_crate( extra_binaries = [ "//codex-rs/cli:codex", ], + rustc_flags_extra = MACOS_WEBRTC_RUSTC_LINK_FLAGS, ) diff --git a/defs.bzl b/defs.bzl index a8ffaa77b33..7a50a308f41 100644 --- a/defs.bzl +++ b/defs.bzl @@ -31,6 +31,16 @@ WINDOWS_RUSTC_LINK_FLAGS = select({ "//conditions:default": [], }) +# libwebrtc uses Objective-C categories from native archives. Any Bazel-linked +# macOS binary/test that can pull it in must keep category symbols alive. +MACOS_WEBRTC_RUSTC_LINK_FLAGS = select({ + "@platforms//os:macos": [ + "-C", + "link-arg=-ObjC", + ], + "//conditions:default": [], +}) + def multiplatform_binaries(name, platforms = PLATFORMS): for platform in platforms: platform_data( diff --git a/patches/webrtc-sys_hermetic_darwin_sysroot.patch b/patches/webrtc-sys_hermetic_darwin_sysroot.patch new file mode 100644 index 00000000000..74e34d88250 --- /dev/null +++ b/patches/webrtc-sys_hermetic_darwin_sysroot.patch @@ -0,0 +1,23 @@ +diff --git a/webrtc-sys/build.rs b/webrtc-sys/build.rs +index 3b4a24a..e6fb056 100644 +--- a/webrtc-sys/build.rs ++++ b/webrtc-sys/build.rs +@@ -375,9 +375,16 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) { + println!("cargo:rustc-link-lib={}", clang_rt); + println!("cargo:rustc-link-arg=-ObjC"); + +- let sysroot = Command::new("xcrun").args(["--sdk", sdk, "--show-sdk-path"]).output().unwrap(); +- +- let sysroot = String::from_utf8_lossy(&sysroot.stdout); ++ let sysroot = env::var("WEBRTC_SYS_DARWIN_SDK_PATH").unwrap_or_else(|_| { ++ let output = Command::new("xcrun") ++ .args(["--sdk", sdk, "--show-sdk-path"]) ++ .output() ++ .unwrap(); ++ String::from_utf8_lossy(&output.stdout).into_owned() ++ }); ++ ++ let sysroot = sysroot.as_str(); + let sysroot = sysroot.trim(); + + let search_dirs = Command::new("cc").arg("--print-search-dirs").output().unwrap(); From ecf380b2f5bfd05883dd3654d04887404778a821 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 11:39:53 -0700 Subject: [PATCH 02/13] Fix WebRTC Bazel CI setup Add the missing image-generation auth flag in the remaining ToolsConfigParams test helpers, and correct the webrtc-sys patch hunk size so Bazel can apply it.\n\nCo-authored-by: Codex --- codex-rs/core/src/tools/spec_tests.rs | 1 + codex-rs/tools/src/tool_registry_plan_tests.rs | 1 + patches/webrtc-sys_hermetic_darwin_sysroot.patch | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/codex-rs/core/src/tools/spec_tests.rs b/codex-rs/core/src/tools/spec_tests.rs index a635a0f9e36..2a2c11a917d 100644 --- a/codex-rs/core/src/tools/spec_tests.rs +++ b/codex-rs/core/src/tools/spec_tests.rs @@ -170,6 +170,7 @@ fn multi_agent_v2_tools_config() -> ToolsConfig { model_info: &model_info, available_models: &available_models, features: &features, + image_generation_tool_auth_allowed: true, web_search_mode: Some(WebSearchMode::Cached), session_source: SessionSource::Cli, sandbox_policy: &SandboxPolicy::DangerFullAccess, diff --git a/codex-rs/tools/src/tool_registry_plan_tests.rs b/codex-rs/tools/src/tool_registry_plan_tests.rs index 6532e1627db..7a66eaf0e43 100644 --- a/codex-rs/tools/src/tool_registry_plan_tests.rs +++ b/codex-rs/tools/src/tool_registry_plan_tests.rs @@ -1604,6 +1604,7 @@ fn code_mode_preserves_nullable_and_literal_mcp_input_shapes() { model_info: &model_info, available_models: &available_models, features: &features, + image_generation_tool_auth_allowed: true, web_search_mode: Some(WebSearchMode::Cached), session_source: SessionSource::Cli, sandbox_policy: &SandboxPolicy::DangerFullAccess, diff --git a/patches/webrtc-sys_hermetic_darwin_sysroot.patch b/patches/webrtc-sys_hermetic_darwin_sysroot.patch index 74e34d88250..eab19d6bc04 100644 --- a/patches/webrtc-sys_hermetic_darwin_sysroot.patch +++ b/patches/webrtc-sys_hermetic_darwin_sysroot.patch @@ -2,7 +2,7 @@ diff --git a/webrtc-sys/build.rs b/webrtc-sys/build.rs index 3b4a24a..e6fb056 100644 --- a/webrtc-sys/build.rs +++ b/webrtc-sys/build.rs -@@ -375,9 +375,16 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) { +@@ -375,8 +375,15 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) { println!("cargo:rustc-link-lib={}", clang_rt); println!("cargo:rustc-link-arg=-ObjC"); From 1ebc9d1eceef66eab74b6f7231b1a7dc1a22a98c Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 11:45:08 -0700 Subject: [PATCH 03/13] Export WebRTC sys Bazel patch Expose the hermetic sysroot patch from the patches package so MODULE.bazel can reference it by label.\n\nCo-authored-by: Codex --- patches/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/patches/BUILD.bazel b/patches/BUILD.bazel index 4db61293c2d..0924842e489 100644 --- a/patches/BUILD.bazel +++ b/patches/BUILD.bazel @@ -20,6 +20,7 @@ exports_files([ "v8_bazel_rules.patch", "v8_module_deps.patch", "v8_source_portability.patch", + "webrtc-sys_hermetic_darwin_sysroot.patch", "windows-link.patch", "xz_windows_stack_args.patch", "zstd-sys_windows_msvc_include_dirs.patch", From a436e609ebc31e1dff5d25ee0c1015e52cbe424e Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 11:49:58 -0700 Subject: [PATCH 04/13] Fix WebRTC sys patch hunk header Correct the old-side hunk length; the patch removes a blank line as part of replacing the xcrun-based sysroot lookup.\n\nCo-authored-by: Codex --- patches/webrtc-sys_hermetic_darwin_sysroot.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/webrtc-sys_hermetic_darwin_sysroot.patch b/patches/webrtc-sys_hermetic_darwin_sysroot.patch index eab19d6bc04..3d74c62e20c 100644 --- a/patches/webrtc-sys_hermetic_darwin_sysroot.patch +++ b/patches/webrtc-sys_hermetic_darwin_sysroot.patch @@ -2,7 +2,7 @@ diff --git a/webrtc-sys/build.rs b/webrtc-sys/build.rs index 3b4a24a..e6fb056 100644 --- a/webrtc-sys/build.rs +++ b/webrtc-sys/build.rs -@@ -375,8 +375,15 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) { +@@ -375,9 +375,15 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) { println!("cargo:rustc-link-lib={}", clang_rt); println!("cargo:rustc-link-arg=-ObjC"); From 7fbbc4bf9e81904045e2f9dcf95bf6caed093872 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 11:55:29 -0700 Subject: [PATCH 05/13] Retarget WebRTC sys patch to crate root Keep patch_args at -p1 and use a/build.rs so Bazel can find the webrtc-sys build script.\n\nCo-authored-by: Codex --- patches/webrtc-sys_hermetic_darwin_sysroot.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/webrtc-sys_hermetic_darwin_sysroot.patch b/patches/webrtc-sys_hermetic_darwin_sysroot.patch index 3d74c62e20c..1e23f254ec3 100644 --- a/patches/webrtc-sys_hermetic_darwin_sysroot.patch +++ b/patches/webrtc-sys_hermetic_darwin_sysroot.patch @@ -1,7 +1,7 @@ -diff --git a/webrtc-sys/build.rs b/webrtc-sys/build.rs +diff --git a/build.rs b/build.rs index 3b4a24a..e6fb056 100644 ---- a/webrtc-sys/build.rs -+++ b/webrtc-sys/build.rs +--- a/build.rs ++++ b/build.rs @@ -375,9 +375,15 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) { println!("cargo:rustc-link-lib={}", clang_rt); println!("cargo:rustc-link-arg=-ObjC"); From 62678ac9bf699ca30292c42f58b42f36c649cae1 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 12:08:12 -0700 Subject: [PATCH 06/13] Use Bazel CC for WebRTC sys search dirs Extend the webrtc-sys build-script patch to use Bazel's CC when querying linker search directories.\n\nCo-authored-by: Codex --- patches/webrtc-sys_hermetic_darwin_sysroot.patch | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/patches/webrtc-sys_hermetic_darwin_sysroot.patch b/patches/webrtc-sys_hermetic_darwin_sysroot.patch index 1e23f254ec3..e9cfdfceeef 100644 --- a/patches/webrtc-sys_hermetic_darwin_sysroot.patch +++ b/patches/webrtc-sys_hermetic_darwin_sysroot.patch @@ -2,7 +2,7 @@ diff --git a/build.rs b/build.rs index 3b4a24a..e6fb056 100644 --- a/build.rs +++ b/build.rs -@@ -375,9 +375,15 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) { +@@ -375,10 +375,21 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) { println!("cargo:rustc-link-lib={}", clang_rt); println!("cargo:rustc-link-arg=-ObjC"); @@ -20,4 +20,11 @@ index 3b4a24a..e6fb056 100644 + let sysroot = sysroot.as_str(); let sysroot = sysroot.trim(); - let search_dirs = Command::new("cc").arg("--print-search-dirs").output().unwrap(); +- let search_dirs = Command::new("cc").arg("--print-search-dirs").output().unwrap(); ++ let cc = env::var("CC").unwrap_or_else(|_| "cc".to_string()); ++ let search_dirs = Command::new(cc) ++ .arg("--print-search-dirs") ++ .output() ++ .unwrap(); ++ + let search_dirs = String::from_utf8_lossy(&search_dirs.stdout); From 0268bc4f47e9ea15cf6c3f2ec746d64a68867e78 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 12:13:17 -0700 Subject: [PATCH 07/13] Minimize WebRTC sys build script patch context Reduce the webrtc-sys patch to the two tool lookup replacements so it applies cleanly to the Bazel-resolved crate version.\n\nCo-authored-by: Codex --- patches/webrtc-sys_hermetic_darwin_sysroot.patch | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/patches/webrtc-sys_hermetic_darwin_sysroot.patch b/patches/webrtc-sys_hermetic_darwin_sysroot.patch index e9cfdfceeef..63acac97794 100644 --- a/patches/webrtc-sys_hermetic_darwin_sysroot.patch +++ b/patches/webrtc-sys_hermetic_darwin_sysroot.patch @@ -2,10 +2,7 @@ diff --git a/build.rs b/build.rs index 3b4a24a..e6fb056 100644 --- a/build.rs +++ b/build.rs -@@ -375,10 +375,21 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) { - println!("cargo:rustc-link-lib={}", clang_rt); - println!("cargo:rustc-link-arg=-ObjC"); - +@@ -378,3 +378,9 @@ - let sysroot = Command::new("xcrun").args(["--sdk", sdk, "--show-sdk-path"]).output().unwrap(); - - let sysroot = String::from_utf8_lossy(&sysroot.stdout); @@ -18,13 +15,10 @@ index 3b4a24a..e6fb056 100644 + }); + + let sysroot = sysroot.as_str(); - let sysroot = sysroot.trim(); - +@@ -383,1 +389,5 @@ - let search_dirs = Command::new("cc").arg("--print-search-dirs").output().unwrap(); + let cc = env::var("CC").unwrap_or_else(|_| "cc".to_string()); + let search_dirs = Command::new(cc) + .arg("--print-search-dirs") + .output() + .unwrap(); -+ - let search_dirs = String::from_utf8_lossy(&search_dirs.stdout); From 27fd108f7840f0ea27a147a1a41186cdf88338c0 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 12:20:34 -0700 Subject: [PATCH 08/13] Add macOS framework path for WebRTC sys Teach the patched webrtc-sys build script to pass the hermetic SDK's framework directory to cc-rs when cross-compiling for macOS.\n\nCo-authored-by: Codex --- patches/webrtc-sys_hermetic_darwin_sysroot.patch | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/patches/webrtc-sys_hermetic_darwin_sysroot.patch b/patches/webrtc-sys_hermetic_darwin_sysroot.patch index 63acac97794..c2b1b2063c9 100644 --- a/patches/webrtc-sys_hermetic_darwin_sysroot.patch +++ b/patches/webrtc-sys_hermetic_darwin_sysroot.patch @@ -2,10 +2,13 @@ diff --git a/build.rs b/build.rs index 3b4a24a..e6fb056 100644 --- a/build.rs +++ b/build.rs -@@ -378,3 +378,9 @@ +@@ -378,6 +378,17 @@ - let sysroot = Command::new("xcrun").args(["--sdk", sdk, "--show-sdk-path"]).output().unwrap(); - - let sysroot = String::from_utf8_lossy(&sysroot.stdout); +- let sysroot = sysroot.trim(); +- +- let search_dirs = Command::new("cc").arg("--print-search-dirs").output().unwrap(); + let sysroot = env::var("WEBRTC_SYS_DARWIN_SDK_PATH").unwrap_or_else(|_| { + let output = Command::new("xcrun") + .args(["--sdk", sdk, "--show-sdk-path"]) @@ -15,8 +18,9 @@ index 3b4a24a..e6fb056 100644 + }); + + let sysroot = sysroot.as_str(); -@@ -383,1 +389,5 @@ -- let search_dirs = Command::new("cc").arg("--print-search-dirs").output().unwrap(); ++ let sysroot = sysroot.trim(); ++ builder.flag(format!("-F{sysroot}/System/Library/Frameworks")); ++ + let cc = env::var("CC").unwrap_or_else(|_| "cc".to_string()); + let search_dirs = Command::new(cc) + .arg("--print-search-dirs") From 1fc3029afda4380b95da8f43aad57cd42f0b8172 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 12:39:03 -0700 Subject: [PATCH 09/13] hi --- MODULE.bazel | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index e59855a3bd7..10ae96cffeb 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -42,6 +42,8 @@ osx.frameworks(names = [ "CoreGraphics", "CoreServices", "CoreText", + "CoreVideo", + "DiskArbitration", "AudioToolbox", "CFNetwork", "FontServices", From 8950b3d8cbff324bdc1454cd58f1454ebeaeaada Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 12:52:35 -0700 Subject: [PATCH 10/13] Expose WebRTC Apple frameworks to Bazel Co-authored-by: Codex --- MODULE.bazel | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index 10ae96cffeb..706f02b634f 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -40,11 +40,13 @@ osx.frameworks(names = [ "ColorSync", "CoreFoundation", "CoreGraphics", + "CoreMedia", "CoreServices", "CoreText", "CoreVideo", "DiskArbitration", "AudioToolbox", + "AVFoundation", "CFNetwork", "FontServices", "AudioUnit", @@ -52,11 +54,18 @@ osx.frameworks(names = [ "CoreAudioTypes", "Foundation", "ImageIO", + "IOSurface", "IOKit", "Kernel", + "Metal", + "MetalKit", + "OpenGL", "OSLog", + "QuartzCore", + "ScreenCaptureKit", "Security", "SystemConfiguration", + "VideoToolbox", ]) use_repo(osx, "macos_sdk") From af46e10c41bd2421e077f7eb83dd0aca5540e4ee Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 12:53:10 -0700 Subject: [PATCH 11/13] Add WebRTC link flags to cloud tasks Bazel target Co-authored-by: Codex --- codex-rs/cloud-tasks/BUILD.bazel | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codex-rs/cloud-tasks/BUILD.bazel b/codex-rs/cloud-tasks/BUILD.bazel index f6e8bfcc567..9beb5f87b02 100644 --- a/codex-rs/cloud-tasks/BUILD.bazel +++ b/codex-rs/cloud-tasks/BUILD.bazel @@ -1,6 +1,7 @@ -load("//:defs.bzl", "codex_rust_crate") +load("//:defs.bzl", "MACOS_WEBRTC_RUSTC_LINK_FLAGS", "codex_rust_crate") codex_rust_crate( name = "cloud-tasks", crate_name = "codex_cloud_tasks", + rustc_flags_extra = MACOS_WEBRTC_RUSTC_LINK_FLAGS, ) From 8a52ff911d813b419363118fc9febd89236fb605 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 12:57:52 -0700 Subject: [PATCH 12/13] Expose nested AVFAudio framework to Bazel Co-authored-by: Codex --- MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/MODULE.bazel b/MODULE.bazel index 706f02b634f..34654209999 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -47,6 +47,7 @@ osx.frameworks(names = [ "DiskArbitration", "AudioToolbox", "AVFoundation", + "AVFAudio", "CFNetwork", "FontServices", "AudioUnit", From a4df77a7f9997c9e6297edc140c836f864710ac7 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 8 Apr 2026 13:43:56 -0700 Subject: [PATCH 13/13] Fix WebRTC sys hermetic macOS SDK build Co-authored-by: Codex --- MODULE.bazel | 5 ++ defs.bzl | 2 + .../webrtc-sys_hermetic_darwin_sysroot.patch | 51 ++++++++++++++++++- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 34654209999..42875b40f0e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -40,7 +40,9 @@ osx.frameworks(names = [ "ColorSync", "CoreFoundation", "CoreGraphics", + "CoreImage", "CoreMedia", + "CoreMIDI", "CoreServices", "CoreText", "CoreVideo", @@ -48,6 +50,7 @@ osx.frameworks(names = [ "AudioToolbox", "AVFoundation", "AVFAudio", + "AVRouting", "CFNetwork", "FontServices", "AudioUnit", @@ -66,6 +69,7 @@ osx.frameworks(names = [ "ScreenCaptureKit", "Security", "SystemConfiguration", + "UniformTypeIdentifiers", "VideoToolbox", ]) use_repo(osx, "macos_sdk") @@ -364,6 +368,7 @@ crate.annotation( ], build_script_env = { "WEBRTC_SYS_DARWIN_SDK_PATH": "$(location @macos_sdk//sysroot)", + "WEBRTC_SYS_LINK_OUT_DIR": "1", }, crate = "webrtc-sys", gen_build_script = "on", diff --git a/defs.bzl b/defs.bzl index 7a50a308f41..6972b65a65c 100644 --- a/defs.bzl +++ b/defs.bzl @@ -37,6 +37,8 @@ MACOS_WEBRTC_RUSTC_LINK_FLAGS = select({ "@platforms//os:macos": [ "-C", "link-arg=-ObjC", + "-C", + "link-arg=-lc++", ], "//conditions:default": [], }) diff --git a/patches/webrtc-sys_hermetic_darwin_sysroot.patch b/patches/webrtc-sys_hermetic_darwin_sysroot.patch index c2b1b2063c9..c90edbd08e9 100644 --- a/patches/webrtc-sys_hermetic_darwin_sysroot.patch +++ b/patches/webrtc-sys_hermetic_darwin_sysroot.patch @@ -1,8 +1,51 @@ diff --git a/build.rs b/build.rs -index 3b4a24a..e6fb056 100644 +index 3b4a24a..6aa06ff 100644 --- a/build.rs +++ b/build.rs -@@ -378,6 +378,17 @@ +@@ -15,1 +15,2 @@ +-use std::path::Path; ++use std::fs; ++use std::path::Path; +@@ -118,1 +119,9 @@ +- println!("cargo:rustc-link-search=native={}", webrtc_lib.to_str().unwrap()); ++ let webrtc_link_lib = if env::var_os("WEBRTC_SYS_LINK_OUT_DIR").is_some() { ++ let out_lib = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("lib"); ++ fs::create_dir_all(&out_lib).unwrap(); ++ fs::copy(webrtc_lib.join("libwebrtc.a"), out_lib.join("libwebrtc.a")).unwrap(); ++ out_lib ++ } else { ++ webrtc_lib ++ }; ++ println!("cargo:rustc-link-search=native={}", webrtc_link_lib.to_str().unwrap()); +@@ -255,1 +264,1 @@ +- println!("cargo:rustc-link-lib=framework=Appkit"); ++ println!("cargo:rustc-link-lib=framework=AppKit"); +@@ -320,1 +329,18 @@ +- builder.warnings(false).compile("webrtcsys-cxx"); ++ builder.warnings(false).compile("webrtcsys-cxx"); ++ let cxxbridge_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("cxxbridge"); ++ let cxx_header = cxxbridge_dir.join("include/rust/cxx.h"); ++ if fs::symlink_metadata(&cxx_header) ++ .is_ok_and(|metadata| metadata.file_type().is_symlink()) ++ { ++ if let Ok(header) = fs::read(&cxx_header) { ++ fs::remove_file(&cxx_header).unwrap(); ++ fs::write(&cxx_header, header).unwrap(); ++ } ++ } ++ let crate_link = cxxbridge_dir.join("crate/webrtc-sys"); ++ if fs::symlink_metadata(&crate_link) ++ .is_ok_and(|metadata| metadata.file_type().is_symlink()) ++ { ++ fs::remove_file(crate_link).unwrap(); ++ } ++ +@@ -375,1 +384,3 @@ +- println!("cargo:rustc-link-lib={}", clang_rt); ++ if env::var_os("WEBRTC_SYS_LINK_OUT_DIR").is_none() { ++ println!("cargo:rustc-link-lib={}", clang_rt); ++ } +@@ -378,6 +389,21 @@ - let sysroot = Command::new("xcrun").args(["--sdk", sdk, "--show-sdk-path"]).output().unwrap(); - - let sysroot = String::from_utf8_lossy(&sysroot.stdout); @@ -20,6 +63,10 @@ index 3b4a24a..e6fb056 100644 + let sysroot = sysroot.as_str(); + let sysroot = sysroot.trim(); + builder.flag(format!("-F{sysroot}/System/Library/Frameworks")); ++ builder.define("__APPLICATIONSERVICES__", None); ++ builder.flag("-include"); ++ builder.flag("CoreGraphics/CoreGraphics.h"); ++ builder.include(format!("{sysroot}/usr/include")); + + let cc = env::var("CC").unwrap_or_else(|_| "cc".to_string()); + let search_dirs = Command::new(cc)