GSoC Project: Making Redox Self-hosting, Final Summary
By ids1024 on
More details of what I’ve done are listed in the status reports I’ve written:
Summary of Progress Made
Since cargo does not work on Redox, it is fair to say that Redox is still not self-hosting. However, that shouldn’t be hard to fix once a couple kernel features that are currently blocking it are implemented. And I intend to help with that once those blocking issues are addressed.
However, in the mean time, I’ve found plenty of other things to work on by focusing on C software, such as making autotools builds work. I have succeeded with a basic autootools based build, though automake/autoconf themselves are not quite functional yet and more complicated builds tend to have issues. It was my intention from the beginning to work on various C porting issues once I had gotten the toolchain working. So I can’t quite say the project was a complete success, but I think overall enough progress has been made in various things, and real self-hosting should now be possible before too long.
Aside from being nearer to self-hosting, porting C software to Redox should be easier now. I have made many improvements to Redox’s C library, and addressed many POSIX incompatibilities. The amount of C software that runs on Redox has increased a fair amount.
What I Learned
A couple of the bugs I dealt with gave me an appreciation for printing integers in hex rather than decimal; things like byte order and address alignment become obvious. I’ve also come to realize that largely following POSIX is important for an OS; frankly, some aspects of POSIX don’t make sense or are outdated, but if you want to use existing software, it becomes rather important. Of course, not everything need be compliant; and the implementation is flexible (POSIX specifies APIs; not the kernel-level interface, or other details like that).
Nothing gives you an appreciation for debuggers like not having one; although that was only relevant to a couple issues I had. I was able to use a convoluted means to connect gdb to qemu and set a breakpoint. At some point Redox needs the ptrace system call or another tracing API; perhaps a scheme, because ptrace has a rather bad API. For debugging Rust, my PR implementing Rust backtraces on Redox should help.
Rust does seem like a suitable language of OS development. Hopefully even if Redox achieves nothing else, it will demonstrate the strength of Rust in this area.
Further Matters to Address
As mentioned before, interruptible system calls are needed to get cargo working, and there’s also an issue with thread joining. Once those are addressed, it should be easy to make progress on cargo builds.
When I patched Rustc, one awkward issue was the lack of dynamic linking on Redox. Various rustc components are built as dynamic libraries (I was able to statically link them) and procedural macros depend on dlopen
(I added a hack disabling proc macros). So Redox needs a dynamic linker. Redox may use m4b’s dryad, which is written in Rust.
Once dynamic linking is possible, it should be possible to upstream Redox patches for rustc. Also, there are various other places where a dynamic linker would help; it would make it possible to load C modules in Python and Perl, for instance. Automake seems to depend on Perl’s dynaloader.
I intend to continue being involved in Redox, though I have other projects to work on, and may also want to work on other aspects of Redox.
Pull Requests
It would be convenient if everything was in one PR or repository, but due to the nature of my project, it touched various repositories. Here is a complete list of the pull requests I have filed related to Redox as part of the GSoC:
redox-os/newlib
- Expose nanosleep() and clock_gettime() in time.h header
- Override time.h to define nanosleep() and clock_gettime()
- Port C code to Rust
- Correct _dup() to dup()
- Add ftruncate() function
- Use SYS_GETCWD syscall in getcwd()
- Add getuid() and getgid()
- Set environ
- Pass -I when building Rust part, so headers are found
- Pass third ‘envp’ argument to main(), expected by some programs
- Build with no_std
- Make rust_begin_panic() both no_mangle and weakly linked
- Use “-C metadata=newlib”
- A couple small things
- Fix override of time.h header
- Expose ftruncate() declaration
- Add functions for Redox-specific calls
- Correct waitpid()
- Fix redox specifc function
- A couple improvements
- Correct umask
- Berkeley sockets API, version 2
- Import Box from alloc
- Implement realpath()
- fsync() and rename()
- Run autotools
- Use libc crate again
- Use libc crate, add a few functions / defines, remove unused placeholder functions
- symlink() and readlink()
- Implement lstat() using O_NOFOLLOW
- Call cargo update
- Define PF_ constants
- Implement gethostname()
- getpwnam() and getpwuid()
- utime() utimes() and futimens()
- Get fcntl() to work
- Use buffer in readdir to reduce number of calls
- Fix system()
- Use RawFile in more places
- Correct tv_nsec in C header
- Pass environmental variable on exec
- Call syscall::fstat instead of _fstat
- \0 terminate in getcwd
- Use off_t in lseek
- Use ; as PATH separator
- Add /dev/null hack and define h_addr
- Change values of F_*
- Use compiler_builtins from rust source tree
- [WIP] [Non-functional] Pthreads, based on pthreads-emb
- Do not ignore env argument of execve
- fchdir()
- Open file without O_WRONLY for utime
- Add utime.h (coppied for Linux backend)
- Use panic=abort
redox-os/syscall
- Use AsRef<[u8]> for paths, instead of &str
- Use repr(C) for structs in data.rs
- Add symlink-related flags
- SYS_GETPPID and getppid()
- Add O_NOFOLLOW flag
- [WIP] [POC] Proc macro for handling system call ABI
- Add MODE_CHR flag for “character special”
- Make sigaction() take Option<_> arguments
- Define F_GETFD and F_SETFD
- Add flag for fifo
- Add F_DUPFD flag
redox-os/libc
- Add build script for GNU make, which compiles (but doesn’t work yet)
- [WIP] [incomplete] LLVM
- Setup xargo/rustup in setup.sh for newlib
- Pass –with-ld when building gcc port
- Use / as prefix instead of /usr for binutils/gcc
- Add Arch Linux PKGBUILDs for toolchain
- Tweak dependencies of Arch packages
- Fix Arch PKGBUILD issues found when building in chroot
- Hacks for dash to compile; more needs to be done for it to work
- Initial port of rustc
- Correct rust install path
- Add libgit2
- Make curl build
- Improve Arch PKGBUILD
- Correct path in gcc build scripts
- Update submodules
- Update readme
- Fix PKGBUILD for newlib
- Use -unknown- instead of -elf-, to match Rust and be more standard
redox-os/cookbook
- Do not copy .cargo and libc-artifacts
- Recipes for gcc, binutils, newlib
- Make stage call unstage
- Handle patches in prepare
- Add “shopt -s nullglob” to fix patch loop
- Make dash available as /bin/sh
- Strip binaries in gcc and gnu-binutils, for much smaller file size
- Check if recipe has been updated in repo.sh
- Strip only executables, not libraries
- Correction to gcc recipe
- Set $XARGO_HOME to build std et al only once
- Recipe for rust
- Use /bin/sh and /bin/cc ion scripts
- Remove xargo-home in clean.sh
- Initial recipe for cargo
- ca-certificates package; needed by cargo
- Recipe for curl
- Correct prefix for openssl in cargo build
- Correct ca-certificates recipe
- Pass –target to pkg
- Use symlinks
- Initial python recipe
- System for compile-time dependencies; use for openssl
- [WIP] Git recipe
- git: use symlink instead of hard link
- Fix repo.sh call for build depends
- Remove some changes to python that are unneeded now
- Recipe for gawk
- Recipe for sed
- Add recipe for uutils findutils
- Fix pastel recipe; add ‘mkdir’
- Override git sha1 implementation
- Recipe for GNU grep
- Hopefully fix grep build
- git: ; as path separator
- Add recipe for diffutils
- Build gcc with C++ support
- Enable ‘backtrace’ feature in libstd, to allow backtraces
- Use -unknown- instead of -elf-
- Add recipe for bash
- Add recipe for xz
- Make extrautils have xz as a build depend
- Add recipe for patch
- Use system ‘pkg’ when run on Redox
- Patch patch not to call chown
- Pass -p to cp, to make running autotools unnecessary
- Add symlinks to uutils package
- Simplify git patch a bit
- Add –debug argument to cook.sh to build in debug mode, unstripped
- Use release tarball for curl, with a couple patches
- Bump python version
- Recipe for perl
- A couple fixes for perl, and initial recipes for automake and autoconf
rust-lang/rust
- Fix building std without backtrace feature, which was broken in ca8b754
- Implement requires_synchronized_create() for Redox
- Redox: Use create() instead of open() when setting env variable
- Set CXX_
in bootstrap - Fix Redox build, broken in ecbb896b9eb2acadefde57be493e4298c1aa04a3
- redox: symlink and readlink
- Fix Redox build, apparently broken by #42687
- Redox: Use O_NOFOLLOW for lstat()
- Redox: Fix Condvar.wait(); do not lock mutex twice
- Redox: Fix Condvar.wait(); do not lock mutex twice
- Redox: add stat methods(); support is_symlink()
- redox: handle multiple paths in PATH
- Implement AsRawFd for Stdin, Stdout, and Stderr
- Make backtraces work on Redox, copying Unix implementation
- Enable unwinding panics on Redox
- Redox: correct is_absolute() and has_root()
- redox: Correct error on exec when file is not found
redox-os/kernel
- Update for changes in std::ptr::Unique API
- Make env: return ENOENT on non-existent; support unlink()
- Implement getppid system call
- Pass empty second argument to dup() call in clone
- Pass empty second argument to dup in exec
- pipe: make read() return when write end is closed
- Revert “pipe: make read() return when write end is closed”
- Implement fstat() for pipe scheme
- Strip whitspaces after #!
- Pass relative, not canonicalized, path to script
- Make dup2() work if second file descriptor doesn’t exist
- Make dup/dup2 clear cloexec
- Make seek on pipe return ESPIPE
- sys:uname
- Strip extra slashes from path
- Use file descriptions, shared between file descriptors
- Use fifo flag for pipe
- Prevent freezing due to double locking
- Implement F_DUPFD
- Support arguments in #!
japaric/xargo
redox-os/redoxfs
- Initialize fields of Stat struct to 0
- Use ? instead of try!
- Allow seek beyond end of file.
- [WIP] Symlinks
- Return EINVAL for O_SYMLINK on non-symlink
- Symlinks in fuse
- Support unlink() on symlink
- Follow symlinks on O_STAT, unless O_NOFOLLOW is passed
- Mtime should be second element
- Make fcntl not clobber access mode
- Do not fail due to file permissions on creation
- Require same uid as owner to unlink, not write permission
- fuse: Fix readdir when directory does not fit in buffer
- fuse: allow setting mtime to earlier time
- Directory symlinks
- Avoid corrupting free node
- Remove unneeded uses of ‘mut’
- Make it not an error to open a directory without O_DIRECTORY or O_STAT
- futimens: do not require O_RWONLY/O_RDWR
redox-os/coreutils
- Implement stat command
- Fix copy/paste error
- Add readlink command
- Stat improvements
- Use O_NOFOLLOW in stat
- Use libstd instead of syscall for stat
- stat: format time properly and display user and group name
- Use
filetime
in touch - rm: -f argument
- dirname command
- rm: fix directory support
- Make ‘which’ work with multiple directories in PATH
- Add uname utility
- Allow directory as second argument to ln
- tr: octal escape
- Remove chmod, env, and ls, which uutils has better versions of
redox-os/gcc
- Link against crt* to support C++ global constructor / destructor
- Use null: instead of /dev/null
- Re-enable stmp-fixinc target
- Use ; as path separator on Redox
redox-os/redox
- Increase filesystem size to 1024 MB
- Make build/filesystem.bin and build/initfs.tag targets .PHONY
- ‘user’ and ‘root’ groups
- “make fetch” target
- Add uutils to filesystem.toml
- Update cookbook submodule
- Add scheme to PATH
- Symlink /usr to /
redox-os/dash
redox-os/netstack
rust-lang/cargo
redox-os/randd
redox-os/pkgutils
- Use pbr crate for progress bar
- Use BufReader to extract gzip archive
- Use clap for argument parsing, and allow a –target argument to choose which target to download packages for
- Determine default target based on LLVM triple at build
- Do not follow symlinks when creating package
- Better error handling
- Add –root argument; print usage on no subcommand
- Use BufWriter
a8m/pb
redox-os/ransid
redox-os/rust
- Redox: Use create() instead of open() when setting env variable
- Temporary implementation of rename
- Symlink and readlink
- Redox: Use O_NOFOLLOW for lstat()
- Redox: Fix Condvar.wait(); do not lock mutex twice
- Correct fix for condvar (hopefully)
- Redox: add stat methods(); support is_symlink()
- Redox: Add JoinHandleExt (matching Unix version)
- redox: handle multiple paths in PATH
- Remove import
ruuda/thread-id
redox-os/orbutils
libgit2/libgit2
redox-os/website
redox-os/netutils
- Use hyper in httpd
- Make wget use -O argument, matching standard behavior
- wget: use pbr for progress bar
alexcrichton/tar-rs
redox-os/tar-rs
alexcrichton/filetime
redox-os/ptyd
redox-os/installer
rust-lang/libc
redox-os/arg-parser
redox-os/extrautils
- Add -v argument to grep
- Implement -c flag to grep
- Support gzip and xz extraction; verbose
- Implement –directory and –strip-components for tar
- tar: set file times
- Try to fix travis by installing liblzma
- Install lzma with no-sudo method
- Support bzip2 extraction in tar
uutils/coreutils
- Make chmod use std where possible instead of libc; compile for Redox
- Fix ordering of ls -t, which was backwards
- Make ls build on Redox
- Correct behavior of cp -r with non-existent dest
- Redox fixes for mktemp and install
- install: Fix verbose mode
- cp: enable setting timestamps