tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

GNU tools netbsd vs netbsdelf



Hello,

First, allow me to give some general background about why we care about this; feel free to skip this paragraph if uninterested. We Nixpkgs/NixOS developers aim to support cross compilation to as many notable platforms as possible. Recently, that's involved polishing our support for NetBSD. You can see some of the code here [nixpkgs-netbsd] if you like. Because we support so many platforms, it is very important we remove special cases / keep overall complexity in check. Issues like this that might seem bit obsessive-compulsive really are important to us, but these special cases do add up if left alone.

The issue we've encountered is that GNU tools don't seem to support dynamic linking properly for cross compilation when the "OS" part of the config is "netbsd"; they seems to require "netbsdelf" instead. Likewise, I've found some traces of "netbsdaout" being in usage in GNU config's config.guess [gnu-config-netbsdaout]. It would appear that there that "netbsd" means "netbsdaout" by default, and only "netbsdelf" enables proper ELF support.

The problem for us is that including the linked binary format with the OS like this breaks our usual tooling; we added a [hack], but it is still deficient as it breaks parsing-rendering round trips.

My first suggestion is that these GNU tools should support <CPU>-netbsd-elf and <CPU>-netbsd-aout as alternative ways of disambiguating. Putting it in an additional "abi" component of the config (this is the 4th component with a vendor (including "pc" or "unknown" in the second position) is something we already support for e.g. bare metal programing that nonetheless use ELF (as supported by the bootloader or whatever). This has the advantage of being a non-breaking change.

My second suggestion would just be to change the meaning of the ambiguous plain "netbsd" to mean ELF rather than a.out by default. NetBSD has, of course, supported ELF for many years now, and other OSes that switched to ELF have made the same change long ago, so this would be hopefully be only a tiny breakage, and one with precedent. See also this comment in GNU config that even anticipates this change [gnu-config-comment].

If you find either of those changes acceptable, I would be happy to do all the work writing and submitting patches upstream to GCC, Binutils, etc. I have spent much time overhauling GNU config to systematize the parsing of these, so there is precedent for upstream putting up with these sorts of cleanups. I wanted to ask here first before doing anything, as I wouldn't want to change upstream stuff for NetBSD behind your backs.

Thanks,

John

(CCing Alyssa who has led the NetBSD work in Nixpkgs.)


[nixpkgs-netbsd]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/bsd/netbsd/default.nix

[gnu-config-netbsdaout]: https://git.savannah.gnu.org/cgit/config.git/tree/config.guess#n182

[hack]: https://github.com/NixOS/nixpkgs/pull/125234/files#diff-f970a71ad61b6b3ee7cfb369f3de4324885ff93d8d7f6b28253b0a812c166b13R474-R477

[gnu-config-comment]: https://git.savannah.gnu.org/cgit/config.git/tree/config.guess#n220



Home | Main Index | Thread Index | Old Index