I'm investigating how easy/hard is it to generate distro-independent binaries.
I think what you're looking for is to statically link libc into your program; probaly the easiest way to do it is to use musl-gcc toolchain. https://stackoverflow.com/questions/73393568/how-to-dynamically-link-your-nim-application-against-musl should be a good starting point
statically link libc into your program
Well, if I have to use libc, I'd rather use my own implementation of the needed libc functions (where I can use syscall s directly). To elaborate, our end goal is to have a library that we can compile to multiple Linux distros, some embedded platforms, and maybe webassembly.
Is there a list of libc functions that Nim uses?
This section of the compiler manual may be useful:
https://nim-lang.org/docs/nimc.html#nim-for-embedded-systems
For info compiling an hello world program with nim c --gc:arc --os:any -d:useMalloc on linux uses the libc functions:
U calloc@GLIBC_2.2.5
U exit@GLIBC_2.2.5
U fflush@GLIBC_2.2.5
U free@GLIBC_2.2.5
U fwrite@GLIBC_2.2.5
U __libc_start_main@GLIBC_2.34
U malloc@GLIBC_2.2.5
U memcpy@GLIBC_2.14
U memset@GLIBC_2.2.5
U realloc@GLIBC_2.2.5
U signal@GLIBC_2.2.5
U __stack_chk_fail@GLIBC_2.4
U strlen@GLIBC_2.2.5