5 ms·
I recall something about Rust's libc crate being glibc-specific. What's the status on that, and can one build the compiler on Solaris/illumos, NetBSD and OpenBS
by vezzy-fnord 12y ago
I recall something about Rust's libc crate being glibc-specific. What's the status on that, and can one build the compiler on Solaris/illumos, NetBSD and OpenBSD?
- steveklabnik 12y ago> What's the status on that We still use glibc, yes. Being able to use musl instead is something that the community and team have been experimenting with lately. > can one build the compiler on Solaris/illumos, NetBSD and OpenBSD? The last two have community members that keep the build green. I _think_ illumos works, but I'm not sure.
- steveklabnik 12y agoOh, look what just popped up: https://github.com/rust-lang/rust/pull/24777 https://github.com/rust-lang/rust/pull/24777
- kibwen 12y agoHere's an experience report by someone who managed to get Rust running on musl, for the purpose of creating fully static Rust binaries: https://gist.github.com/cl91/bb927df2525738502131#file-static-linking-against-musl-md https://gist.github.com/cl91/bb927df2525738502131#file-stati... (discussion at https://www.reddit.com/r/rust/comments/33boew/weekend_experiment_link_rust_programs_against/ https://www.reddit.com/r/rust/comments/33boew/weekend_experi...).
- kibwen 12y agoUPDATE: Official (though still experimental) support for using musl with Rust code is landing in the compiler as we speak! https://github.com/rust-lang/rust/pull/24777 https://github.com/rust-lang/rust/pull/24777
- duaneb 12y ago> I recall something about Rust's libc crate being glibc-specific. If this is true, it's because support for others hasn't rolled out yet, not because it has some inherent dependency on that version of libc.
- miffe 12y agoWhy does rust need a libc? Im still new to rust, so forgive me if this is a stupid question.
- erickt 12y agoNo it's not a stupid question. libc (or CRT on windows) really is the library that exposes all the user space system libraries. It contains the functions to do IO, sockets, threads, and etc. So we use it to expose that functionality to rust users. Now there are some languages, namely Go, that skip libc and just implement directly against the syscall interface. Go has the advantage of being able to draw from Google's vast experience interacting deep within the system, so it was comparatively cheap for them to do this. For rust, it never really felt like it was worth the effort for the benefit we'd get out of it. It was more important to get the language done.
- noir_lord 12y agoIn theory you could later implement libc (libcrust. calling it now) in Rust as well so you get the best of both worlds couldn't you?
- vezzy-fnord 12y agoI'm not sure if it makes any sense to implement libc in anything other than C.
- yellowapple 12y agoIt would be an interesting experiment, seeing as how Rust code can be called from C and vice versa. There's already been some tinkering on various operating system kernels written in Rust (even if they don't do much besides printing "Hello, world!" quite yet), so I figure a pure-Rust standard library is the next step in that.
- kibwen 12y agoThis is actually a project I have considered with in the past, though not very seriously. Theoretically you could completely replace libc with a Rust implementation and use it system-wide, and the rest of your programs would be none the wiser. It's a non-trivial amount of effort, however. :)
- diamondlovesyou 12y agoYes, but the standard crates don't really use any of the glibc specific Stuff. I found it not too difficult when I ported Rust to use `newlibc`, for use with PNaCl. I have even managed to build a PNaCl version of `rustc` itself.