Motivation
Having a C compiler is necessary for many crates, for example, https, tls, compression/decompression.
For http, even if rustls is used, it would still have to pull in ring which has a build-script to compile the C code and assembly code.
For compression/decompression, the most widely used algorithms such as zstd, libz/flate, xz are implemented in C and would require a C compiler to compile.
This means that many rust users have to install a C compiler after experiencing confusing build script errors, and it makes cross compilation a nightmare.
For users who want maximum performance with cross language LTO, this also means that they have to be careful to use the same LLVM version for the c toolchain and the rust toolchain.
And finally an external C compiler makes sandboxing much harder since build script has to invoke a potentially untrusted external command.
Proposed solution
I propose that we should distribute a c compiler via rustup by default, preferably zig-cc/cargo-zigbuild.
zig-cc has excellent cross compilation story, and cargo-zigbuild contains some workaround for zig-cc that rustup can include.
The path to the wrapped zig-cc should be exposed via a environment variable during build-script, so that cc-rs can pick it up and use it for compilation.
The zig-cc should use the same LLVM version as rustc, so that users can enable cross language LTO without pain.
If the build script is compiled down to WASI for sandboxing, then it can allow invocation of zig-cc bundled with rustup as it is trusted.
I would propose that rust should also support zig-cc also used as linker to simplify cross compilation, including to older version of glibc.
By bundling zig-cc with rustup, we could potentially eliminate build-script for certain projects, by putting the c source code in a pre-defined directory within the crate and automatically compiled when compiling the crate.
Alternative solution
Alternatively, crate owner/maintainer can use c2rust to transpile the code to rust code.
bzip2 maintainer has done this and this is working ok for them, despite some performance loss for now that could be claimed back later.
I have also tried transpiling zstd but found a few unsupported intrinsics