rust-sdks icon indicating copy to clipboard operation
rust-sdks copied to clipboard

build_linux.sh: add option to choose toolchain

Open Be-ing opened this issue 2 months ago • 13 comments

This adds a --toolchain CLI option to the script that can be either

  • gnu
  • llvm
  • chromium-llvm

The gnu and llvm options use the system's toolchain. chromium-llvm uses Chromium's prebuilt LLVM toolchain with its Debian sysroot.

Previously, the script tried to combine the system's gcc with libstdc++ from Chromium's Debian sysroot, which failed to find glibc headers:

[1/4184] CXX obj/third_party/abseil-cpp/absl/base/base/cycleclock.o FAILED: obj/third_party/abseil-cpp/absl/base/base/cycleclock.o g++ -MMD -MF obj/third_party/abseil-cpp/absl/base/base/cycleclock.o.d -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -D_GLIBCXX_ASSERTIONS=1 -DCR_SYSROOT_KEY=20250129T203412Z-1 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DABSL_ALLOCATOR_NOTHROW=1 -I.. -Igen -I../third_party/abseil-cpp -fno-strict-overflow -fno-ident -fno-strict-aliasing -fstack-protector -funwind-tables -fPIC -pipe -pthread -m64 -msse3 -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -O2 -fdata-sections -ffunction-sections -fno-math-errno -fno-omit-frame-pointer -g0 -fvisibility=hidden -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comments -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -std=gnu++2a -Wno-changes-meaning -fno-exceptions --sysroot=../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -Wno-narrowing -Wno-class-memaccess -Wno-invalid-offsetof  -c ../third_party/abseil-cpp/absl/base/internal/cycleclock.cc -o obj/third_party/abseil-cpp/absl/base/base/cycleclock.o In file included from /usr/include/c++/15/bits/version.h:51,
                 from /usr/include/c++/15/atomic:50,
                 from ../third_party/abseil-cpp/absl/base/internal/cycleclock.h:45,
                 from ../third_party/abseil-cpp/absl/base/internal/cycleclock.cc:23:
/usr/include/c++/15/x86_64-redhat-linux/bits/c++config.h:3:10: fatal error: bits/wordsize.h: No such file or directory
    3 | #include <bits/wordsize.h>
      |          ^~~~~~~~~~~~~~~~~

Be-ing avatar Oct 08 '25 22:10 Be-ing

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 08 '25 23:10 CLAassistant

Nice PR, @Be-ing do you have any results links for Actions? I can't seem to trigger an external branch workflow in our Actions. we need to verify that the compiled libwebrtc libs and ffi.so can be loaded correctly by python/node sdks in linux.

cloudwebrtc avatar Oct 13 '25 09:10 cloudwebrtc

I can't seem to trigger an external branch workflow in our Actions.

That may be because the action was set to trigger only on pushing a tag. For testing I added a commit changing that to run on any push. A successful build on my fork is here: https://github.com/Be-ing/rust-sdks/actions/runs/18477988272 When you decide this is ready to merge, I can rebase to remove that commit.

Be-ing avatar Oct 13 '25 21:10 Be-ing

FWIW I tested building with the gn option use_sysroot=true with host GNU and LLVM toolchains because I thought it might make more sense to add a --use-sysroot command line option for build-linux.sh than tie it to the --toolchain option. The GNU toolchain failed with the error in the commit message. The LLVM toolchain fails with:

