Skip to content

Enable Rust plugins on Android

amyspark requested to merge amyspark/cerbero:wip-nirbheek into main

Hi all,

In !1191 (merged) (commit 643087f3), the removal of GCC support relied on making the Android compiler available to all processes. This fixed accessing the host's compiler for Meson based builds like fribidi's, and also allowed OpenSSL to build, but there was a hidden side effect: it broke Rust's ability to compile build scripts because the linker it finds (LLVM 14 from the NDK) no longer supports --no-add-needed (1, 2).

Example log (source)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/builds/amyspark/cerbero/cerbero-build/rust/cargo/bin:/builds/amyspark/cerbero/cerbero-build/build-tools/bin:/builds/amyspark/cerbero/cerbero-build/android-ndk-25/toolchains/llvm/prebuilt/linux-x86_64/bin:/builds/amyspark/cerbero/cerbero-build/android-ndk-25/shader-tools/linux-x86_64:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcUNZ6Ix/symbols.o" "/builds/amyspark/cerbero/cerbero-build/sources/android_universal/armv7/gst-plugins-rs-0.12.0/_builddir/release/build/serde-c837ac022ee76594/build_script_build-c837ac022ee76594.build_script_build.f81ec550fb80d3e0-cgu.0.rcgu.o" "/builds/amyspark/cerbero/cerbero-build/sources/android_universal/armv7/gst-plugins-rs-0.12.0/_builddir/release/build/serde-c837ac022ee76594/build_script_build-c837ac022ee76594.5cffrxap1lhw84mk.rcgu.o" "-Wl,--as-needed" "-L" "/builds/amyspark/cerbero/cerbero-build/sources/android_universal/armv7/gst-plugins-rs-0.12.0/_builddir/release/deps" "-L" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-a57e2388c0aea9b1.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-dcd9be90ae2cb505.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-516789932d161b4e.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-1ff34b0cf871cb60.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-0c110dd0650d6cb7.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-a6e97aae2681ad8f.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-b93dac2525ec4d1e.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-ce1d65fb391ae98b.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-8933a2fb54d88492.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-306712ebb1ee1a3f.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-349c574f342b0d30.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-65c422a3ad95273d.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-7e6330a6c0cb9441.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-39c59240bfdfab27.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-e9d126c51bb8b2bb.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-5af394d9b1f07bdc.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-693a8f23970c5917.rlib" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-13fc9d1ed9c7a2bc.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/builds/amyspark/cerbero/cerbero-build/sources/android_universal/armv7/gst-plugins-rs-0.12.0/_builddir/release/build/serde-c837ac022ee76594/build_script_build-c837ac022ee76594" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,--strip-debug" "-nodefaultlibs"
  = note: ld: error: unknown argument '--no-add-needed'
          collect2: error: ld returned 1 exit status
          
error: could not compile `serde` (build script) due to 1 previous error
Caused by:
  process didn't exit successfully: `/builds/amyspark/cerbero/cerbero-build/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name build_script_build --edition=2018 /builds/amyspark/cerbero/cerbero-sources/gst-plugins-rs/cargo-vendor/serde/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="serde_derive"' --cfg 'feature="std"' -C metadata=c837ac022ee76594 -C extra-filename=-c837ac022ee76594 --out-dir /builds/amyspark/cerbero/cerbero-build/sources/android_universal/armv7/gst-plugins-rs-0.12.0/_builddir/release/build/serde-c837ac022ee76594 -C strip=debuginfo -L dependency=/builds/amyspark/cerbero/cerbero-build/sources/android_universal/armv7/gst-plugins-rs-0.12.0/_builddir/release/deps --cap-lints allow` (exit status: 1)
warning: build failed, waiting for other jobs to finish...

A more Meson-ese fix is to pass the toolchain as a constant in the native file, and fill the path in manually. This also needs to be injected manually into the PATH for OpenSSL as that's how its configure script consumes the toolchain.

Fixing this issue finally lets us enable the Rust plugins for Android without errors.

cc @nirbheek @slomo

Merge request reports

Loading