by avar · 10y ago · 0 comments
> no autoconf
Mentioning this in the same breath as "no segfaults" seems odd, does Rust use some other build configuration tool, or does it just not have the need for compile-time configuration detection? If it's the latter how does that even work?Are there no optional libraries? No outdated libraries whose version you have to detect? No obscure platforms whose architecture you have to detect for unsafe inline code etc.?
Because if you can have any of those or any number of other cases where you need compile-time detection of configuration options you're going to need something like autoconf.
Yes. Rust ships with cargo, which is probably the best build configuration tool ever written, and I've tried a lot of them, for a lot of different languages.
It has clean, non-hacky solutions to all of the cases you listed, and a lot more besides those.
> happily downloaded a random pre-built ELF binary to build itself.
Yes, Cargo builds itself with Cargo, so you need to get a previous Cargo. The binary is very much not 'random'.The main problem is you can't download dependencies separately from compiling your code. It should never be the same step. Even pip had it mostly correct, by providing an option to disable network communication.
It is somewhat mitigated by documentation mentioning where the downloaded dependencies are put, so you can do all that manually. This sucks balls heavily.
> Yes, Cargo builds itself with Cargo, so you need to get a previous Cargo. The binary is very much not 'random'.
It's fetched outside of regular downloading you do on tarball. You have no control over where is it downloaded from. It means it's pretty much random for your purposes. Heck, it would be even unexpected, if I wasn't used to developers not understanding the difference between building and downloading software.
But this is not the main point. Cargo should not need already compiled Cargo to build itself. This is ridiculous. I understand that every good compiler is built with the very same compiler you're building, but look at how they do that: by bootstrapping. Not so much with Cargo. Who ever thought it as a valid idea?
We will see what happens when a vendor write their own Rust compiler that has its own idiosyncrasies.
Compiling pure rust relies on the single compiler toolchain which is assumed to be present by cargo, and universal on all platforms. That's pretty solid.
...but rust = no autoconf is somewhat misleading; rust that uses c libraries has to solve all the same problems that anything else using c libraries has to; but unlike python or node, there is no help (ie. gyp or distutils) for you if you need to do this.
Perhaps eventually something clever will come along to fill the gap, but it's something of a pain point at the moment, especially on windows.
For example:
cfg_if! {
if #[cfg(windows)] {
mod windows;
pub use windows::*;
} else {
mod unix;
pub use unix::*;
}
}
The 13 struct stat's in libc: https://github.com/rust-lang-nursery/libc/search?utf8=%E2%9C...Cargo supports versioning libraries (and seemingly does so sanely!). Obscure platform support is obscure.