Free Standing Compiler
Socktt opened this issue · comments
⭐️ Proposed change
An option to compile free standing code
🤔 Rationale
I am trying to write an operating system kernel in emojicode (because I hate myself)
🕺 Example
Something that functions similarly to -ffreestanding in gcc but for the much better programming lanugage emojicode
How do you plan to handle Emojicode's runtime, which relies on dynamic allocation?
How do you plan to handle Emojicode's runtime, which relies on dynamic allocation?
No runtime runtimes are for nerds
That does not translate to an implementation strategy for -ffreestanding
though.
Let me provide some details on this for future reference as its an interesting question:
As @NieDzejkob mentioned, Emojicode allocates class instances on the heap and manages them with reference counting.
A kernel project might provide a different implementation of the runtime, though. See ejc*
functions here.
One could also only use a subset of Emojicode that does not use any dynamic allocation. Such a subset would prohibit the use of classes (only value types), casting, generics, closures, and any other mechanism that makes use of boxing. Binaries will still require some runtime support such as ejcPanic
.
Moreover, our implementation of the s package relies on the C standard library for certain operations, like random number generation or printing strings. Also, it makes heavy use of classes. The same strategy could be applied here: Either not use these APIs or reimplement the s package. The compiler relies on certain types, though.
Finally, you'll want to link everything yourself. The Emojicode compiler supports a -c
flag, which produces an object file.