When trying to build the basic-webserver platform I'm hitting Undefined Symbol in relocation
like in #3609 when on linux x86-64. I can build with the legacy linker and builds for all other OS' and architectures passed. Should we still do a release of basic-webserver if it does not work on linux x86-64 with the surgical linker @Richard Feldman?
I'd say yes :+1:
it's worth it to get something all the new beginners will be able to try with a URL tomorrow
we can tell people to work around it with --linker=legacy
for now
Assuming my code works correctly, roc should automatically use the legacy linker when it realizes there is no surgical linker file
Awesome, I'll try that out
Also, I think this may be a bug caused by rust dead code elimination, I'll take a look. Oh, maybe I can also make rust glue for functions generate the special code to avoid garbage collection of our effect functions....
Is this on main?
I got the undefined symbol in relocation
while using the more-features of basic-webserver, I was also using export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
roc should automatically use the legacy linker when it realizes there is no surgical linker file
That worked, I did end up getting a segfault when running the example on NixOS, going to try out macos aarch64 now.
macos aarch64 test succeeded
going to try out ubuntu now
segfault on Ubuntu too when running the todos example.
To prevent setting a large share of users up for disappointment I think we should not make an official release of the basic-webserver platform right now. What do you think @Richard Feldman?
It's still an amazing feat we got the webserver this far though :heart:
Interesting. I wonder why it segfaults for you. gotta love works on my machine.
I'll do more testing later
Is it just todos that is segfaulting?
I wonder if the sqlite db I created on arm64 isn't ok when used on linux-x64, I assumed it would be identical because it's the sqlite format but maybe not. I did a quick search and that was inconclusive
Oh, are you testing using current main or that PR branch? Current main will be broken on all other systems except macos arm64 because glue generates invalid rust code and you have to fix manually. On the PR branch I went through and fixed for all architectures so that should be ok.
I should be using the more-features branch everywhere. The Linux .o is also built for musl, so the segfault may only replicate with that target. I ran without DB_PATH on Linux so it should not be the sqlite3 file that causes the segfault. I did not test the other examples but the todos is the most important one.
This is the pre-release url btw:
https://github.com/roc-lang/basic-webserver/releases/download/temp-test-0-1/znf7xalzBi9Wn8vSrgw1YIEd2XcqAvgg8EDZiH4lPGs.tar.gz
I can reproduce the segfaults on my linux machine :cry:
@Brendan Hansknecht I am highly suspicious of the glue issues (https://github.com/roc-lang/roc/issues/6012) though I don't think this is likely the cause of this issue.
I don't think we ever tested previous versions on linux so it could be a more fundamental issue with the implementation of the server.
I don't think it is hyper as it boots up the server and binds to localhost, and looks like it accepts a connection. Maybe it fails as soon as it calls into Roc (the force_thunk method on RocFunction_86 closure related or something)?
so it segfaults even when using the legacy linker?
to answer the question directly: if we can't get it working, I actually still think we should release 0.1 (with a prominent note that Linux isn't supported yet) just so some beginners can try it easily.
Regardless of whether there's a release, Linux users won't be able to use it at all. At least if there's a release, people on other operating systems can try it without needing Rust installed etc.
in fact I'd be fine with saying just go ahead and release 0.1 right now, add prominent notes that it won't work on Linux, and then we can plan to do an 0.1.1 release that fixes Linux as soon as we can figure out a fix! :smiley:
@Brendan Hansknecht you mentioned it works on your machine - is that an x64 Linux machine?
Ok yeah, I see the segfault. Probably tested something local before
Not yet sure what is going on, but it seems that the string being passed to stdout.line does not make sense (maybe it is a seemless slice or small string being handled incorrectly). Commenting out the logging in the todo.roc fixes the issue.
So maybe a bug in RocStr
, maybe a bug in roc code gen.
hmm, may also be some sort of pointer passing related change. I think some reason roc stdoutline expects a return value now? @Folkert de Vries maybe a bug in your resent changes around cabi always using pointers?
oh wait, actually, it is supposed to return a result with error.
Oh, so this is just a simply function glue mismatch. I think roc_fn
needs to be regenerated
Claims to return nothing:
https://github.com/roc-lang/basic-webserver/blob/a9b32ff9425095d51d08928c433bf064176cbd11/platform/src/roc_fn/src/lib.rs#L63-L66
Claims to return an error:
https://github.com/roc-lang/basic-webserver/blob/a9b32ff9425095d51d08928c433bf064176cbd11/platform/Effect.roc#L47
so we should just need to make those match. Either drop the return type from the roc side or regenerate the function glue and change the rust type to return an error.
oh I definitely think those shouldn't return an error
This probably also effects flush
(we can have a more advanced version that returns an error, but the 99% use case is to assume writing to stdout will succeed)
Yeah, in that case, we should just need to update the roc side to fix the segfault
nice! Can you make a PR for that?
Should flush return an error? I assume not as well?
let's have it not for now, can revisit in the future if necessary
https://github.com/roc-lang/basic-webserver/pull/10
@Anton I assume you're done for the day, but if you can verify that it works on x64 Linux for you and cut a release tomorrow, that would be fantastic! :smiley:
given time zones, I think the math works out that we could have that on the site in time for the release :big_smile:
Thank you @Brendan Hansknecht so glad you found that!! Sorry for breaking it :smiling_face_with_tear: . I was part way through changing them all over to return errors, and then aborted the change and didnt undo it properly as it had the flush addition.
Awesome work @Brendan Hansknecht! A new release is building
:tada: release is up
Release is working well! I already used it in the new roc-pg example: https://github.com/agu-z/roc-pg/tree/main/examples/store
Last updated: Jul 06 2025 at 12:14 UTC