mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Bundle Linux voice runtimes and improve audio reliability (#44714)
## Why Linux voice needs system ALSA plugins and enough buffering to accommodate PipeWire graph cycles without losing capture samples. Voice startup failures also need actionable diagnostics without exposing native error details. ## What changed - Build and bundle GNU voice helpers and runtimes with primary Linux musl release archives, and sign the archives. Keep Python wheels free of these libraries to preserve `manylinux_2_17` compatibility. - Discover ALSA plugins in fixed system directories and increase Linux capture and playback buffering to support larger PipeWire graph cycles. - Report voice failures by stage, preserve negotiation timeout classification, and discard native error sources. Suppress the misleading `requested` closure message after failure cleanup. - Add explicit Windows MSVC, pkgconf, and CMake toolchain configuration and preserve host architecture in native build environments. ## Testing Add coverage for Linux release assembly, ALSA plugin discovery, PipeWire capture and playback, classified startup failures, failure cleanup rendering, and Windows build environment handling. GitOrigin-RevId: d805eace96a669ce3a4489f12e2db6f68f9f7f53
This commit is contained in:
committed by
copyberry
parent
08e49689b8
commit
da20788df9
Vendored
+24
@@ -133,6 +133,30 @@ alias(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
# Explicitly select the installed pkgconf and pinned CMake in Windows voice CI.
|
||||
native_tool_toolchain(
|
||||
name = "windows_pkg_config_tool",
|
||||
env = {"PKG_CONFIG": "$(execpath :pkg_config)"},
|
||||
path = "$(execpath :pkg_config)",
|
||||
target = ":pkg_config",
|
||||
)
|
||||
|
||||
toolchain(
|
||||
name = "windows_pkg_config_toolchain",
|
||||
exec_compatible_with = ["@platforms//os:windows"],
|
||||
toolchain = ":windows_pkg_config_tool",
|
||||
toolchain_type = "@rules_foreign_cc//toolchains:pkgconfig_toolchain",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
toolchain(
|
||||
name = "windows_cmake_toolchain",
|
||||
exec_compatible_with = ["@platforms//os:windows"],
|
||||
toolchain = "@cmake-3.31.8-windows-x86_64//:cmake_tool",
|
||||
toolchain_type = "@rules_foreign_cc//toolchains:cmake_toolchain",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "archives",
|
||||
srcs = [
|
||||
|
||||
Vendored
+4
-4
@@ -1,6 +1,6 @@
|
||||
# Native voice libraries in Codex releases
|
||||
|
||||
The macOS Codex release package includes dynamically linked GStreamer and GLib
|
||||
Codex release packages with voice include dynamically linked GStreamer and GLib
|
||||
libraries and selected plugins, plus their native library dependencies. These
|
||||
components have their own copyrights and licenses. Their notices accompany
|
||||
this file in `licenses/`: `LGPL-2.1.txt` for GStreamer and GLib,
|
||||
@@ -12,6 +12,6 @@ The exact upstream versions, source archive URLs and SHA-256 digests are in
|
||||
projection and package scripts are in the public Codex source tree under
|
||||
`third_party/voice/`. The source commit for this package is recorded in
|
||||
`manifest.json`. The native libraries remain separate dynamic libraries in
|
||||
`lib/` and `plugins/`; replacing them requires compatible binaries and valid
|
||||
macOS code signatures. Build tools listed in `sources.json` are build inputs,
|
||||
not bundled runtime libraries.
|
||||
platform-specific runtime directories. Replacements must be compatible with
|
||||
the package and, on macOS, have valid code signatures. Build tools listed in
|
||||
`sources.json` are build inputs, not bundled runtime libraries.
|
||||
|
||||
Vendored
+4
-1
@@ -258,11 +258,14 @@ The module does not download that installed tree or accept compiler licenses.
|
||||
After provisioning, a native PowerShell invocation is:
|
||||
|
||||
```powershell
|
||||
$hostArch = $env:PROCESSOR_ARCHITEW6432
|
||||
if (-not $hostArch) { $hostArch = $env:PROCESSOR_ARCHITECTURE }
|
||||
bazel build //third_party/voice:native_link_windows_x86_64 `
|
||||
--platforms=//:local_windows_msvc `
|
||||
--inject_repository="voice_windows_tools=$env:VOICE_WINDOWS_BAZEL_REPOSITORY" `
|
||||
--//third_party/voice:windows_installed_tools=@voice_windows_tools//:tools `
|
||||
--action_env="SystemRoot=$env:SystemRoot" --host_action_env="SystemRoot=$env:SystemRoot"
|
||||
--action_env="SystemRoot=$env:SystemRoot" --host_action_env="SystemRoot=$env:SystemRoot" `
|
||||
--action_env="PROCESSOR_ARCHITECTURE=$hostArch" --host_action_env="PROCESSOR_ARCHITECTURE=$hostArch"
|
||||
```
|
||||
|
||||
Use `native_link_windows_aarch64` on native ARM64 Windows. Existing MSVC license
|
||||
|
||||
Vendored
+6
-2
@@ -64,9 +64,13 @@ def main():
|
||||
environment, _ = build_environment(
|
||||
document, inputs["target"], {"python": Path(sys.executable)}
|
||||
)
|
||||
# Keep executor scratch directories, never its developer tool search path.
|
||||
# Keep host identity and scratch directories, never developer tool search paths.
|
||||
environment.update(
|
||||
{name: os.environ[name] for name in ("TMP", "TEMP") if name in os.environ}
|
||||
{
|
||||
name: os.environ[name]
|
||||
for name in ("TMP", "TEMP", "PROCESSOR_ARCHITECTURE")
|
||||
if name in os.environ
|
||||
}
|
||||
)
|
||||
home = temporary / "home"
|
||||
home.mkdir()
|
||||
|
||||
Vendored
+8
-3
@@ -1,4 +1,4 @@
|
||||
"""Stage verified macOS voice libraries and seal their post-signing release receipt."""
|
||||
"""Stage verified voice libraries and seal their public-release receipt."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
@@ -10,8 +10,13 @@ from runtime import digest
|
||||
|
||||
|
||||
def stage(source: Path, destination: Path, target: str) -> None:
|
||||
if target not in {"aarch64-apple-darwin", "x86_64-apple-darwin"}:
|
||||
raise ValueError("public voice runtime requires a macOS target")
|
||||
if target not in {
|
||||
"aarch64-apple-darwin",
|
||||
"x86_64-apple-darwin",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
}:
|
||||
raise ValueError("unsupported public release voice runtime target")
|
||||
source = source.resolve(strict=True)
|
||||
files = runtime_files(source, target)
|
||||
destination.mkdir()
|
||||
|
||||
+32
@@ -276,6 +276,38 @@ class AssembleTests(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(manifest["appVersion"], version)
|
||||
|
||||
def test_linux_release_pairs_musl_app_with_gnu_voice_runtime(self):
|
||||
self.commit = "b" * 40
|
||||
target = "aarch64-unknown-linux-gnu"
|
||||
runtime, _ = self.make_runtime(target)
|
||||
staged = self.root / "staged"
|
||||
stage(runtime, staged, target)
|
||||
seal(staged, target)
|
||||
for version in ("0.154.0-alpha.8", "0.154.0-beta.2", "0.154.0"):
|
||||
with self.subTest(version=version):
|
||||
self.metadata["version"] = version
|
||||
(self.package / "codex-package.json").write_text(
|
||||
json.dumps(self.metadata)
|
||||
)
|
||||
output = self.root / f"linux-{version}"
|
||||
assemble(
|
||||
self.package,
|
||||
self.helper,
|
||||
target,
|
||||
self.commit,
|
||||
output,
|
||||
runtime=staged,
|
||||
release_version=version,
|
||||
)
|
||||
voice = output / "codex-resources/voice"
|
||||
manifest = json.loads((voice / "manifest.json").read_text())
|
||||
self.assertEqual(manifest["appTarget"], "aarch64-unknown-linux-musl")
|
||||
self.assertEqual(manifest["voiceTarget"], target)
|
||||
self.assertEqual(
|
||||
manifest["sha256"]["codex-resources/voice/runtime.json"],
|
||||
digest(staged / "runtime.json"),
|
||||
)
|
||||
|
||||
def test_rejects_invalid_runtime_receipts_before_creating_package(self):
|
||||
runtime, original = self.make_runtime()
|
||||
changes = [
|
||||
|
||||
+43
@@ -5,13 +5,56 @@ import errno
|
||||
import json
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
from types import SimpleNamespace
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import bazel_windows
|
||||
|
||||
from bazel_copy import copy_payloads
|
||||
from bazel_windows import selected_inputs
|
||||
|
||||
|
||||
class WindowsInputsTests(unittest.TestCase):
|
||||
def test_adapter_preserves_host_architecture_without_developer_path(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
config = Path(directory) / "action.json"
|
||||
config.write_text("{}")
|
||||
for architecture in ("AMD64", "ARM64"):
|
||||
environment = {"PROCESSOR_ARCHITECTURE": architecture, "PATH": "unsafe"}
|
||||
with (
|
||||
self.subTest(architecture=architecture),
|
||||
patch.object(
|
||||
bazel_windows, "os", SimpleNamespace(environ=environment)
|
||||
),
|
||||
patch.object(
|
||||
bazel_windows.sys, "argv", ["driver", "unknown", str(config)]
|
||||
),
|
||||
patch.object(
|
||||
bazel_windows,
|
||||
"selected_inputs",
|
||||
return_value={"target": "unused"},
|
||||
),
|
||||
patch.object(
|
||||
bazel_windows,
|
||||
"build_environment",
|
||||
return_value=({"PATH": "declared"}, {}),
|
||||
),
|
||||
):
|
||||
with self.assertRaisesRegex(
|
||||
ValueError, "unknown Windows native action"
|
||||
):
|
||||
bazel_windows.main()
|
||||
self.assertEqual(
|
||||
environment,
|
||||
{
|
||||
"PROCESSOR_ARCHITECTURE": architecture,
|
||||
"PATH": "declared",
|
||||
"HOME": environment["HOME"],
|
||||
"USERPROFILE": environment["HOME"],
|
||||
},
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
temporary = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temporary.cleanup)
|
||||
|
||||
Vendored
+8
-1
@@ -25,6 +25,9 @@ def _windows_tools_impl(ctx):
|
||||
system_root = ctx.configuration.default_shell_env.get("SystemRoot")
|
||||
if not system_root:
|
||||
fail("Pass --action_env=SystemRoot=<actual Windows directory> as a fixed value")
|
||||
host_architecture = ctx.configuration.default_shell_env.get("PROCESSOR_ARCHITECTURE")
|
||||
if not host_architecture:
|
||||
fail("Pass --action_env=PROCESSOR_ARCHITECTURE=<actual host architecture> as a fixed value")
|
||||
msvc = ctx.attr.msvc[DirectoryInfo]
|
||||
sdk = ctx.attr.sdk[DirectoryInfo]
|
||||
tools = {
|
||||
@@ -68,7 +71,11 @@ def _windows_tools_impl(ctx):
|
||||
python = python,
|
||||
manifest = manifests[0],
|
||||
installed_files = installed,
|
||||
environment = {"SystemRoot": system_root, "SYSTEMROOT": system_root},
|
||||
environment = {
|
||||
"SystemRoot": system_root,
|
||||
"SYSTEMROOT": system_root,
|
||||
"PROCESSOR_ARCHITECTURE": host_architecture,
|
||||
},
|
||||
inputs = {
|
||||
"schemaVersion": 1,
|
||||
"target": ctx.attr.target,
|
||||
|
||||
Reference in New Issue
Block a user