roc: get_builtins_host_obj_path requires `lib/` when that doesn't make sense for the platform

As of 43f9e2a7 (#1848), Roc requires a lib directory to be present by requiring it with an expect in get_builtins_host_obj_path in crates/compiler/builtins/src/bitcode.rs. This doesn’t always make sense, for example in Rust platforms. Should that function return an Option<String> or something?

cc @Anton-4 since you were working on that PR

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 20 (20 by maintainers)

Most upvoted comments

hopefully it will be ~/.cache/roc

Oh shoot, I forgot that this is used for the host object and the zig source files.

So another addition. The host object file doesn’t make sense and needs to be remove. Host is a very specific target and does not makes senses to distribute. It could use instructions that are not available to the end user.

I am pretty sure this object file is only needed for the dev backend. This code is generated with llvm bytecode in the main backend. It might be reasonable to generate generic versions of this file for each architecture and ingest them into the roc app, but that would bloat the roc app for every single target we want to support (currently by about 260k). Not huge, but would add up across os, cpu architecture pairs.

We don’t want Roc to depend on zig being installed, so we don’t want to ingest the zig files directly. Though that would be a simple solution. Ingest the zig files and compile them into an object file on the host. Instead, I think the best solution here is to use the ingested llvm bytecode to generate this object the first time that roc is run per target. Then we dump it to disk in some sort of global roc related cache and it will only need to be generated again when Roc updates.

The long-term goal is definitely to have the compiler be a standalone binary, so I’m adding the bug label to this!