+ ninja -C /home/be/sw/rust-sdks/webrtc-sys/libwebrtc/build-x64-release :default
ninja: Entering directory `/home/be/sw/rust-sdks/webrtc-sys/libwebrtc/build-x64-release'
[348/4198] LINK ./protoc-gen-js
FAILED: protoc-gen-js 
"vpython3" "../src/build/toolchain/gcc_link_wrapper.py" --output="./protoc-gen-js" -- /usr/lib64/ccache/clang++ -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=fast -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,--undefined-version -Wl,--no-call-graph-profile-sort -m64 -no-canonical-prefixes -Wl,--gc-sections -Wl,-z,defs -Wl,--as-needed -nostdlib++ --sysroot=../src/build/linux/debian_bullseye_amd64-sysroot -rdynamic -pie -Wl,--disable-new-dtags -o "./protoc-gen-js" -Wl,--start-group @"./protoc-gen-js.rsp" -Wl,--end-group   ../src/third_party/llvm-build/Release+Asserts/lib/clang/21/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a -ldl -lpthread -lrt -Wl,--start-group  -Wl,--end-group 
ld.lld: error: undefined reference: pthread_getspecific@GLIBC_2.34
>>> referenced by /lib64/libgcc_s.so.1 (disallowed by --no-allow-shlib-undefined)

ld.lld: error: undefined reference: pthread_key_create@GLIBC_2.34
>>> referenced by /lib64/libgcc_s.so.1 (disallowed by --no-allow-shlib-undefined)

ld.lld: error: undefined reference: _dl_find_object@GLIBC_2.35
>>> referenced by /lib64/libgcc_s.so.1 (disallowed by --no-allow-shlib-undefined)

ld.lld: error: undefined reference: pthread_once@GLIBC_2.34
>>> referenced by /lib64/libgcc_s.so.1 (disallowed by --no-allow-shlib-undefined)

ld.lld: error: undefined reference: pthread_setspecific@GLIBC_2.34
>>> referenced by /lib64/libgcc_s.so.1 (disallowed by --no-allow-shlib-undefined)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

I can only get use_sysroot=true to build on my machine (running Fedora 42) with the chromium-llvm toolchain. So tying use_sysroot to the --toolchain option seems best.

Be-ing avatar Oct 13 '25 21:10 Be-ing

hey @Be-ing, the issue seems to have returned to the original point. I used the build_linux.sh file from this PR, adding ./build_linux.sh --arch x64 --profile release --toolchain chromium-llvm to compile the linux-arm64-release. I then set:

rust-sdks # export LK_CUSTOM_WEBRTC=`pwd`/webrtc-sys/libwebrtc/linux-x64-release
rust-sdks # cd livekit-ffi && cargo build --release

I got the following error:

= note: /usr/bin/ld: skipping incompatible /home/duan/development/rust-sdks/webrtc-sys/libwebrtc/linux-x64-release/lib/libwebrtc.a when searching for -lwebrtc

06a758c4501ed0/out" "-L" "/home/duan/development/rust-sdks/target/release/build/soxr-sys-2d4bc72a8c734889/out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/duan/development/rust-sdks/target/release/deps/liblivekit_ffi.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-Wl,--strip-all" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: /usr/bin/ld: skipping incompatible /home/duan/development/rust-sdks/webrtc-sys/libwebrtc/linux-x64-release/lib/libwebrtc.a when searching for -lwebrtc
          /usr/bin/ld: cannot find -lwebrtc: No such file or directory
          /usr/bin/ld: have you installed the static version of the webrtc library ?
          collect2: error: ld returned 1 exit status

cloudwebrtc avatar Oct 14 '25 03:10 cloudwebrtc

Here are some key information, cargo build the ffi can only correctly link libraries in the elf64-x86-64 obj format

objdump info form g++ 14 compiled libwebrtc.a

# objdump -p gcc-linux-x64-release/lib/libwebrtc.a

...

ice_credentials_iterator.o:     file format elf64-x86-64


transport_description.o:     file format elf64-x86-64

and form chromium-llvm compiled libwebrtc.a

# objdump -p linux-x64-release/lib/libwebrtc.a

...
ice_credentials_iterator.o:     file format elf64-little


transport_description.o:     file format elf64-little

cloudwebrtc avatar Oct 14 '25 04:10 cloudwebrtc

Interesting, I have not seen that error before :thinking: What distro are you using?

I notice the error mentions /usr/bin/ld, which is probably the GNU linker. Rust no longer uses that by default, so I suspect you haven't updated your Rust toolchain in a while. Can you try linking with lld, mold, or wild? You can configure the linker by adding this section to ~/.config/cargo.toml

[target.aarch64-unknown-linux-gnu]
linker = "clang"
rustflags = [
    "-C", "link-arg=--ld-path=wild"
]

Does that error only occur with the chromium-llvm toolchain?

Be-ing avatar Oct 14 '25 05:10 Be-ing

Ah, I used GNU ld on x86-64 with a chromium-llvm built libwebrtc.a and reproduced the linker error running cargo build -p livekit-ffi. :weary: I've worked on another project using cxx and GNU ld failed with that in all kinds of strange ways. I'm glad it's no longer the default with Rust.

Be-ing avatar Oct 14 '25 05:10 Be-ing

Linking fails with GNU ld with a gcc-built libwebrtc.a as well :melting_face:

error: linking with `clang` failed: exit status: 1
  |
  = note:  "clang" "-Wl,--version-script=/tmp/rustc1rEJSb/list" "-Wl,--no-undefined-version" "-m64" "/tmp/rustc1rEJSb/symbols.o" "<257 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "-lwebrtc" "/home/be/sw/rust-sdks/target/debug/deps/{libsoxr_sys-3b1060156484242d,libenv_logger-e889999eedfb1394,libtermcolor-ae217a739aa95278,libis_terminal-05fcb2229c3ef67c,librustix-7db5450d241e3054,liblinux_raw_sys-8f3688b52b6c9d3f,libhumantime-d9a477c93c6d3b89,libregex-ab1cd6393b2f8d16,libregex_automata-bf40c5ddcf51b343,libaho_corasick-6a1811f7e6866819,libregex_syntax-6eb6a6d0ce6f03c8,libimgproc-e8a540f3d4750155,libyuv_sys-f327d49bdc6096de,libdowncast_rs-1a808245959ff1b1,libdashmap-dc2f760a2c6d2c78,libhashbrown-5b27c82112d5d37e,libprost-eddfe7d361cfe202,liblivekit-84c7cf42c7a60ed1,libsemver-e2dbdc919db7eb09,liblivekit_api-1b879489300296db,libsha2-8eeeeb9f9232fd84,libreqwest-23aa575380c09890,libserde_urlencoded-b1fa463111e40ed9,libhyper_rustls-ec557140bef57d47,librustls_native_certs-79324e0f730eaf94,librustls_pemfile-2c0b2db6779c2eaf,libtokio_rustls-243a5dbcb091db51,librustls-1f0072708ce8cf91,libsubtle-5e091a47b6d5ae4f,libwebpki-7576e008145d8e87,librustls_pki_types-8eddbdaaeb48c2fe,libzeroize-797fa9185ba2a04c,libtower_http-9525aa175956d61a,libbitflags-0c08b1afeaef909c,libiri_string-b20ea7799580795d,libtower-d4897f4121b3311f,libtower_layer-9509e29554bfee0a,libhyper_util-6c0decfdc7f8a835,libbase64-7f533940e913641b,libipnet-c86bf2b9f0bd926f,libtower_service-1498bc64a909ad15,libtracing-eb55b53ae9198a0d,libtracing_core-8738da29eb143bb4,libonce_cell-412d1e90b9aa8310,libhyper-2f78cb53263f8c93,libwant-aa1b7c11a6f0d257,libtry_lock-2f75916ca6056f9a,libfutures_channel-92152d129f23d3b4,libhttp_body_util-a9906efa82c6c405,libhttp_body-ff0439f19f375529,libsync_wrapper-43999db9f4d1f1b7,libtokio_tungstenite-dcd7238d907a99ac,librustls_native_certs-8e050a323e1cba0f,librustls_pemfile-6668e3bbfdc18638,libopenssl_probe-52e63a4c66c2ee6b,libtokio_rustls-dd94851298501969,libtungstenite-b884772a9824ff9f,libdata_encoding-5b4b01e1fa1baad7,librand-29bfafea3d3bef44,librand_chacha-04435c81e1e54586,librand_core-037e803a31b0c195,librustls-3e2f05ce1077c159,libsct-2bc765a99a7748b5,libwebpki-2fd7c356dfe666b3,libutf8-87dc9e2dd7a88151,libbyteorder-9b7ffac2ffc7a996,libsha1-cfa91355d5cad76b,libcpufeatures-c76a65f6e50e3059,libdigest-cf91f7b60a32079b,libblock_buffer-65a67908c68b0501,libcrypto_common-9abcc68955449734,libgeneric_array-3e99299ae9328ac0,libtypenum-1c4deec53aa88b57,libhttparse-340fc7ea42587a38,liburl-925f52f2985af779,libidna-599281f5b97a4f4e,libunicode_normalization-b67143c5bfa68313,libtinyvec-293ebe4778bc04bb,libtinyvec_macros-c76c16681523760b,libunicode_bidi-65183cc9cf5d4e79,libform_urlencoded-c10c62577cfe1430,libpercent_encoding-b9e3544214d77820,libhttp-8d65ca4491cf4ff2,librand-fdd7358cb8c80a3f,librand_chacha-7a99296438cbbcde,libppv_lite86-18ad05721333f2fc,librand_core-b5342255ebc65bc7,libgetrandom-2bda84b79ceaa2ef,libzerocopy-1499dc5effc503fc,libhttp-263da255e8d04090,libfnv-96b60e3f2c7c6181,libjsonwebtoken-07a6ebea981beba9,libring-48273171f8ed7793,libgetrandom-1543a25ab9a12b56,libspin-7a538c22313f304a,libuntrusted-342b97918ed22099,libbmrng-1fbb0a084aaf9ace,liblibwebrtc-d0b5274bb35a1fca,libserde_json-100f8bb86c29106d,libryu-15cf0f29a31b65f4,libitoa-69bb86c817c47245,liblog-820479d1617cbb89,liblivekit_protocol-203ab9c75dee0e1a,libpbjson_types-6b4c6948fdb1ab84,libpbjson-92a2f2864df5df1c,libbase64-b7ab379526b01c6b,libchrono-d8769bd9708ba884,libnum_traits-c260a608700b6c46,libiana_time_zone-1c634e8930807fbe,libserde-5334e0bc901b671b,libserde_core-495fdf623c11a715,libprost-1e913b87256e8288,liblivekit_runtime-fd44436ce8ca43bc,libtokio_stream-8e502f433492f593,libtokio-4aff51bf599cb497,libsignal_hook_registry-860f5b2b12b15fa4,libsocket2-9f71f5cb4395efcd,libbytes-97bfd1eebf784336,libmio-be5d37919b3682e0,libparking_lot-2305901110c4796b,libparking_lot_core-106925e494550b55,libthread_id-44248c5372b63c52,libpetgraph-2fb8b26c5b0ed3e3,libindexmap-764c95365ef09e3b,libequivalent-db500b950376db5a,libhashbrown-85a3702f0a6d327e,libfixedbitset-fa3de3418f072aa6,libbacktrace-a739865664fc6a1a,libminiz_oxide-672c92a5d28cbb0d,libadler-b9bf456b0bcc66af,libobject-2b252694ec6f099c,libmemchr-427c431f3e708351,liblibc-2eac2cc3d82d81d4,libaddr2line-e5656136b6f529a7,libgimli-fbe4e3d051ef29c1,librustc_demangle-4772612697fc0319,libsmallvec-e16c991b59fbb220,liblock_api-96ae7290729d5d41,libscopeguard-a8c2fd109e4a17e0,libwebrtc_sys-4f794dfeb7622b7b,libcxx-5ae313d0f4f1456c,libfoldhash-560d7142643007ca,liblink_cplusplus-ea04b486a436f71a,libthiserror-b6c517b5c7f2c3bb,liblibloading-2dbff795db235a44,libcfg_if-cc2087599ea52af9,libfutures_util-9956b72f784c2b58,libslab-4b58037ec73c3b88,libpin_project_lite-9164271deaa22993,libfutures_sink-7ce70f237a914f15,libfutures_task-073518e06a893e22,libpin_utils-9c592db860bfcea8,libfutures_core-f709dd7d9baf3db9,liblazy_static-4d19625ac923b645}.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lm" "-lrt" "-ldl" "-lpthread" "-lm" "-lstdc++" "-ldl" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustc1rEJSb/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/be/sw/rust-sdks/target/debug/build/yuv-sys-a8f610199d4a4fbc/out" "-L" "/home/be/sw/rust-sdks/target/debug/build/cxx-c0f5a714b86b13e9/out" "-L" "/home/be/sw/rust-sdks/target/debug/build/link-cplusplus-22dff08d9db7e7fe/out" "-L" "/home/be/sw/rust-sdks/target/debug/build/webrtc-sys-0eacd8939395a015/out" "-L" "/home/be/sw/rust-sdks/target/debug/build/ring-ed27242d90492bc9/out" "-L" "/home/be/sw/rust-sdks/target/debug/build/soxr-sys-48b9e7ca7299e4c8/out" "-L" "/home/be/sw/rust-sdks/webrtc-sys/libwebrtc/gnu-linux-x64-release/lib" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/be/sw/rust-sdks/target/debug/deps/liblivekit_ffi.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "--ld-path=ld"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(path.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(functional.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(new_helpers.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdexcept.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(string.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(verbose_abort.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(new.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_exception.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_personality.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_handlers.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(fallback_malloc.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdlib_exception.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(private_typeinfo.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdlib_typeinfo.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_guard.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdlib_stdexcept.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(abort_message.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_aux_runtime.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_default_handlers.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_exception_storage.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: unknown architecture of input file `/home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_virtual.o)' is incompatible with i386:x86-64 output
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(path.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(functional.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(new_helpers.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdexcept.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(string.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(verbose_abort.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(new.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_exception.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_personality.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_handlers.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(fallback_malloc.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdlib_exception.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(private_typeinfo.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdlib_typeinfo.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_guard.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdlib_stdexcept.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(abort_message.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_aux_runtime.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_default_handlers.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_exception_storage.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_virtual.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(path.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(functional.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(new_helpers.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdexcept.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(string.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(verbose_abort.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(new.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_exception.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_personality.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_handlers.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(fallback_malloc.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdlib_exception.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(private_typeinfo.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdlib_typeinfo.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_guard.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(stdlib_stdexcept.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(abort_message.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_aux_runtime.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_default_handlers.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_exception_storage.o)(.eh_frame); no .eh_frame_hdr table will be created
          /usr/bin/ld: error in /home/be/sw/rust-sdks/target/debug/deps/libwebrtc_sys-4f794dfeb7622b7b.rlib(cxa_virtual.o)(.eh_frame); no .eh_frame_hdr table will be created
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

warning: `livekit-ffi` (lib) generated 22 warnings
error: could not compile `livekit-ffi` (lib) due to 1 previous error; 22 warnings emitted

Be-ing avatar Oct 14 '25 05:10 Be-ing

I could put some hacks in build.rs to use lld, mold, and wild in preference to GNU ld. That doesn't seem necessary though now that Rust ships and uses lld by default.

Be-ing avatar Oct 14 '25 06:10 Be-ing

Interesting, I have not seen that error before 🤔 What distro are you using?

I can reproduce these issues on Ubuntu 24.04/x64. It's worth noting that the libwebrtc built by llvm with libwebrtc m125 can link correctly. However, we recently upgraded libwebrtc to m137. It's clear that the llvm-build toolchain used by libwebrtc has been upgraded, resulting in the new lib/obj format being incompatible with the Rust toolchain, leading to these new issues.

cloudwebrtc avatar Oct 14 '25 06:10 cloudwebrtc

@cloudwebrtc Are you able to link with another linker?

Be-ing avatar Oct 17 '25 15:10 Be-ing

I am now doubting that there is any use case for the use_sysroot=true gn option for us. At first I thought it might be helpful for linking against an old glibc in the Debian sysroot, but that's not actually helpful because the Rust toolchain links the final executable or shared library. It makes sense for Chromium because Chromium is the final executable. So for libc compatibility, it matters what Rust links to (via the libc crate), rather than what libwebrtc.a was built with.

Be-ing avatar Oct 20 '25 03:10 Be-ing