The compiler isn't the issue here, the runtime is, and runtimes inherently have to be written in unsafe code because the underlying hardware architecture and operating system APIs are themselves unsafe. (With the exception of some very obscure and obsolete hardware from the 70s and 80s.)
It doesn't follow that anything but the lowest-level wrappers that call into the OS APIs have to be unsafe. Those wrappers can be a tiny fraction of the runtime code.