Skip to content

Remove default link-time dependency on GLib#1144

Merged
ladvoc merged 1 commit into
livekit:mainfrom
gasmith:webrtc-glib-deps
Jun 12, 2026
Merged

Remove default link-time dependency on GLib#1144
ladvoc merged 1 commit into
livekit:mainfrom
gasmith:webrtc-glib-deps

Conversation

@gasmith

@gasmith gasmith commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Before you submit your PR

Make sure the following is true before submitting your PR:

  • I have read the contributing guidelines and validated that this PR will be accepted.
  • I have read and followed the principles regarding breaking changes, testing, and code quality.

PR Description

The webrtc-sys build script used pkg_config::probe_library for glib-2.0/gobject-2.0/gio-2.0, which emitted cargo:rustc-link-lib directives even though only the headers are required at build time. Switch to pkg_config::Config::new().cargo_metadata(false) so the include paths are still discovered but no link metadata is emitted.

Drop glib-main-loop from libwebrtc's default features and re-expose it as an opt-in passthrough on the top-level livekit crate. The screensharing example enables it explicitly. Note that the original change (ca86d4c) was somewhat broken on arrival, since it did not provide any way for a livekit consumer to opt out of the internal GLib main loop.

Fixes: #1129

Breaking changes

Consumers of livekit or libwebrtc that rely on Wayland screen sharing must now enable the glib-main-loop feature (if they do not have their own GLib main loop).

MSRV

No change.

Testing

Validated that a trivial crate that depends on livekit no longer pulls in glib as a dependency.

Built a cdylib on Linux aarch64 in a build environment where the linker does not use --as-needed (or it simply does not work as expected), and validated that the resulting binary does not include library dependencies on GLib. See the build artifacts from foxglove/foxglove-sdk#1292 (lib/libfoxglove.so).

The webrtc-sys build script used pkg_config::probe_library for
glib-2.0/gobject-2.0/gio-2.0, which emitted cargo:rustc-link-lib
directives even though only the headers are required at build time.
Switch to pkg_config::Config::new().cargo_metadata(false) so the
include paths are still discovered but no link metadata is emitted.

Drop glib-main-loop from libwebrtc's default features and re-expose
it as an opt-in passthrough on the top-level livekit crate. The
screensharing example enables it explicitly.

### Breaking changes

Consumers of `livekit` or `libwebrtc` that rely on Wayland screen
sharing must now enable the `glib-main-loop` feature (if they do not
have their own GLib main loop).

@cloudwebrtc cloudwebrtc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@ladvoc ladvoc merged commit 2540efe into livekit:main Jun 12, 2026
21 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

webrtc-sys: pkg_config::probe_library for glib/gobject/gio adds unused -l flags, leaks as DT_NEEDED in downstream binaries

3 participants