Repository: wezterm/wezterm (language: rust)

Issue:
wgpu depends upon wayland even when building wezterm without the wayland feature
When doing `cargo build --release --no-default-features --features vendored-fonts` I get an error building `wayland-sys`, which shouldn't happen.

I am seeing this issue on the current git main 9ddca7bde92090792dbcdc65c1e9897c362196d7.

I have tested the last public release 20240203-110809-5046fc22 and I am able to build from source just fine.

Based on some crude `git bisect`ing, it looks like the issue appeared around 09ac8c53777ac6de61b757292f5dc4da80322bbd.

24702de74a958460e3b9af3fbf21327b7ba4a3e3 is the last version I can build currently.

## Build Environment (please complete the following information):

 - OS: Linux X11
 - Linux: `Linux name 6.10.13-304.current #1 SMP PREEMPT_DYNAMIC 2024-10-06 x86_64 GNU/Linux`
 - Compiler: clang 18.1.8 (not sure if this is what you were looking for)
 - Rust version: 1.79

```
LSB Version:    1.4
Distributor ID: Solus
Description:    Solus
Release:        4.6
Codename:       convergence
```

```
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/user/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu
1.79.0-x86_64-unknown-linux-gnu (default)

active toolchain
----------------

1.79.0-x86_64-unknown-linux-gnu (default)
rustc 1.79.0 (129f3b996 2024-06-10)
```

## Dependencies

Did you run the `get-deps` script to install required system dependencies? yes
Was it successful? yes

If building from the git repo, did you update the submodules?  yes

## The build output

```sh
git submodule update --init --recursive
cargo clean
cargo build --release --no-default-features --features vendored-fonts
```

```
error: failed to run custom build command for `wayland-sys v0.31.5`

Caused by:
  process didn't exit successfully: `/home/user/Source/Clones/wezterm/target/debug/build/wayland-sys-54d8d2a2b5738154/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=WAYLAND_CLIENT_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=WAYLAND_CLIENT_STATIC
  cargo:rerun-if-env-changed=WAYLAND_CLIENT_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wayland-sys-0.31.5/build.rs:10:47:
  called `Result::unwrap()` on an `Err` value:
  pkg-config exited with status code 1
  > PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags wayland-client

  The system library `wayland-client` required by crate `wayland-sys` was not found.
  The file `wayland-client.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  The PKG_CONFIG_PATH environment variable is not set.

  HINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing `wayland-client.pc`.

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
```

seems unrelated to this Nix issue: https://github.com/wez/wezterm/issues/5367


Discussion / hints:
You need to install some wayland client lib, see your error log. On other distros this is probably included in the get-deps script file.
```
The system library `wayland-client` required by crate `wayland-sys` was not found.
  The file `wayland-client.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  The PKG_CONFIG_PATH environment variable is not set.
```
I'm not using Wayland and no part of it is installed. `--no-default-features` is documented as disabling Wayland support. Prior to 09ac8c53777ac6de61b757292f5dc4da80322bbd it was possible to fully disable Wayland. But it doesn't seem to fully do that anymore.
I think you will need to find out how to relay/interpret the feature selection down to the wgpu crate (by looking at its available set of features) to tell it not to import the wayland client libraries if you want to build wezterm without them.
I don't think it's `wgpu`, I don't see a hard dependency on anything Wayland there. It's `wayland-backend`, which has the `wayland-sys` dependency.

https://github.com/wez/wezterm/commit/09ac8c53777ac6de61b757292f5dc4da80322bbd#diff-8b7cc7bbcc91b1d0b3bb4323aeab9b4999f5e6a78a5d6d62183c28c44e8601bfR85

I have a fix for this I just tested, will submit a PR soon.


Fix patch:
diff --git a/window/Cargo.toml b/window/Cargo.toml
index 2ad3ac6b4c2..06f32a49902 100644
--- a/window/Cargo.toml
+++ b/window/Cargo.toml
@@ -15,7 +15,7 @@ k9 = "0.12.0"
 gl_generator = "0.14"
 
 [features]
-wayland = ["wayland-client", "smithay-client-toolkit", "wayland-egl", "wayland-protocols"]
+wayland = ["wayland-client", "smithay-client-toolkit", "wayland-egl", "wayland-protocols", "wayland-backend"]
 
 [dependencies]
 async-channel = "2.3"
@@ -82,7 +82,7 @@ zbus = "4.2"
 zvariant = "4.0"
 
 smithay-client-toolkit = {version = "0.19", default-features=false, optional=true}
-wayland-backend = {version="0.3.5", features=["client_system", "rwh_06"]}
+wayland-backend = {version="0.3.5", features=["client_system", "rwh_06"], optional=true}
 wayland-protocols = {version="0.32", optional=true}
 wayland-client = {version="0.31", optional=true}
 wayland-egl = {version="0.32", optional=true}


Test patch: