One difficulty in answering this question is pinning down what Racket "in its entirety" means. Much of Racket is implemented in Racket.
If you think about the main Git repository, it is organized as:
https://github.com/racket/racket
├── pkgs/
│ └── ...
└── racket/
├── collects/
│ └── ...
└── src/
└── ...
A useful boundary is between the contents of the racket/src/
directory, which contains the "Racket VM" implementations, and everything else, which contains code written in Racket that should be the same for all Racket implementations. The Racket VM provides the environment described in § 18.1.1 Initialization, where only "primitive modules with names that start with #%
are defined". These provide the primitives accessed by ffi/unsafe/vm
.
I think that's what you mean by "standard library", but usually I would use "standard library" to refer to the contents of the racket/collects/
directory.
Even inside the Racket VM, some components are implemented in Racket. These can be run in "user space" on an existing Racket (primarily for development), but they are primarily compiled in a special mode (e.g. to produce C or R6RS libraries) and embedded into the VM. The expander
package implements the macro expander, reader, and module system for both Racket CS and Racket BC. Racket CS also uses thread, io, regexp, and schemify layers implemented in Racket, while Racket BC implements equivalent functionality in C.
Both Racket BC and Racket CS use a C library, rktio, to provide thread-safe non-blocking IO and similar OS-level functionality.
Replacing Racket "in its entirety" could involve replacing some or all of the above components, but, more likely, you'd want to re-use many of them.
From another perspective, at the language level, a Racket implementation must be able to compile and instantiate linklet
forms as documented in § 14.14 Linklets and the Core Compiler. Then, it must provide the very large number of primitive functions and values you mentioned. As Matthew Flatt recently put it:
It's all the primitives that would matter if you're trying to imitate Racket, and the complexity there is why Racket is complicated to build.
For more detail, you might find the paper Rebuilding Racket on Chez Scheme (Experience Report) useful.