New major version of libc planned?

I just read this week in rust and stumbled upon this GSoC project: Modernising the libc crate.

This project aims to release a new major version of libc, introducing breaking changes

Doesn't this risk causing another libcpocalypse?

I'll link to dtolnay's semver-trick which must be relevant and has a pretty good explanation and more links about libcpocalypse.

2 Likes

I guess it does. How many people actually use libc? I do just now because I'm programming in Crust, but that is kind of aberrant behaviour. How huge a braking change could it be?

Used in 99,327 crates (7,594 directly)

I see there's a 1.0.0-alpha.1 release already. For some reason I thought the new major version of libc would be 2.0.0, but maybe it will be the full 1.0.0 release.

Indirectly - everyone who uses rand, for example, since it pulls in getrandom which depends on libc.

Hmm... I was thinking pretty much everyone uses libc but for most it is hidden under the Rust standard library and so they would be protected from any churn in libc.

It'd be a bigger issue now since we have more unmaintained and crates with low activity, which probably libc = "0.2" in their dependencies; crates which could be used rather often. Any crate that exposes something from libc could require a major version bump to prevent breakage. The probability of error is also probably higher because there are far more crates than there were in 2015. There would have to be a lot of dependency pinning if stuff breaks, from the looks of it.

There will be some churn, but hopefully not apocalyptic.

It's not a problem to have two versions of libc in one project.

The compatibility problems come mainly from mixing types defined in different major versions of a crate. If your crate or your dependency just calls libc functions or only uses libc in private code, it should be fine.

libc doesn't have its own c_void type any more and it's an alias to libstd type, so it won't change. Only more specific types will be affected like struct timeval. Hopefully not many crates expose bare libc types in their public interface.

5 Likes