Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions crates/voxctrl-inference/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ whisper-rs = { version = "0.16" }
[dev-dependencies]
tempfile = { workspace = true }

# Used by build.rs to compile the glibc __isoc23_* shim for the Moonshine
# backend on Linux. `cc` is already in the build graph (whisper-rs-sys), so this
# adds nothing to compile.
[build-dependencies]
cc = "1"

[features]
default = []
cuda = ["whisper-rs/cuda"]
Expand Down
20 changes: 20 additions & 0 deletions crates/voxctrl-inference/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
fn main() {
// The Moonshine backend statically links a prebuilt ONNX Runtime (via
// `ort` + `download-binaries`) that is built against glibc >= 2.38 and so
// references __isoc23_strtol/strtoll/... symbols. Linking that archive on an
// older-glibc host (our ubuntu-22.04 release runners ship glibc 2.35) fails
// with "undefined symbol". Compile and link a tiny shim that provides those
// symbols by forwarding to the classic libc functions, keeping the binary
// linkable and runnable on older glibc. Linux + `moonshine` feature only.
let moonshine = std::env::var_os("CARGO_FEATURE_MOONSHINE").is_some();
let linux = std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("linux");

println!("cargo:rerun-if-changed=src/isoc23_compat.c");
println!("cargo:rerun-if-changed=build.rs");

if moonshine && linux {
cc::Build::new()
.file("src/isoc23_compat.c")
.compile("voxctrl_isoc23_compat");
}
}
45 changes: 45 additions & 0 deletions crates/voxctrl-inference/src/isoc23_compat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* glibc __isoc23_* compatibility shims for the Moonshine backend.
*
* The prebuilt ONNX Runtime static library (pyke, pulled in by `ort` with
* `download-binaries`) is compiled against glibc >= 2.38. Under C23, glibc
* redirects strtol/strtoul/... to __isoc23_* symbols, so the static archive
* references e.g. __isoc23_strtol. Our release runners are ubuntu-22.04
* (glibc 2.35), which has no such symbols, and the static link fails with
* "undefined symbol: __isoc23_strtol".
*
* These forwarders provide the symbols by calling the classic libc functions,
* so the binary links and runs on older glibc while keeping the AppImage's low
* glibc floor. The only C23 difference is that base 0 also accepts a "0b"
* binary prefix; ONNX Runtime's integer config parsing does not depend on that,
* so forwarding to the classic functions is safe.
*
* Compiled and linked only for the `moonshine` feature on Linux (see build.rs).
*/

#include <stdlib.h>
#include <inttypes.h>

long __isoc23_strtol(const char *nptr, char **endptr, int base) {
return strtol(nptr, endptr, base);
}

long long __isoc23_strtoll(const char *nptr, char **endptr, int base) {
return strtoll(nptr, endptr, base);
}

unsigned long __isoc23_strtoul(const char *nptr, char **endptr, int base) {
return strtoul(nptr, endptr, base);
}

unsigned long long __isoc23_strtoull(const char *nptr, char **endptr, int base) {
return strtoull(nptr, endptr, base);
}

intmax_t __isoc23_strtoimax(const char *nptr, char **endptr, int base) {
return strtoimax(nptr, endptr, base);
}

uintmax_t __isoc23_strtoumax(const char *nptr, char **endptr, int base) {
return strtoumax(nptr, endptr, base);
}
Loading