Description
Should setting target_family require also setting target_os?
Currently, the x86_64-linux-kernel
target sets target_family to "unix", but the os is "none". This is the only target which sets the family without the os. This can make it a little confusing/awkward when writing cfg
expressions to properly cover targets such as these (sometimes the check for os="none" needs to appear before the family).
In practice today this isn't an issue because libcore, liballoc, and compiler_builtins do not ever check the family. AFAIK, the family doesn't have any other effects other than the cfg
settings.
This issue came up during #74033 where I was adjusting some cfg
expressions for building std for Cargo. I do not know if Cargo's build-std will ever support x86_64-linux-kernel
, but I'd like to try to cover as many targets as possible and avoid special cases if they are not necessary.
@eddyb had some suggestions which I'll copy here:
Does the Linux kernel even have an UNIX API inside of itself? That doesn't sound right but maybe I just haven't seen it before.
(To be clear, I'm thinking that family="unix" is as valid for inside an OS kernel as os="thatosname" - if os="none" is used then surely there should also not be a family? Maybe we should enforce that the family is derived from the OS name and therefore means "OS family")
cc @joshtriplett who I think might know a little about the x86_64-linux-kernel
target, and @alex who introduced the target. Perhaps they can shed some light why "unix" was chosen.