Skip to content

Multi-OS loader using Cosmopolitan #53

Description

@Destructor17

It is not likely to be possible to compile Webrogue runners againts Cosmopolitan LibC, but why not to write a tiny loader that would detect current OS and launch corresponding runner instead? So

  • The entrypoint (a.k.a loader) is a binary compiled using Cosmopolitan
  • Runners would be embedded into loader using C arrays or using the same tricks to embed compiled WASM into a runner
  • Loader detects current OS and CPU architecture and extracts corresponding runner into memfd, then changes context using execve

But there are a few issues:

  • Neither memfd_create nor execve are found in upstream Cosmopolitan LibC repo. I guess someone simply removed them. So i will have to write inline assembly for that syscalls
  • There should be some way to bundle WRAPP only once by appending it to loader, not each runner, but the problem is how to let runner find loader location or receive loader's fd
  • I guess memfd_create trick will not work on MacOS, so temporary file should be created instead
  • What to do with Windows? It is a bad idea to invoke undocumented Windows syscalls, while functions from dlls like kernel32.dll can't be used in a strightforward way because it will make linkage fail on other OSes. Maybe weak linkage?
  • Does it worth it? "Cosmopolitan GUI app" sounds like a headline that will attract a lot of attention, but such apps may be not fully store-compatable, may look suspicious from an antivirus' point of view, will need more disk space and will consume much more memory and CPU time during startup

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlow importanceSomething not very important

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions