rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.23k stars 679 forks source link

Update clang-sys #2844

Closed theoparis closed 2 weeks ago

theoparis commented 1 month ago

Please update clang-sys to 1.8.1 in bindgen, previous versions do not handle static linking or libc++ properly.

Additionally I can't update clang-sys myself:

error: failed to select a version for `clang-sys`.
    ... required by package `bindgen v0.49.3 (https://github.com/rust-lang/rust-bindgen#ad0bf8e6)`
    ... which satisfies git dependency `bindgen` of package `nixc v0.0.1 (/home/theo/Documents/nixc)`
versions that meet the requirements `^0.28.0` are: 0.28.1, 0.28.0

the package `clang-sys` links to the native library `clang`, but it conflicts with a previous package which links to `clang` as well:
package `clang-sys v1.8.2 (https://github.com/KyleMayes/clang-sys#e4c9b7ef)`
    ... which satisfies git dependency `clang-sys` of package `nixc v0.0.1 (/home/theo/Documents/nixc)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the `links = "clang"` value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

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

Cargo.toml:

[package]
name = "nixc"
version = "0.0.1"
edition = "2021"

[dependencies]
rnix = "0.11.0"
clap = "4.5.4"

[workspace]
members = []
resolver = "2"

[build-dependencies]
bindgen = { git = "https://github.com/rust-lang/rust-bindgen", features = ["static"], default-features = false }
clang-sys = { git = "https://github.com/KyleMayes/clang-sys", version = "1", default-features = false, features = ["libcpp", "static"] }

[patch.crates-io]
clang-sys = { git = "https://github.com/KyleMayes/clang-sys", version = "1" }
jschwe commented 1 month ago

Additionally I can't update clang-sys myself:

... required by package `bindgen v0.49.3 (https://github.com/rust-lang/rust-bindgen#ad0bf8e6)`

Have you tried updating bindgen to the most recent version before trying to update clang-sys?

theoparis commented 2 weeks ago

Not sure why I had an old version of bindgen here. However I am running into a new issue where I get undefined references to zstd, possibly due to using a static zstd library. My bad, the llvm build I used was using libzstd.so for some reason.