vaaaaanquish / lightgbm-rs

LightGBM Rust binding
MIT License
73 stars 30 forks source link

Cargo build failure caused by other crates with bindgen #29

Open takkyu2 opened 3 years ago

takkyu2 commented 3 years ago

First things first, thank you for this nice crate!

This is not a problem of this crate per se, and this issue is just for your information. If I include several crates which make use of bindgen, say this crate (vaaaaanquish/lightgbm-rs) and davechallis/rust-xgboost in Cargo.toml,

[package]
name = "xg_ls"
version = "0.1.0"
edition = "2018"

[dependencies]
lightgbm = "0.2.3"
xgboost = "0.1.4"

cargo build fails with the following error message:

error: multiple packages link to native library `clang`, but a native library can be linked only once

package `clang-sys v0.22.0`
    ... which is depended on by `bindgen v0.36.1`
    ... which is depended on by `xgboost-sys v0.1.2`
    ... which is depended on by `xgboost v0.1.4`
    ... which is depended on by `xg_ls v0.1.0 (/home/kou/ws_code/xg_ls)`
links to native library `clang`

package `clang-sys v1.2.0`
    ... which is depended on by `bindgen v0.56.0`
    ... which is depended on by `lightgbm-sys v0.3.0`
    ... which is depended on by `lightgbm v0.2.3`
    ... which is depended on by `xg_ls v0.1.0 (/home/kou/ws_code/xg_ls)`
also links to native library `clang`

As is menthioned in this issue https://github.com/rust-lang/cargo/issues/5237, it seems this failure occurs in the presence of the different versions of bindgen in the dependency.

If people want to do some ensembling (say xgboost & lightgbm just as above), or deploy some product with a complex data-processing pipeline, this may be a problem.

Having said that, I have no idea how to address the problem, since I do not know even a tiny bit of the cargo internals. Also, this seems to be a problem of the cargo build system itself, and it may be inappropriate to bring up this issue here, so please feel free to close this issue in case you find it unnecessary.

leofidus commented 3 years ago

The best solution I've found is to update all packages to a bindgen version of at least 0.55.0.

It looks like vaaaaanquish is doing god's work and upgrading the xgboost crate, so this specific instance should be solved soon.

vaaaaanquish commented 3 years ago

@takkyu2 @leofidus Thx.

As leofidus said, it was a problem with the bindgen version. To make this possible, we did a very big job of upgrading the xgboost version.

Almost there. Please wait a moment. :)