Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Compile to standalone x86_64 code for bare metal. #251

Open
ApplePieCodes opened this issue Jun 16, 2024 · 3 comments
Open

Feature: Compile to standalone x86_64 code for bare metal. #251

ApplePieCodes opened this issue Jun 16, 2024 · 3 comments

Comments

@ApplePieCodes
Copy link

If possible, could you attempt to implement this feature. It would make Operating System Development much easier.

@titzer
Copy link
Owner

titzer commented Jun 16, 2024

Interesting, and not too far-fetched. Currently the compiler can produce ELF and Mach-O x86-64 binaries. In both cases, the compiler inserts only a little bit of startup asm code, and the rest of the runtime system and GC is written in Virgil. There are a handful of syscalls in the compiler-inserted asm code to set up signal handling and the stack, but the rest is in Virgil using Linux.syscall or Darwin.syscall. So switches to turn off that would allow generating a standalone ELF file, which a bootloader could load into memory.

@ApplePieCodes
Copy link
Author

Maybe add an asm running command like rust's asm!().

@khaledh
Copy link

khaledh commented Nov 8, 2024

I'm interested in this as well. I've been developing a kernel in Nim, but I'm always on the lookout for interesting system programming languages. I'd love to give Virgil a try, but without official bare metal support it would be hard.

Things I look for in a language to support kernel programming:

  • Freestanding (no stdlib, no OS) output
  • Customizable virtual memory page allocator
  • Deterministic memory management (no random GC pauses)
  • Unsafe pointers
  • Custom data layout (Virgil seems to have nice support here, but it's byte-level, would be nice if there's bit-level layout support as well)
  • Naked functions (no prolog/epilog) for interrupt handlers

Nice to have:

  • Customizing executable layout
  • Inline assembly, or at least a stable ABI
  • UEFI target (for the bootloader)

I'm pretty sure I forgot other things, but that would be a good start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants