News for hackers. Stuff that matters.
Re:Aro – Zig's new C compiler by o11c on Saturday July 20, 2024 @03:30PM (#41019054)
Generally, the hard part isn't the cross compiler (nor, these days, the cross binutils), but the cross libraries. There are at least 3 ways (/usr/lib/$ARCH, /usr/$ARCH/lib, /$CHROOT/usr/lib/) to set up the libraries, all incompatible with each other.

Zig is notable for putting a lot of work into hard-coding basic C libraries, though of course you still need a scattering of other C libraries for most real-world programs.

(for a sufficiently advanced language ecosystem, the language's own libraries should be easy enough)

Re:Aro – Zig's new C compiler by wucke13 on Saturday July 20, 2024 @07:11PM (#41020900)
The nixpkgs have a rather elegant way to deal with that. Let's presume you need a libpng for an armv7 platform, such as an old RaspberryPi. Then Nix allows you to

- get a suitable cross compiler toolchain

- pick whether you want dynamic or static linking (most likely static when the target system does not come with /nix/store)

- compile all prerequisites for the library such as transitive dependencies

- compile the library with the cross compiler for the selected target arch

All in one command line call, that does not require you to 'apt-get install' any of the tools manually:

  nix-build '<nixpkgs>' -A pkgsStatic.libpng --arg crossSystem '{ config = "armv7a-unknown-linux-gnueabihf"; }'
Re:Aro – Zig's new C compiler by Cloudef on Sunday July 21, 2024 @01:35AM (#41022663)
You can combine zig and nix with <https://github.com/Cloudef/zig2nix> (shameless plug)