rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.82k stars 440 forks source link

Use `dep:` syntax to avoid implicit features. #1099

Closed waywardmonkeys closed 3 months ago

waywardmonkeys commented 3 months ago

The only real externally visible feature should be parallel and not the implicit features for the optional dependencies.

waywardmonkeys commented 3 months ago

With this, adding cc as a dependency results in:

      Adding cc (local) to build-dependencies
             Features:
             - parallel

rather than:

      Adding cc v1.0.99 to build-dependencies
             Features:
             - jobserver
             - libc
             - once_cell
             - parallel
rafales commented 2 months ago

Guys, this broke a lot of code because solana-program has been using jobserver dependency for a long time.

NobodyXu commented 2 months ago

Guys, this broke a lot of code because solana-program has been using jobserver dependency for a long time.

In that case it's a no-op, enabling jobserver does not enable the parallel compilation, it's still compiled in sequential, just with one extra dependency doing nothing.

waywardmonkeys commented 2 months ago

@NobodyXu It looks like they enabled both parallel and jobserver:

https://github.com/solana-labs/solana/blob/27eff8408b7223bb3c4ab70523f8a8dca3ca6645/sdk/program/Cargo.toml#L92

Now this would fail since there is no jobserver feature.

Maybe cc should add one that does nothing, but there's no means for deprecating a feature either. I could submit a PR that does one of:

jobserver = ["parallel"]

or

jobserver = []

And perhaps we could emit a warning when cfg(feature = "jobserver")

NobodyXu commented 2 months ago

Right yeah that makes sense, I would accept a PR for it.

waywardmonkeys commented 2 months ago

I'll do this ... but I notice that it has been 3 weeks and only apparently one thing is broken and I don't see that anyone in that community has reported an issue or filed a PR to fix their usage of cc.