book should explain programs and their libraries (newlib, libstd, libredox, ...)
Created by: skierpage
Hi, congratulations on this amazing project.
I'm confused how programs work at all in Redox. It offers a number of big C programs and I think uses a port of newlib to make these work. But Rust programs use libstd. I read in Rust-land about the difficulties of running libstd on non-standard architectures but I don't know where Redox wound up.
The only references to all this in the Redox-OS book are two mentions of newlib in passing, and https://doc.redox-os.org/book/contributing/best_practices/rusting_properly.html says "libredox should be 1-to-1 with the official libstd"
I think the best place to address this is in a section after 5.2 The kernel and before 5.4. Coreutils, called 5.x Programs and Libraries. I'd make a pull request for this but I was unable to get Redox working, neither from the book, nor building new libc, nor from docker :-( , so here's a guess at what the chapter should say.
5.x Programs and Libraries
Redox can run programs. Some programs are interpreted by a runtime for the program's language, such as a script running in the Ion shell or a Python program. Others are compiled into machine instructions that run on a particular operating system (Redox) and specific hardware (e.g. x86 compatible CPU in 64-bit mode).
- In Redox compiled binaries use the standard ELF ("Executable and Linkable Format") format.
Programs could directly invoke Redox syscalls, but most call library functions that are higher-level and more comfortable to use. You link your program with the libraries it needs.
- Redox does not support dynamic-link libraries yet (issue #927), so the libraries that a program uses are statically linked into its compiled binary.
- Most C and C++ programs call functions in a C standard library ("libc") such as
fopen
- Redox includes a port of the newlib Standard C library. This is how programs such as git can run on Redox. newlib has some POSIX compatibility.
- Rust programs implicitly or explicitly call functions in the Rust standard library (libstd).
- ??
Redox implements a subset of this in libredox - The Rust libstd now includes an implementation of its system-dependent parts (such as file access and setting environment variables) for Redox, in
src/libstd/sys/redox
. ?? Most of libstd works in Redox, so many command-line Rust programs can be compiled for Redox.
- ??
The Redox "cookbook'' project includes recipes for compiling C and Rust projects into Redox binaries.