Stream: beginners

Topic: roc build output


view this post on Zulip Luke Boswell (May 28 2023 at 04:05):

I was attempting to build a roc binary and reached for a command line argument -o but we dont support roc build -o output input.roc. Just wondering why that is? Is it strange that the output binary is determined in the file?

view this post on Zulip Brendan Hansknecht (May 28 2023 at 04:12):

This is similar to most build systems: cargo in rust, cmake or make (I think zig build where it would be defined in build.zig).

I think it is a question of if you see roc as a build coordinator/system or something that should compile individual files...

But that is just my guess.

view this post on Zulip Luke Boswell (May 28 2023 at 04:47):

I don't have a strong opinion here, just noticed this while I was working on something. I have written another app which compiles some roc script files, but don't have a good way to know what the resulting binary will be called or where it will be located. I may be approaching this the wrong way, basically I'm experimenting with a CGI server which on load compiles all the "scripts" into binaries, and then on a request calls the roc binary/executable.

view this post on Zulip Richard Feldman (May 28 2023 at 11:20):

I've actually been thinking about switching to this

view this post on Zulip Richard Feldman (May 28 2023 at 11:20):

right now it's defined in the app module

view this post on Zulip Richard Feldman (May 28 2023 at 11:20):

e.g. app "mybinaryname"

view this post on Zulip Richard Feldman (May 28 2023 at 11:20):

that design is from ~2019 and I think maybe doing it at the command line might make more sense

view this post on Zulip Luke Boswell (May 29 2023 at 07:12):

@Richard Feldman would you accept a PR for this change, or do we need more discussion to understand the implications? Do you have any thoughts on removing the app name string from the module header? I can create an issue to track this, and reference this conversation.

view this post on Zulip Anton (May 29 2023 at 10:10):

If no "-o" is provided would we then default to the filename without ".roc"?

view this post on Zulip Richard Feldman (May 29 2023 at 11:23):

Anton said:

If no "-o" is provided would we then default to the filename without ".roc"?

that sounds good - and with .exe on Windows

view this post on Zulip Richard Feldman (May 29 2023 at 11:23):

yeah I think PR is fine!

view this post on Zulip Fábio Beirão (Jun 01 2023 at 12:47):

@Anton I believe that once you have this PR you will fix the issue I opened a few minutes ago about empty app names, or even worse, app names with paths on it :sweat_smile:

view this post on Zulip Fábio Beirão (Jun 01 2023 at 12:49):

So it is indeed important to implement the "if no -o is provided, we default to the filename (instead of the app name) :+1:

view this post on Zulip Anton (Jun 02 2023 at 08:51):

Thanks for alerting us to the security issue @Fábio Beirão, I've made issue #5501 for first step fix. I've marked it an intermediate issue because I don't think it will be complicated but familiarity with the code base will make it easier. If no one wants to take it, I will.


Last updated: Jul 06 2025 at 12:14 UTC