Is there a way to instruct roc cli to build a rust platform and use debug instead of release? I am trying to debug some things using dbg!
macros and not sure how to do this when using roc dev myapp.roc
which rebuilds the platform.
If you don't pass --optimize
it should build a rust platform in debug mode.
As long as you have a local platform of course that is getting built from source
So, packages { pf: "../src/main.roc" }
should be building and running in debug then?
hmm, I think there is something else going on here. Thanks @Brendan Hansknecht
yeah, should be. You should see roc saying rebuilding host.
also, you should be able to delete target/release
and it should still run without recompile. Cause it will use the rust debug build
It looks like bdg is working. I think the issue is something about my "glue" types and passing values between Roc and rust
dbg*
@Brendan Hansknecht can you please have a look at this? Am I missing something obvious here? I feel like maybe I can't just pass a command_glue::Command
straight into the roc_fx_commandStatus
?
# Effect.roc
commandStatus : InternalCommand.Command -> Effect U8
# InternalCommand.roc
Command : {
program : Str,
args : List Str, # [arg0, arg1, arg2, arg3, ...]
envs : List Str, # [key0, value0, key1, value1, key2, value2, ...]
}
// command_glue.rs
#[derive(Clone, Default, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, )]
#[repr(C)]
pub struct Command {
pub args: roc_std::RocList<roc_std::RocStr>,
pub envs: roc_std::RocList<roc_std::RocStr>,
pub program: roc_std::RocStr,
}
# lib.rs
pub extern "C" fn roc_fx_commandStatus(cmd: &command_glue::Command) -> u8
That looks like it should be correct to me
I had it working fine just passing in a RocStr
but recently changed it to the struct Command
One guess, maybe it explicitly needs to be a pointer instead of &
Does it work if you remove one of the fields?
I've just pushed my WIP to #55
I'll try removing all the fields except the RocStr
Yeah, it works ok removing the args
and envs
fields from command_glue::Command
My current guess is that is is related to #5544 and since the size is 72 bytes (which is over 64 bytes) it becomes a pointer.
So it should work with 2 fields, but fail with 3
With 3 probably just need to change the input type to a pointer.
but maybe something more complex is needed
Ok, thanks. It doesn't work with two or three fields.
To change to a pointer, I need to use a Box type right?
Hmm. breaks with 2. Maybe it is something else, not sure. Anyway, I would test with a *const command_glue::Command
Works!! :tada:
Thank you
Pushed to this commit in case anyone finds this thread in future and wants to know how to use Box as a workaround here.
Hmm. that isn't what I meant, but is a patch I guess. Pretty wasteful to just box for that. Though it is always a workaround to any glue issues.
My suggestion would not use box on the roc side at all. It would just use the pointer on the rust side.
Not saying my suggestion would work, but this api definitely should work without any box on the roc side.
Hmm. I just tested your code on my m1 mac and I think your original code works just fine. Like without any changes....hmm
Last updated: Jul 05 2025 at 12:14 UTC