Skip to content

Drive system-deps as a standard for managing system dependencies #97

@weihanglo

Description

@weihanglo

Thank you for maintaining this awesome package!

The value of a declarative interface for system dependencies is something the community already knew but never thought deeply about. It benefits everyone without writing imperative build scripts. I really love the idea, and wish it becomes more mainstream, or even built-in in Cargo.

The elephant(s) in the room

I see some issues that the community currently has around system dependencies:

  • They tend to use imperative build scripts to invoke pkg-config/vcpkg to probe libraries.
    • Those build scripts were usually copied from some build scripts from well-known repositories, so they share some of the same bugs/defects.
    • Compared to a declarative interface like system-deps, an imperative build script cannot be easily updated, so the logic is typically more error-prone.
    • People don't write tests for build scripts.
  • They often declare a vendored Cargo feature for building from source. However, Cargo features are unified and additive. Once some crate in a dependency tree activates vendored, they can never use the library from the system.
    • This silent vendoring behavior is hard to detect. You only find its existence when a symbol is not found, or even worse, a segfault at runtime because the source is from a wrong vendored version.
    • At some air-gapped/sandboxed environments, such usage is prohibited. By the nature of Cargo features, the vendoring behavior is nearly impossible to revert, making the entire project unbuildable.
    • From a security aspect, it's hard to either audit or patch a vendored system dependency. It loses the ability of modern Linux distributions to update shared libraries for patching vulnerabilities.

A practical(?) plan

As the first step, we tried to make our own system-deps, and then came across this repository. I believe there is room for us to collaborate to push this as a de facto way to declare system dependencies, and then become official (i.e., rust-lang/cargo#12432).

There are some tasks waiting for us to make the adoption rate better:

  • The top 10 popular *-sys crates tend to have a relatively low MSRV, like 1.52 or something. system-deps currently has a high MSRV of 1.65 because of its dependency toml. If we could lower the MSRV to some extent, it would be easier to convince those *-sys crate authors to buy into the idea.
  • Developers should have the final say on whether a *-sys is vendored or not. To support this, we need to model vendoring. One idea is that we isolate vendoring logic in a callback through the system-deps API, so that we have control over its execution. For example, providing a SYSTEM_DEPS_MODE=probe|mode environment for developers to make their own choice.
  • Vcpkg support. Obviously, it is vcpkg support #8. This might be a must if we wish system-deps to prosper.
    • This can be hard, but we don't need to do it perfectly in one version.

Thanks for reading this lengthy issue. This is a long-term fight, and I believe by tackling the top 10s, we can make the adoption of system-deps more widespread.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions