Shop OBEX P1 Docs P2 Docs Learn Events
[Tool] loadp2 ported to CGo-free Go – Linux/amd64 ready, looking for Windows/Mac hackers! — Parallax Forums

[Tool] loadp2 ported to CGo-free Go – Linux/amd64 ready, looking for Windows/Mac hackers!

Hi everyone,

I’ve been working with the Propeller 2 and wanted a version of the loadp2 utility that didn't require fiddling with C compilers or toolchains, so I decided to port it to Go.

The port is completely CGo-free. If you have Go installed, you can grab the latest version and build the binary in seconds with a single command:

$ go install modernc.org/loadp2@latest

Current Status:

Right now, the tool successfully scratches my own itch, so it currently only supports the linux/amd64 target.

Call for Contributors (Windows / macOS / ARM):

I would love to see this become fully cross-platform so the whole Go community can benefit from easy, dependency-free binaries. If you are on Windows or macOS and want to help, I've included a HACKING.md in the repository. It documents the exact, step-by-step process I used to create the Linux port, which should serve as a clear roadmap for adding other targets.

You can find the repository and the HACKING guide here: https://gitlab.com/cznic/loadp2

A big thank you to Dave Hein and Eric R. Smith for the original C implementation that made this possible.

If you are on Linux, please give it a try and let me know how it works for you! And if you decide to take a swing at the Windows or macOS ports, feel free to open a PR or ping me with questions.

Cheers,
jnml

Comments

  • ElectrodudeElectrodude Posts: 1,686
    edited 2026-02-26 06:21

    This ccgo tool that you're evidently the main author of seems like it should be really nice for getting native Go versions of C libraries, but is there a practical point in running it on a top-level C program like loadp2 besides seeing whether it will work?

    Do you intend for this to become the starting point for an idiomatic Go version of loadp2? If so, I'd definitely want to use it over the C version once it's done. But then what's the point of running ccgo for each platform as described in HACKING.md - wouldn't it be better to have a single Go codebase for all platforms? Can you make your tool make the file structure of the Go output mirror that of the C input, rather than just emitting one giant file? I feel like porting it by hand would be an easier route to an idiomatic port - trying to manually untangle all the C-isms and reimplementations of basic Go features looks like a nightmare. If your goal isn't an idiomatic Go port, using this on a top-level program is just a C compiler with extra steps; an easier way to get a dependency-free build of loadp2 would be to just make a fully statically-linked build of the regular C version.

  • It's cool that you have ported this to Go (automatically, even). What are your plans for it?

    I notice in the HACKING.md you suggesting cloning the whole flexprop repo. There's no need to do that for just loadp2, it has its own repo at https://github.com/totalspectrum/loadp2.

  • So your goal is to replace "fiddling with C compilers or toolchains" (???) by fiddling with the Go compiler/toolchain (singular)? I'm not sure what you're trying to accomplish there, especially since the result of transpilation by nature is single-target and not really a good place to start doing any actual code changes (and god forbid you want to integrate upstream improvements later down the line). As @Electrodude mentioned, if you want a ready-to-go static executable loader on linux systems, you can just build with static libc - we do this on every commit for spin2cpp CI builds, I can probably add CI for loadp2, too.

    Also ai slop kitsch header image in a git repo is like the worst code smell imaginable, IMO.

Sign In or Register to comment.