Skip to content
Open
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
10 changes: 6 additions & 4 deletions crates/wayle-idle-inhibit/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! Build script for wayle-idle-inhibit.
//!
//! this crate intentionally does not force link order for
//! libwayland-client. Binaries that also use `gtk4-layer-shell` must ensure
//! `gtk4-layer-shell` is linked before `wayland-client` so its interposition
//! works. Handle that in the final binary (via its build script).
//! libwayland-client is linked via `#[link(name = "wayland-client")]` on the
//! FFI extern block in `src/ffi.rs`, so it is always retained regardless of
//! linker `--as-needed` ordering, in every binary and test depending on this
//! crate. This build script therefore forces no link order. Binaries that also
//! use `gtk4-layer-shell` must still ensure it is linked before wayland-client
//! for its interposition to work; handle that in the final binary/shell.

fn main() {
println!("cargo:rerun-if-changed=build.rs");
Expand Down
8 changes: 8 additions & 0 deletions crates/wayle-idle-inhibit/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ mod sys {

use super::{WlInterface, WlProxy};

// Declare the library these symbols come from so rustc emits
// `-lwayland-client` adjacent to this crate's objects. This keeps it out of
// reach of the linker's `--as-needed` pruning (which can otherwise drop a
// `-lwayland-client` that appears before the code referencing it, depending
// on link ordering) and propagates the link requirement to every binary and
// test that depends on this crate. gtk4-layer-shell interposition ordering
// is still the final binary's concern (see the shell's build script).
#[link(name = "wayland-client")]
unsafe extern "C" {
pub fn wl_display_roundtrip(display: *mut super::WlDisplay) -> c_int;
pub fn wl_proxy_add_listener(
Expand Down
Loading