Stream: beginners

Topic: Error with dynhost


view this post on Zulip Jared Cone (Sep 23 2024 at 00:03):

I'm on Linux trying to build/run some of the examples but they keep throwing an error for unable to find "dynhost":

~/External/basic-cli$ roc build.roc
🔨 Rebuilding platform...
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
failed to open file "platform/dynhost": No such file or directory (os error 2)
Location: crates/linker/src/lib.rs:552:29

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:12):

Which version of Roc are you using?

view this post on Zulip Jared Cone (Sep 23 2024 at 00:17):

latest nightly, roc nightly pre-release, built from commit 3215a8f on Mi 18 Sep 2024 09:01:58 UTC

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:20):

Okay, I've reproduced

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:22):

I think I understand the issue. Grabbing some links

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:25):

@Luke Boswell I'm actually not quite sure what's happening here. Could you give some context?

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:27):

Okay, I got it. We forgot to update the import in the build script to use a prebuilt version of the CLI: https://github.com/roc-lang/basic-cli/blob/0ac2f5ccb16c4ba503074511bc247f18440b565f/build.roc#L2

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:28):

@Jared Cone please replace the line I linked above with the latest release of basic-cli: https://github.com/roc-lang/basic-cli/releases/tag/0.15.0

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:28):

And then the instructions in the readme should work!

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:28):

I'll make a PR to fix this

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:32):

https://github.com/roc-lang/basic-cli/pull/249

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:33):

Would appreciate an approval from any onlooking maintainer!

view this post on Zulip Jared Cone (Sep 23 2024 at 00:34):

yep fixed, thanks!

view this post on Zulip Jared Cone (Sep 23 2024 at 00:38):

do all the examples need to be updated to use the downloaded platform too?

view this post on Zulip Sam Mohr (Sep 23 2024 at 00:58):

Within basic-cli, I don't believe so.

view this post on Zulip Sam Mohr (Sep 23 2024 at 01:00):

We try to strike a balance for now between "relative path platforms are lower maintenance" and "downloaded platforms are robust"

view this post on Zulip Sam Mohr (Sep 23 2024 at 01:00):

So in the future once package management is more deeply investigated, maybe that'll happen

view this post on Zulip Sam Mohr (Sep 23 2024 at 01:00):

But for now, it's staying as-is

view this post on Zulip Luke Boswell (Sep 23 2024 at 02:19):

Jared Cone said:

do all the examples need to be updated to use the downloaded platform too?

I've been thinking maybe we should rename these to tests or something. They're kind of serving two purposes at the moment. Maybe it's better to direct people to the examples repo instead, and add a label over there like basic-cli to it's easy to see which examples are using the platform.

We've got a new release process we will hopefully switch over to soon, and the idea is that roc main branch can move forwards independently of the platforms. But users of roc won't be affected as all the supported platforms will be kept in sync by using a recommended or latest release. So the URL version of examples will work, but we haven't really discussed the examples folder in the platforms
I think they should keep referring to the local path because we need them for CI and testing locally.

view this post on Zulip Jared Cone (Sep 23 2024 at 05:39):

I'm trying to get a C host up and running using https://github.com/lukewilliamboswell/roc-platform-template-c as a starting point. I've got roc build.roc working and it seems to be generating a platform/linux-x64.a file. However when I run roc app.roc it throws the same error as above:

roc app.roc
🔨 Rebuilding platform...
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
failed to open file "platform/dynhost": No such file or directory (os error 2)
Location: crates/linker/src/lib.rs:552:29

view this post on Zulip Oskar Hahn (Sep 23 2024 at 06:07):

Try to run your application with "--linker legacy".

I think the roc-platform-template-c only creates the files for the legacy linker. But on linux, the surgical linker is used as default. To fix this, would need also to create the dynhost file and the other files needed for the surgical linker.

view this post on Zulip Oskar Hahn (Sep 23 2024 at 06:16):

This are the steps to do this:

  1. First create a simple example app, that uses your platform.
  2. You create a libapp.so by calling roc build main.roc --lib --output libapp.so on this example.
  3. Then, you create dynhost by compiling your host (c-code) linked to the libapp.so
  4. You move the dynhost inside your platform, next to the main.roc-file inside the platform.
  5. As a last step, you call roc preprocess-host PATH/TO/dynhost PATH/TO/PLATFORM/main.roc PATH/TO/libapp.so, which creates to more files inside the platform.

view this post on Zulip Luke Boswell (Sep 23 2024 at 06:26):

We dont have a std lib implementation ir a working glue spec for C yet, so things can get a bit challenging for more complicated platforms. Definitely something I am sure will exist in time, it's just needs some elbow grease to get there.. and the focus has been on rust mostly at this stage as things are still in flux on the platform development side of things.

view this post on Zulip Luke Boswell (Sep 23 2024 at 06:58):

Regarding building the prebuilt binaries for the legacy and surgical linkers, I made this diagram for basic-cli. It was on the README but we must have removed it at some point. That illustrates the process.

view this post on Zulip Luke Boswell (Sep 23 2024 at 06:59):

Oh, I guess we removed it because we had to change the layout of crates slightly to fix a segfault.

view this post on Zulip Anton (Sep 23 2024 at 07:01):

Yeah, it's linked in the crates README. The reasoning was that most people viewing the main README do not need details on the build process.

view this post on Zulip Anton (Sep 23 2024 at 07:01):

And in build.roc too

view this post on Zulip Luke Boswell (Sep 23 2024 at 07:01):

Oh nice, I hadn't noticed the crates README

view this post on Zulip Jared Cone (Sep 23 2024 at 15:24):

Ah thanks, I guess I'd better stick with rust for that std lib :)


Last updated: Jul 06 2025 at 12:14 UTC