@Luke Boswell is it possible that build.zig is misconfigured for a native build? this is a very shaky area for me, but I tried a native build, and there were some glibc symbols going into a musl build, which:
roc test/host.roc
ld.lld: error: undefined symbol: __vfprintf_chk
>>> referenced by secp256k1.c
>>> .zig-cache/o/68a5a1526d4b3cedd8deaf08a3d7878c/secp256k1.o:(fprintf(_IO_FILE*, char const* pass_object_size1, ...)) in archive test/../platform/targets/x64musl/libhost.a
-- LINKER FAILED ---------------------------------
The linker failed while building for target x64musl
Error: LinkFailed
error: Recipe `test-integration` failed on line 269 with exit code 1
it may just be my build.zig, not sure yet
Codex says:
You’ve got it — the “native” build is faster, but in this project “native” needs to mean “native Roc target,” not “host libc.” On Linux, Roc’s native target is x64musl, while Zig’s default native target is typically glibc. So the current zig build native produces a glibc-flavored libhost.a and then copies it into the x64musl slot, which looks “right” but is actually wrong.
How the two builds differ today:
- zig build (what build-all uses) builds each Roc target explicitly via roc_target.toZigTarget(), so x64musl is truly musl.
- zig build native uses the host target, which is glibc on most Linux distros, and then copies to the Roc target directory. That mismatch is the subtle bug.
Your expectation is totally reasonable; the “native build” just isn’t configured to match the Roc target definition.
If you want, I can fix native in build.zig to use detectNativeRocTarget(...) → toZigTarget() instead of standardTargetOptions(). That keeps the fast build but produces the correct musl target on Linux.
this might be an artifact of my inclusion of libsecp256k1; anyhow it's resolved
Rick Hull said:
this might be an artifact of my inclusion of
libsecp256k1; anyhow it's resolved
At first glance I would guess it was related to this.
What was the issue in the end?
diff --git a/build.zig b/build.zig
index bccf6f4..c5462eb 100644
--- a/build.zig
+++ b/build.zig
@@ -99,13 +99,14 @@ pub fn build(b: *std.Build) void {
const native_target = b.standardTargetOptions(.{});
- // Detect native RocTarget and copy to proper targets folder
+ // Detect native RocTarget based on host, then build using that Roc target.
const native_roc_target = detectNativeRocTarget(native_target.result) orelse {
std.debug.print("Unsupported native platform\n", .{});
return;
};
- const native_lib = buildHostLib(b, native_target, optimize, builtins_module, secp256k1_dep);
+ const native_roc_zig_target = b.resolveTargetQuery(native_roc_target.toZigTarget());
+ const native_lib = buildHostLib(b, native_roc_zig_target, optimize, builtins_module, secp256k1_dep);
b.installArtifact(native_lib);
const copy_native = b.addUpdateSourceFiles();
I am about to publish my nostr-platform repo on github. I think it's feature complete for building the rest of nostr in Roc. But I think I need to rename it. There is nothing in the platform specific to nostr -- it's roc-platform-template-zig, using Zig's sha256, plus libsecp256k1. Any suggestions for repo name?
I have 3 functions from libsecp: create public key, sign a msg/hash, verify a signature. These are all strictly related to "Schnorr Signatures", which are used in Bitcoin (primarily) and later adopted by Nostr Protocol
libsecp256k1 does WAY MORE than Schnorr, and Schnorr is a small optional module. So i am going to to avoid the big mouthful and likely base on schnorr. roc-platform-schnorr or schnorr-platform
schnorr-platform sounds good
for day to day development, is there any reason to build all targets vs just the native target? i assume this is for release rather than dev
Yes, the new basic-cli script allows you to choose: https://github.com/roc-lang/basic-cli/blob/03e94adde676e495d7a80c89b5b54de7ed17af61/build.sh#L87
is there any good reason to build all for edit-build-test cycles?
Not that I can think of
For "hello world" to work with the new compiler, a new user needs a "new compiler" platform. this will be basic-cli by default, when it's ready. but is roc-platform-template-zig the next best alternative? for a new user wanting hello world?
Yes for now the template or possibly something like roc-ray which both have releases.
The basic-cli branch works well enough but you do need to build the platform from source so not as friendly.
@Rick Hull what OS are you running? I could make probably make a an alpha release with just the binary for your system. I could probably add http too if you are wanting to experiment with it.
this isn't for me, really, but I'm running Arch Linux. so, step 1 of "hello world" is first, get a working platform with Stdout. and a binary seems good for that.
referencing some other platform discussion in other channels... what is the future of roc-platform-template-zig ? I can imagine that basic-cli might be a better starting point for my schnorr-platform (not really, just hypothetically). leaving aside Rust vs Zig (I much prefer Zig, in my naivete)
perhaps it becomes basic-cli-zig? or halfway there?
The future plan is to not change it... it's done
ah, nice. I can agree with that
Unless the roc <-> host boundary changes... I don't plan to change anything. It's a minimal platform template that shows just enough functionality for people to see how to build a platform. I aim to have the identical platform API for all the templates, Rust, Swift, C, Go, Zig, etc...
if there were a hypothetical basic-cli-zig would you recommend someone wrapping an importantly-host-only library start with roc-platform-template-zig or basic-cli-zig ?
or is there a better question lurking in here?
I don't really understand the question. What is a hypothetical basic-cli-zig... is that the basic-cli API but with a zig host?
yes, let me rephrase. use basic-cli as a starting point, or roc-platform-template-rust ?
What are you wanting to achieve? keep in mind the crypto primitive should be implemented in Roc's builtins so you could use any platform
I recognize that this might be a poorly conceived question. feel free to answer any related question ;)
I thought your schnorr-platform was a learning experiment to learn more about roc, not necessarily something you plan to publish releases for and support long term
Can you share a link to your platform? I wonder if you might want to implement it as a package instead?
If we assume the crypto primitives are in the builtins (we can simulate that by putting that in a forked platform for now) -- you would explore options to build a higher level abstraction on top of that
this is getting too specific to me. my question is more general, about future stuff and new developers coming here with questions. forget crypto. pick a good example of something that belongs in the host. maybe a fresh new arena allocator. I've got this thing, and I want to expose it to Roc via a platform. the platform templates are a great resource and a minimal way to get started. basic-cli is very comprehensive and provides many modules that might never get used by any given application. I guess to answer my question, I would start with the smallest thing that could possibly work.
Ahk ... so generally I would suggest forking something like basic-cli if you needed all the functionality and wanted the same API (just adding a little more).
I might tell someone: start with roc-platform-template-rust, which gives you basic I/O and memory mgmt. add your host feature, and then start developing roc against your platform. if you find that you need more platform features, you can base your host feature on basic-cli instead.
If you are wanting to build a new platform I would say start with a template so you can see just the parts you need more easily
also, good question about learning vs supporting for the long term. that schnorr-platform is so tiny, porque no los dos? I plan to implement nostr in roc (already done it in ruby)
If you have any interest in implementing Schnorr achieving a Schnorr impl in Roc, I have a line-by-line impl in Ruby that matches the spec nearly 1-1. But this type of impl gives up some timing guarantees, etc. I don't mean that you, Luke, undertake this. but there are reasons not to.
Is schnorr implemented in this? https://ziglang.org/documentation/master/std/#std.crypto
I can take a peek :spectacles:
huzzah! https://ziglang.org/documentation/master/std/#std.crypto.pcurves.secp256k1.Secp256k1
schnorr is an optional module, almost certainly implemented
if it is not a port or wrapper around libsecp256k1 it may be less desirable nonetheless
(this is my sophomoric understanding, not a crypto developer, IANAL etc etc)
If you design an idiomatic Roc module that wraps that zig functionality... you could propose the crypto primitive be added to Roc's builtins in a new ideas thread.
If we have a solid design proposal -- I am reasonably confident I could implement it in no time
@Brendan Hansknecht do you have any thoughts on adding secp256k1 as a primitive?
If you design an idiomatic Roc module that wraps that zig functionality... you could propose the crypto primitive be added to Roc's builtins in a new ideas thread.
I'm gonna call this a.... S T R E T C H G O A L
Rick Hull said:
If you design an idiomatic Roc module that wraps that zig functionality... you could propose the crypto primitive be added to Roc's builtins in a new ideas thread.
I'm gonna call this a.... S T R E T C H G O A L
If you are interesting in working on this... here was the version we almost landed for SHA256 https://github.com/MatthewJohnHeath/rocSHA/blob/1f30fe05e1f617605f8c17c92c2d1ac5290cc667/crates/compiler/builtins/roc/Crypto.roc
That will need some translation to use type modules and associated methods etc... but it should give you some ideas
honestly, my next step is to develop nostr in Roc on top of schnorr-platform; I was just getting comfortable with "old-roc" when I realized there was a "new-roc", and I hardly know either.
Using this topic as a scratchpad, maybe better than creating new topics. Are build.sh and bundle.sh expected to be standards carried forwards? Or would something like justfile or Makefile be better?
The plan is to replace them with build.roc and bundle.roc
ok, good to know!
i haven't looked at these in detail but now on my radar
Those scripts don't exist yet, we have them in the old compiler version of basic-cli for an example
is there a canonical build.roc?
No -- the plan is to use basic-cli for scripting, but we don't have a release for that yet
I'm happy to assist with whatever I can with that, but I need to get much more comfortable with basic-cli ergos
Luke Boswell said:
Brendan Hansknecht do you have any thoughts on adding secp256k1 as a primitive?
Nope... not really.
Last updated: Feb 20 2026 at 12:27 UTC