Wezterm: Build with vendored dependencies fails

Created on 22 Nov 2020  路  4Comments  路  Source: wez/wezterm

I'm trying to package wezterm for NixOS and am experiencing build issues with vendored dependencies and native library links. I tried to resolve it but to no avail so far. Before spending more time on this issue I'd like some feedback where others think the issue originates. Since the build works without vendoring dependencies, it might be a bug in cargo vendoras well.

Build Environment (please complete the following information):

  • OS: Linux 5.8.17 NixOS
  • Compiler: gcc-9.3
  • Rust version: rustc 1.48.0

Dependencies

Did you run the get-deps script to install required system dependencies?
Was it successful? No, because it doesn't support NixOS

If building from the git repo, did you update the submodules? Yes

The build output

I used this command to test local changes:

(
  set -e
  git checkout .cargo/config 
  cargo vendor >> .cargo/config
  cargo build --release
)

yielding

error: failed to select a version for `servo-fontconfig-sys`.
    ... required by package `servo-fontconfig v0.4.0`
    ... which is depended on by `font-loader v0.8.0`
    ... which is depended on by `wezterm-font v0.1.0 (/home/steveej/src/others/wezterm/wezterm-font)`
    ... which is depended on by `wezterm-gui v0.1.0 (/home/steveej/src/others/wezterm/wezterm-gui)`
versions that meet the requirements `=4.0.6` are: 4.0.6

the package `servo-fontconfig-sys` links to the native library `fontconfig`, but it conflicts with a previous package which links to `fontconfig` as well:
package `fontconfig v0.1.0 (/home/steveej/src/others/wezterm/deps/fontconfig)`
    ... which is depended on by `wezterm-font v0.1.0 (/home/steveej/src/others/wezterm/wezterm-font)`
    ... which is depended on by `wezterm-gui v0.1.0 (/home/steveej/src/others/wezterm/wezterm-gui)`

failed to select a version for `servo-fontconfig-sys` which could resolve this conflict

Options that seemed promising but didn't help

Vendoring dep's crates

I tried explicitly instructing cargo vendor to consider the crates in the _dep_ directory but it didn't have an effect:

  --sync=deps/freetype/Cargo.toml \
  --sync=deps/harfbuzz/Cargo.toml \
  --sync=deps/fontconfig/Cargo.toml \

Version the vendored crates

Passing --versioned-dirs to cargo vendor didn't help either.

bug

Most helpful comment

As I mentioned, I believe that this is a cargo bug

I agree, I'm just sure where exactly it is!

I've removed font-loader from the build so resolving the cargo issue shouldn't block this one

Thank you! I'll go ahead with the packaging and hope I have enough motivation to pursue the Cargo bug afterwards :wink:

All 4 comments

I think this is a cargo vendor bug. font-loader is specified as a dependency only on macos and windows because it introduces the incompatible servo-font crate dependencies:

https://github.com/wez/wezterm/blob/master/wezterm-font/Cargo.toml#L32-L35

commenting out that dep allows the build to proceed further... but will break the build on macos and windows.
It may make sense to selectively sed/patch that for the nixos build?

My current assumption is that cargo vendor downloads the dependencies for every given condition, and cargo check|build|run assumes all vendored dependencies need to be loaded, which leads to the situation we're finding here.

If my assumption is correct (I'm currently going through cargo code to verify that) I think the best place to fix it is in the compilation, because it would be useful to re-use the vendor directory to build for all platforms.

As I mentioned, I believe that this is a cargo bug, however, I've removed font-loader from the build so resolving the cargo issue shouldn't block this one.

As I mentioned, I believe that this is a cargo bug

I agree, I'm just sure where exactly it is!

I've removed font-loader from the build so resolving the cargo issue shouldn't block this one

Thank you! I'll go ahead with the packaging and hope I have enough motivation to pursue the Cargo bug afterwards :wink:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sanga picture sanga  路  10Comments

chris-morgan picture chris-morgan  路  8Comments

erf picture erf  路  5Comments

erf picture erf  路  6Comments

mborejdo picture mborejdo  路  6Comments