pub enum Libc {
None,
Archive,
Stub,
Import,
}Expand description
What a produced sysroot holds for a target’s C library.
Four cases, from spec/cross-compile/08-sysroots.md section 8.2’s table, and the line differs
between them in what goes on it rather than in how it is spelled. The table has seven rows and two
of those are legal walls rather than technical ones, so what is left is these four.
Variants§
None
Nothing, which is the freestanding row: the nine compiler headers and no link inputs at all. Our runtime is still there, because an architecture without a division instruction needs it whether there is a libc or not.
Archive
A real static archive, which today means musl built from source. The only row where the code behind the names is present, so the only row a static link can use.
Stub
A generated stub shared object: the names the platform’s libc exports and none of the code. glibc is the row this was written for, and bionic, the BSDs and illumos take the same shape for the same reason, which is that their libc is a shared object on the target machine and a list of names is enough to link against one.
Import
A set of import libraries, which is what the same idea is called in COFF.
Windows is the row this is, and it is a separate case from Libc::Stub rather than a
spelling of it, for two reasons that both show up on the line. The container is different: a
Windows program links against an archive of tiny objects per DLL rather than against one
shared object, which is spec/cross-compile/09-libc-stubs.md section 9.4 and what
rucc_stub::coff writes. And the C library is not one file: the msvcrt import library,
mingw-w64’s own libmingwex.a and libmoldname.a, and the Win32 libraries a CRT calls into
are all on the line, where a glibc line has one libc.so on it.
A static link against this is not refused, which is the other difference. On Windows the C
library is a DLL on every machine and always has been, so -static there is a statement
about our libraries and mingw-w64’s rather than about the CRT, and a program linked that way
runs. That is why the refusal in crate::argv::argv is about Libc::Stub by name.