Done first issue! I want to help out some more, which of the current issues do you prefer be taken care of?
Super cool :)
Can you look into the musl target issue with macos from PR#4980. So we want the target to be x86_64-unknown-linux-musl
on linux x86_64, aarch64-unknown-linux-musl
on linux aarch64 and to not change the target in other situations (windows, macos...)
as I recall, macOS has a policy that you're always supposed to dynamically link libSystem
for its libc
so I think we should probably never try to build with musl on macOS :big_smile:
yea ill only update linux
um how do you if at all test platforms without an application?
if you try to cargo build basic_cli you get https://gist.githubusercontent.com/dankeyy/9f0134bdd98a043c37d8fd7ca75cd68f/raw/2cd7503967f64c4d2b86741e5ee7feca6a5ad73b/basic_cli%2520error
In basic-cli/src/Cargo.toml, it is specified that our rust program links the app lib, which is produced by roc, so I just do ./roc_nightly/roc build ../basic-cli/examples/countdown.roc
. I'm not sure if there is some workaround to be able to test platforms in a standalone manner...
I've done basically no platform development
cargo test
should work
cargo build
does not work because the code depends on symbols that roc
needs to provide
but you can run tests so long as they don't use these roc symbols
I'd think cargo check
would also work
Folkert de Vries said:
cargo build
does not work because the code depends on symbols thatroc
needs to provide
yea ik but I just wanted a way to quickly get an object file that I could check if it targeted correctly
you can actually find the target in the error message you posted
oh lmao I didn't even notice
so I did some digging
here's what we cant do:
build.rs
- that feature apparently does not existwhat we can do is kinda meh but it's setting the environment flag CARGO_BUILD_TARGET
somebody even suggested me execing the right cargo commands in build.rs
lol
I think we can do something similar to 1: put println!("cargo:rustc-flags=--target=x86_64-unknown-linux-musl");
in a build.rs with a cfg for os and architecture.
that would get you error: Only
-l and
-L flags are allowed in build script
Too bad...
Can we set CARGO_BUILD_TARGET
in the build.rs?
Anton said:
Too bad...
Can we setCARGO_BUILD_TARGET
in the build.rs?
lol I just now was trying it
I thought so but it doesn't seem to stick
ahhh it's running in a subshell
https://gist.github.com/dankeyy/80fcc9c5d430b865cb89ddab896d83e1
So hacky, but something like this should work. this is a trick rusters (rusteceans?) use to bypass the fact that build.rs runs in a subshell haha
Although on the link error I still see gnu. Haven't figured out why yet but that general direction should work
@Anton
Thanks @dank, it looks acceptably hacky :p
What do you get with ./roc_nightly/roc build ./examples/countdown.roc
? In src/target you should see a folder named x86_64-unknown-linux-musl
if it actually used that target
Anton said:
What do you get with
./roc_nightly/roc build ./examples/countdown.roc
? In src/target you should see a folder namedx86_64-unknown-linux-musl
if it actually used that target
I do actually see that folder so that's good
(btw basic_cli can cargo build now)
but when I look at ldd countdown it seems like it still links with glibc
these are the changes and what came out if you wanna have a look too https://github.com/dankeyy/basic-cli/tree/custom_targets
(I'll gitignore it later but) these look weird
https://github.com/roc-lang/basic-cli/commit/62e4af678f609e103eb4b58b62d9e2f1d283c1e2#diff-6350355364e65408a16e43505e743340cc1c16b136695be77ee0f12ac6fd7a1a
dropping unsupported crate type cdylib
for target x86_64-unknown-linux-musl
I've found that "rustc for musl does not support dynamic linking" from here. I'm going to look into it more after lunch
damn
We had it working earlier when always setting x86_64-unknown-linux-musl with .cargo/config so I'd expect we can solve this.
Can you try without this line?
still glibc
Anton said:
I've found that "rustc for musl does not support dynamic linking" from here. I'm going to look into it more after lunch
even setting the flags like the comment below suggests doesnt seem to effect anything
i may have an idea as to what's going on. hold up
ok I think it was a confusement of roc build on the target path
deleting the custom target_dir arg, it hangs
ill see what i can do
Well bad news.
The hacky approach doesnt seem to effect the build outcome (really not sure why)
Neither does messing with RUST_FLAGS (from within the build script)
and unfortunately neither does this trick I was hopeful for // println!("cargo:rustc-env=CARGO_BUILD_TARGET={}-unknown-linux-musl", std::env::consts::ARCH);
Worst case scenario we could actually just do it from outside the various rust configs, yea? it's just kinda sucky
Maybe I'll come up with something clever later, but for now kinda blocked ¯\_(ツ)_/¯
I've thought of something, we can create or write to an existing .cargo/config file for the CI workflow where the files (.rh1, .o) for linux are generated. Because we only do it in that step, there would be no issues on macos etc. .
yea I've thought of that. but at this point, wouldn't it be easier to just set the env var?
(it should work if we're doing it externally, the only problem in previous approach was that it ran in a subshell)
I know we clear all env vars at some points for better reproducibility, can you check if setting the env var works?
It is indeed the easier solution :)
Anton said:
I know we clear all env vars at some points for better reproducibility, can you check if setting the env var works?
It is indeed the easier solution :)
yea yea. I ran it before to make sure it's a only the subshell's fault that it's still linking with glibc..
it works great
[dankey@computer:~/dev/basic-cli/src]$ CARGO_BUILD_TARGET=x86_64-unknown-linux-musl ~/dev/roc/target/debug/roc build ~/dev/basic-cli/examples/countdown.roc && ldd /home/dankey/dev/basic-cli/examples/countdown
🔨 Rebuilding platform...
0 errors and 0 warnings found in 1532 ms while successfully building:
/home/dankey/dev/basic-cli/examples/countdown
statically linked
Excellent, I'll do a new release of basic-cli on Monday. Thanks for all the help @dank!
I wanted to add some extra testing for the basic-cli release and ended up spending a long time on some refactoring. I should be able to release tomorrow though.
What's up Anton?
I gather something didnt work?
btw is someone working on the editor right now? i saw a couple todos which might be doable for me
My understanding is that editor development has been on hold for a little while, the focus has been smashing bugs and adding core features/stability I think. @Anton mentioned a refactor of the editor is planned to start soon, this half of 2023. I started looking at the Breakout example to learn more and prepare for editor dev, then switched to making my own platform roc-tui
but haven't made much progress recently. I think glue is being upgraded to use a .roc
plugin for code generation and also to support a new way of doing effects without the hosted
module type. This will be necessary for building more complicated platforms, and should enable more host languages to be supportable by glue. I am not sure how progress is on this, if anyone has an update that would be super. :grinning:
Anton is on holiday for a few days. And yeah, active development editor has been on hold; the priority for now is stabilizing the language and pushing along glue and effects.
Having glue work with Roc plugins is currently ongoing. Besides that, a big effort is getting glue to work with generating bindings for closures, which Folkert is working on.
Ayaz Hafiz said:
Anton is on holiday for a few days. And yeah, active development editor has been on hold; the priority for now is stabilizing the language and pushing along glue and effects.
any pressing good first issues in these areas?
@dank I'm not as qualified as most people here. But I think something that I would personally find very helpful is if you were able to write some of the documentation for Abilities
language feature.
At the moment I understand there are a number of Abilities implemented, esp Eq
Hash
Encode
Decode
etc, but there is really limited documentation, especially for making your own custom ones.
Note that I think there was some discussion about changing the syntax a bit because we don't love the current implementation, I will try and dig out that discussion and link here.
You can find information scattered through various tests, merged PRs, and some discussion on Zulip here. But consolidating that into some notes would be super helpful.
I've had a few goes at using abilities and found some bugs. I've not made much progress playing with them as it is difficult for me to separate my lack of understanding and incomplete feature sometimes.
There is a section waiting to be written in the tutorial using markdown at;
www/generate_tutorial/src/input/tutorial.md
And also the documentation comments for the builtins are missing at
crates/compiler/builtins/roc/Encode.roc
and crates/compiler/builtins/roc/Decode.roc
Note there is a design doc in the repo at design/language/Abilities.md
Another idea for anyone to consider. It's writing Roc code, so not really compiler stuff which I think your looking for @dank; but if anyone is interested we could write more parsers, tests and examples.
We've got a parser package at examples/parser/package/main.roc
and examples at examples/parser/examples
.
I started with a plan to write smaller examples to show how to write/use parsers in Roc, and also add more tests, but haven't touched it in a few weeks.
what kind of things are you interested in? if you are interested in type systems and/or compilation (lowering source languages) feel free to DM me; less good first issues there, but we’d love to figure out a project you might like and ramp up!!
@dank sorry, I should have communicated my progress. I'm now ironing out the last bugs on the automated testing of the release. The combination of bash and multiple CI servers makes for a slow feedback loop, but I expect to be done on monday.
Ayaz Hafiz said:
what kind of things are you interested in? if you are interested in type systems and/or compilation (lowering source languages) feel free to DM me; less good first issues there, but we’d love to figure out a project you might like and ramp up!!
thanks. im mostly interested in backend stuff like code gen and optimizations.
i'll finish some unrelated stuff and dm you soon, thanks!!
Anton said:
dank sorry, I should have communicated my progress. I'm now ironing out the last bugs on the automated testing of the release. The combination of bash and multiple CI servers makes for a slow feedback loop, but I expect to be done on monday.
oh no worries! glad it's going ok :+1:
I've made the 0.2.1 pre-release for basic-cli. I've tested it and it works on NixOS :tada:. I'm really glad we got this done, thank you so much for your help @dank!
Note that it's currently using tar.gz instead of tar.br, I'll update it to tar.br on Monday.
Anton I think we've got a small issue though. Are you sure url download works on your nixos?
❯ ldd ~/.cache/roc/packages/github.com/roc-lang/basic-cli/releases/download/0.2.1/Ja9E41aYCiBElYvaSIGl7RY8_kQcdtwApHUcCnt-YDQ/linux-x86_64.rh1
ldd (0x7f4f5519d000)
~/testing/roctests
❯ file ~/.cache/roc/packages/github.com/roc-lang/basic-cli/releases/download/0.2.1/Ja9E41aYCiBElYvaSIGl7RY8_kQcdtwApHUcCnt-YDQ/linux-x86_64.rh1
/home/dankey/.cache/roc/packages/github.com/roc-lang/basic-cli/releases/download/0.2.1/Ja9E41aYCiBElYvaSIGl7RY8_kQcdtwApHUcCnt-YDQ/linux-x86_64.rh1: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, BuildID[sha1]=1ebcd9d14b2c1a1840a12d240ae2a4fbb3624133, with debug_info, not stripped
It's a static-pie
So "statically linked" won't show in ldd rh1
So it will trigger an error on nixOS
Oh I see. Yes it did work on NixOS, I don't know yet why the error was not triggered...
it does trigger on my machine actually
but ofc no reason static-pie wouldnt work (and it does)
so it's a pretty easy fix @Anton
if you'd want I can pr a fix to account for static-pie real quick
This can be done by either querying ldd for (not)"=>" or "ldd".
Or even moving as a whole to using file
instead (tho that's probably not ideal bc then you need to actually regex it in case the path contains "static" haha).
whichever you prefer
querying ldd for (not)"=>" or "ldd".
Sounds good :)
I've uploaded the new tar.br to the basic-cli release assets
So now everything works out of the box in NixOS
❯ ~/dev/roc/target/release/roc dev
Downloading https://github.com/roc-lang/basic-cli/releases/download/0.2.1/wx1N6qhU3kKva-4YqsVJde3fho34NqiLD3m620zZ-OI.tar.br
into /home/dankey/.cache/roc/packages
hellooo
that's so cool
WOOOO!!!!! :tada: :tada: :tada:
amazing job getting that working!
that's fantastic - so now we have a template that future Roc platforms with Rust hosts can use for how to Just Work across Linux distros, even Nix! :smiley:
oh also it means we can drop this note in the tutorial now :big_smile:
Screen-Shot-2023-02-24-at-12.44.19-PM.png
Yeah, I have had a PR up for it for some time but I'm still encountering a difficult to debug CI issue
oh weird
Last updated: Jul 06 2025 at 12:14 UTC