Stream: compiler development

Topic: roc build


view this post on Zulip Brendan Hansknecht (Oct 26 2025 at 17:00):

Question on roc build with the interpreter. It basically should be the same as roc run except that it will

  1. build the roc module env and serialize it via llvm to a global constant in an object file
  2. use a different version of the interpreter shim that loads from this global instead of from shared memory
  3. link all of those together into a standalone binary

Does this sound correct?

view this post on Zulip Richard Feldman (Oct 26 2025 at 17:14):

yeah that sounds right to me!

view this post on Zulip Brendan Hansknecht (Oct 26 2025 at 18:48):

For our ipc, I see parent_base_address. Trying to makes sure I understand this correctly. Instead of serializing in a pointer free format, we serialize with pointers, but then shift them between the two different address spaces. Is that what is happening here?

Trying to understand the ramifications of serializing to a slice of bytes instead of to a shared mem allocator.

view this post on Zulip Brendan Hansknecht (Oct 26 2025 at 18:48):

Something just feels a bit off to me

view this post on Zulip Notification Bot (Oct 26 2025 at 18:52):

4 messages were moved here from #contributing > Worklog (Draft PRs and coordination) by Richard Feldman.

view this post on Zulip Richard Feldman (Oct 26 2025 at 18:55):

so the basic procedure is:

view this post on Zulip Richard Feldman (Oct 26 2025 at 18:55):

does that clarify? Happy to answer any follow-up questions about it!

view this post on Zulip Brendan Hansknecht (Oct 26 2025 at 19:04):

That overall makes sense. I still don't quite understand why we serialize: parent_base_addr: u64, over the IPC. What is the parent in this case? the entire module+header?

view this post on Zulip Richard Feldman (Oct 26 2025 at 19:08):

I forget offhand, but I think it's the base address of the ModuleEnv

view this post on Zulip Brendan Hansknecht (Oct 26 2025 at 19:45):

Oh cool, got it working!

view this post on Zulip Brendan Hansknecht (Oct 26 2025 at 19:45):

That was surprisingly easy

view this post on Zulip Brendan Hansknecht (Oct 26 2025 at 19:45):

That said, right now I have a hacked rocRun that builds an exe

view this post on Zulip Brendan Hansknecht (Oct 26 2025 at 19:45):

Need to make it a separated updated rocBuild path.

view this post on Zulip Brendan Hansknecht (Oct 26 2025 at 19:46):

standalone roc binary

view this post on Zulip Luke Boswell (Oct 26 2025 at 21:43):

Niiice :grinning_face_with_smiling_eyes:

view this post on Zulip Brendan Hansknecht (Oct 27 2025 at 00:08):

For roc build, instead of ever touching shared memory, I should be able to:

  1. create the module env in standard gpa/arena.
  2. create a new arena (or block of bytes) for what will be serialized.
  3. write the header at the start of the area
  4. serialize the module env into the bytes

Right?


So it will be a little bit of rearchitecting to do that, but nothing too bad. Probably the biggest hassle is that I want to factor it well instead of duplicating the code as a slight variant.

view this post on Zulip Brendan Hansknecht (Oct 27 2025 at 00:08):

Nothing hard, just cleanup/organization.

view this post on Zulip Richard Feldman (Oct 27 2025 at 00:21):

sounds right, yeah!

view this post on Zulip Brendan Hansknecht (Oct 27 2025 at 00:49):

Also, I am a little confused that our current module even shared memory thing. It doesn't actually call moduleenv.serialize. I guess it kinda just adhoc deals with everything instead to avoid an extra copy to serialize.

view this post on Zulip Brendan Hansknecht (Oct 27 2025 at 01:35):

Also, hmm. I guess an arena is not guaranteed to be contiguous given it is a linked list of blocks. So either I need to still used the shm allocator.

I guess using the shm allocator is actually the minimal amount of copying (though not sure if it would include some extra unneeded data being serialized).

Cause shm allocator is:

  1. writing to the allocator
  2. write to disk via llvm.

Vs gpa/arena would be:

  1. write to allocator
  2. serialize to flat array of bytes
  3. write to disk via llvm.

view this post on Zulip Brendan Hansknecht (Oct 27 2025 at 01:36):

So assuming the shm allocator isn't accidentally including extra bytes or otherwise significantly costly to create. It likely is the nicest way to handle all of this.

view this post on Zulip Brendan Hansknecht (Nov 03 2025 at 19:53):

Just an update: I still just have the prototype working on a branch. It is a hacked roc run that builds and runs. Hoping to get back to his later this week or early next.

Since I am planning to anchor to shared mem, I think it will make the refactoring to land pretty small. Mostly need to enable running the roc app compilation step at two different potential locations. For build it has to run before all the linking. For run. It should run after (or eventually in parallel)

view this post on Zulip Luke Boswell (Nov 04 2025 at 00:58):

So hyped for this. Will be really nice to unlock wasm based platforms.


Last updated: Nov 08 2025 at 12:13 UTC