From 142de4c505db3f312cde39a5aa7d57e07cfdd972 Mon Sep 17 00:00:00 2001 From: UMCEKO Date: Sat, 2 May 2026 01:35:24 +0300 Subject: [PATCH 1/2] build: force `-fno-lto` for the bundled libopus build The bundled `libopus.a` is consumed by rustc (objects bundled into the rlib via cargo's `+bundle` modifier), not by a C linker, so C-level LTO gains nothing here. When ambient CFLAGS contain `-flto` (e.g. Arch's `makepkg` with `OPTIONS=(lto)`, Gentoo `LTOFLAGS`, distros enabling it by default), GCC produces "slim LTO" objects: empty `.text`, code only in `.gnu.lto_*` sections, marked with `__gnu_lto_slim`. rust-lld then links the rlib without an LTO plugin and reports `opus_decoder_create`, `opus_decoder_destroy`, and `opus_decode` as undefined. Repro on Arch with `makepkg`-set CFLAGS containing `-flto=auto`: rust-lld: error: undefined symbol: opus_decoder_destroy >>> referenced by symphonia_adapter_libopus... Append `-fno-lto` to the cmake C flags so libopus is always built with real native code regardless of inherited flags. gcc/clang honor the last `-flto*` argument, so this overrides any earlier `-flto`, and is a no-op for compilers that don't recognize it. --- build.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index d19667e..c837616 100644 --- a/build.rs +++ b/build.rs @@ -100,7 +100,19 @@ fn build() { .define("CMAKE_INSTALL_INCLUDEDIR", "include") .define("CMAKE_INSTALL_OLDINCLUDEDIR", "include") .define("CMAKE_INSTALL_LIBDIR", "lib") - .define("CMAKE_TRY_COMPILE_TARGET_TYPE", "STATIC_LIBRARY"); + .define("CMAKE_TRY_COMPILE_TARGET_TYPE", "STATIC_LIBRARY") + // The bundled libopus.a is consumed by rustc (bundled into the + // rlib), not the C link, so C-level LTO gains nothing here. If the + // ambient CFLAGS contain `-flto` (e.g. Arch's makepkg with + // `OPTIONS=(lto)`, Gentoo `LTOFLAGS`, distros enabling it by + // default), GCC produces slim LTO objects: empty `.text`, code only + // in `.gnu.lto_*` sections, marked with `__gnu_lto_slim`. rust-lld + // links the rlib without an LTO plugin and reports the opus_* + // symbols as undefined. Force LTO off here regardless of inherited + // flags. `-fno-lto` overrides any preceding `-flto*` (gcc/clang + // honor the last one) and is a no-op for compilers that don't + // recognize it. + .cflag("-fno-lto"); //Keep this up to date with Cargo.toml if cfg!(feature = "dred") { From b987ed02b03c485366e5213c5efbe84e574c55a8 Mon Sep 17 00:00:00 2001 From: UMCEKO Date: Sat, 2 May 2026 14:05:34 +0300 Subject: [PATCH 2/2] ci: include build.rs in path filters --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 242f57c..b307e3a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,6 +9,7 @@ on: - 'src/**.rs' - 'tests/**' - 'Cargo.toml' + - 'build.rs' - 'opus/**/*' pull_request: types: [opened, synchronize, reopened, ready_for_review] @@ -19,6 +20,7 @@ on: - 'src/**.rs' - 'tests/**' - 'Cargo.toml' + - 'build.rs' - 'opus/**/*' jobs: check: