servo: Compiling libservo as a dependency fails

Importing libservo from the latest commit with a Cargo.toml like

[package]
name = "servo-embedder"
version = "0.1.0"

[dependencies]
libservo = { git = "https://github.com/servo/servo.git", rev = "84185eb" }

and then running cargo check results in a conflict:

    Updating git repository `https://github.com/servo/servo.git`
    Updating git repository `https://github.com/servo/media`
    Updating crates.io index
    Updating git repository `https://github.com/servo/devices`
    Updating git repository `https://github.com/jrmuizel/raqote`
    Updating git repository `https://github.com/pcwalton/signpost.git`
    Updating git repository `https://github.com/servo/rust-mozjs`
    Updating git repository `https://github.com/gfx-rs/wgpu`
    Updating git repository `https://github.com/servo/mozjs`
error: failed to select a version for `freetype-sys`.
    ... required by package `freetype v0.5.1`
    ... which is depended on by `font-kit v0.9.0`
    ... which is depended on by `raqote v0.8.1-alpha.0 (https://github.com/jrmuizel/raqote#4b947efa)`
    ... which is depended on by `canvas v0.0.1 (https://github.com/servo/servo.git?rev=84185eb#84185eb1)`
    ... which is depended on by `compositing v0.0.1 (https://github.com/servo/servo.git?rev=84185eb#84185eb1)`
    ... which is depended on by `constellation v0.0.1 (https://github.com/servo/servo.git?rev=84185eb#84185eb1)`
    ... which is depended on by `libservo v0.0.1 (https://github.com/servo/servo.git?rev=84185eb#84185eb1)`
    ... which is depended on by `servim v0.1.0 (/home/noah/src/servim)`
versions that meet the requirements `^0.11.0` are: 0.11.0

the package `freetype-sys` links to the native library `freetype`, but it conflicts with a previous package which links to `freetype` as well:
package `freetype-sys v0.13.1`
    ... which is depended on by `freetype v0.7.0`
    ... which is depended on by `font-kit v0.10.0`
    ... which is depended on by `canvas v0.0.1 (https://github.com/servo/servo.git?rev=84185eb#84185eb1)`
    ... which is depended on by `compositing v0.0.1 (https://github.com/servo/servo.git?rev=84185eb#84185eb1)`
    ... which is depended on by `constellation v0.0.1 (https://github.com/servo/servo.git?rev=84185eb#84185eb1)`
    ... which is depended on by `libservo v0.0.1 (https://github.com/servo/servo.git?rev=84185eb#84185eb1)`
    ... which is depended on by `servim v0.1.0 (/home/noah/src/servim)`

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

Compiling servo using mach directly works fine though, how is the conflict solved then? Am I compiling it correctly as an embedder or is there an alternative method?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

@jdm I think you are correct, I forgot that the lock file may be overwritten. Copying the lock file again fixes this error but another one about media_platform arises:

error[E0433]: failed to resolve: use of undeclared type or module `media_platform`
   --> /home/noah/.cargo/git/checkouts/servo-12bfca331f128de3/84185eb/components/servo/lib.rs:298:13

Examining the lib.rs file, it’s clear that the module only gets declared if “media-gstreamer” or “media-dummy” is enabled. So adding the “media-gstreamer” feature to libservo solves this error.

Now it finally fully builds, thank you very much for the help. In summary it was resolved by

  • adding the rustc-dev component (with e.g. rustup component add rustc-dev),

  • copying Cargo.lock from servo, make sure it’s not overwritten before every build,

  • performing the following changes to Cargo.toml:

    • Copy overriddes from servo’s Cargo.toml, particularly those for webrender and raqote.
    • Add either layout-2013 or layout-2020 as a feature to libservo.
    • Add either media-dummy or media-gstreamer as feature to libservo.

My Cargo.toml then looks like:

[dependencies]
libservo = { git = "https://github.com/servo/servo.git", rev = "84185eb", features = ["layout-2020", "media-gstreamer"] }

[patch."https://github.com/jrmuizel/raqote"]
raqote = { git = "https://github.com/jdm/raqote", branch = "fkup" }

# https://github.com/servo/servo/issues/27515#issuecomment-671474054
[patch."https://github.com/servo/webrender"]
webrender = { git = "https://github.com/jdm/webrender", branch = "crash-backtrace" }
webrender_api = { git = "https://github.com/jdm/webrender", branch = "crash-backtrace" }

Try cargo +nightly-2020-07-27 build instead.

Ah yes, this worked. Unfortunately, I am getting another error:

❯ cargo build
    Blocking waiting for file lock on package cache
    Updating git repository `https://github.com/servo/servo`
    Updating git repository `https://github.com/servo/webrender`
    Updating git repository `https://github.com/jrmuizel/raqote`
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
   Compiling net v0.0.1 (https://github.com/servo/servo?rev=7f12ee6#7f12ee64)
   Compiling script_plugins v0.0.1 (https://github.com/servo/servo?rev=7f12ee6#7f12ee64)
   Compiling libservo v0.0.1 (https://github.com/servo/servo?rev=7f12ee6#7f12ee64)
   Compiling hashglobe v0.1.0 (https://github.com/servo/servo?rev=7f12ee6#7f12ee64)
   Compiling style v0.0.1 (https://github.com/servo/servo?rev=7f12ee6#7f12ee64)
   Compiling servo_remutex v0.0.1 (https://github.com/servo/servo?rev=7f12ee6#7f12ee64)
   Compiling unicase v2.6.0
   Compiling generic-array v0.14.4
   Compiling gl_generator v0.13.1
   Compiling quote v0.6.13
   Compiling ash v0.31.0
   Compiling bindgen v0.53.3
   Compiling brotli v3.3.0
   Compiling libflate v0.1.26
   Compiling flate2 v1.0.17
   Compiling cc v1.0.50
   Compiling rand_core v0.5.1
   Compiling mio v0.6.22
   Compiling bytes v0.4.12
   Compiling futures-cpupool v0.1.8
   Compiling cookie v0.11.2
   Compiling accountable-refcell v0.2.0
   Compiling dirs v2.0.2
   Compiling clap v2.33.3
   Compiling gfx-hal v0.6.0
   Compiling indexmap v1.5.0
   Compiling syn v1.0.38
   Compiling wayland-scanner v0.28.0
   Compiling num-integer v0.1.42
   Compiling approx v0.3.0
   Compiling ordered-float v1.0.2
   Compiling spirv_headers v1.4.2
   Compiling line_drawing v0.7.0
   Compiling num-complex v0.2.4
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/home/raphael/.rustup/toolchains/nightly-2020-07-27-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.0.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.1.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.10.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.11.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.12.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.13.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.14.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.15.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.2.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.3.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.4.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.5.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.6.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.7.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.8.rcgu.o" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.script_plugins.6kbpc9ot-cgu.9.rcgu.o" "-o" "/home/raphael/Desktop/photon/target/debug/deps/libscript_plugins-313a4b34b92f6720.so" "-Wl,--version-script=/tmp/rustcQ7wpKv/list" "/home/raphael/Desktop/photon/target/debug/deps/script_plugins-313a4b34b92f6720.1rfg3a7l5e3ubv9q.rcgu.o" "-shared" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/raphael/Desktop/photon/target/debug/deps" "-L" "/home/raphael/.rustup/toolchains/nightly-2020-07-27-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/raphael/.rustup/toolchains/nightly-2020-07-27-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_driver-1d3a8c7062c07322" "-Wl,--start-group" "-L" "/home/raphael/.rustup/toolchains/nightly-2020-07-27-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-3799b36d315ad05d" "-Wl,--end-group" "-Wl,-Bstatic" "/tmp/rustcQ7wpKv/libcompiler_builtins-645e6567a5572509.rlib" "-Wl,-Bdynamic" "-lLLVM-10-rust-1.47.0-nightly" "-lutil" "-ldl" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-ldl" "-lutil"
  = note: /usr/bin/ld: cannot find -lLLVM-10-rust-1.47.0-nightly
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: could not compile `script_plugins`.

EDIT: Adding the llvm-tools-preview component fixed it.

Try cargo +nightly-2020-07-27 build instead.

I got to a similar and @hellux solution didn’t work. I made some small changes It worked fine. After copping the Cargo.lock file to my dir I alter some Information on the Cargo.toml the file look like this:

# ... Not related information
[dependencies]
glutin = "0.9"

# here changed 
[dependencies.simpleservo]
path = "../servo/ports/libsimpleservo/api/"
version = "0.0.1"
features = ["layout-2013", "media-dummy"]


[patch."https://github.com/jrmuizel/raqote"]
raqote = { git = "https://github.com/jdm/raqote", branch = "fkup" }

[patch."https://github.com/servo/webrender"]
webrender = { git = "https://github.com/jdm/webrender", branch = "crash-backtrace" }
webrender_api = { git = "https://github.com/jdm/webrender", branch = "crash-backtrace" }

but thank you, It helped very much

Maybe add the rustup component rustc-dev?

You may need to coy those cargo overrides as well, in that case. The error shows that you are not using our fork of raqote.