A while ago I found an interesting blog post about writing an operating system in Rust.
I'm curious, what it would take to implement something similar using Swift?
I did read this post:
Creating a new Platform, SDK, and toolchain, resources?
however I did not find improvements in this area on any roadmap so far.
Are there any interesting compiler flags that would let me cross compile for any LLVM supported architecture without creating a completely new toolchain from scratch? I know I can avoid linking the standard library, but that's not very useful when even integers are part of it. Is it possible for non standard library code to access the builtin types without building the compiler somehow?
Other issues I can think of are lack of inline assembly etc.
I really don't want to build Swift from source, last time I tried I ran out of SSD space and my MacBook crashed.
i.e. what would it take to at least draw "Hello world!" to the screen without an operating system?
edit:
As a starting point it would be interesting to know how to print hello world just generating an object file, without the Swift module; Linking with libc/darwin and writing to stdout is not enough because I have no way of expressing arrays of integers.
And that's a problem still even if I somehow have access to the builtin module, because how can I implement an Int8 array without pointers?
I would probably have to add these first, right?
But to do anything I first need builtin types; I assume it would be pretty simple to just compile for whatever architecture I need, or add assembly files
I searched everywhere but I couldn't find anything, and the Swift source code is massive
ok I figured out this part, can I get Builtin to show up in VS Code?
I think what I'm essentially trying to do is write a custom less OS dependent "standard library" from scratch, I should probably move this to a different category
edit 2:
Another issue, I'm stuck with top level code but it would probably be nice to have a main() function; I could probably do so using clang, but I'm not sure if it's going to cause issues when Swift is in top level code mode; can swiftc generate normal Swift?
Where can I even find documentation on this?