-
-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Description
#508 introduces a native code compiler uses LLVM, replacing the bytecode interpreter. The new setup involves a Rust based runtime library, and generated code statically links against this library.
While the generated code supports cross compilation (though we only support a limited number of known targets for now), we still need a runtime library for the target environment. Users of Inko might not have Rust and the necessary dependencies installed (e.g. when installing through a package manager that provides pre-built packages), so we need a way to make it easy to obtain the runtime library for a target environment.
One approach is that we provide pre-built runtime libraries for all supported targets, and extend the `inko executable to support downloading these. I don't want this to be a separate tool (e.g. ivm), as users should be able to cross compile without the need for even more tools.
The mentioned pull request includes some foundational work for this, as the compiler looks for the runtime library in a specific directory, but it only supports a single directory. In case of a system installation that will be something like /usr/lib/inko/...
, and the user likely won't have write permissions to that directory. This means we'll need to extend it to either support multiple directories. This comes with the challenge of having to version that path somehow, as different versions of Inko might not be compatible with each other (e.g. they expect a different structure, or the runtime files need to be different).
Related work
- https://ziglang.org/learn/overview/#cross-compiling-is-a-first-class-use-case
- https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html
Related issues
- Run CI on ARM64 #614: we'll need this if we want to build arm64 runtime libraries ahead of time
Tasks
- Determine if/how to cross compile from e.g. amd64-linux to arm64-mac, and what dependencies are necessary for this
- Extend CI to build runtime libraries for Linux and macOS, relying on Rust's cross-compilation support to do so. Do this when pushing a new release/tag.
- amd64-linux-gnu
- arm64-linux-gnu
- amd64-mac-native
- arm64-mac-native
- Upload the resulting
.a
files to the S3 bucketreleases.inko-lang.org/runtime
. Make sure this doesn't mess up the release process (e.g. generating the manifest) - Add the command
inko runtime add TARGET
which downloads a runtime for the given target into the runtime directory - Add the command
inko runtime remove TARGET
which removes a given runtime - Add the command
inko runtime list
which simply lists all available runtimes