pub fn cross_sysroot(target: Triple, opts: &LinkOptions) -> Option<Sysroot>Expand description
The sysroot a cross link would use, or None for a link against this machine.
The one place the two paths are told apart, so that the linker that is looked for and the line it is handed cannot disagree about which kind of link this is.
Three conditions, and two of them are about leaving working configurations alone. A target that
is this machine is linked against this machine, which is what every native compile has always
done and what the directories under /usr/lib are for. A --sysroot the user wrote is taken as
the root of a tree they assembled, and the line above prefixes every path it decides with it,
which is what cross compiling against a real distribution tree has always meant here. The third
is that there has to be a cache directory to look in, which on a real command line there always
is.
An unknown host counts as different from every target. A machine this compiler cannot name is a
machine whose /usr/lib it should not be guessing at.
§A pinned release is a cross compile
The first of those three conditions is about the machine and not about the triple, and a target
that names a libc release is not this machine even when it is this architecture. Somebody on a
2.44 box writing --target=x86_64-linux-gnu.2.28 is asking for a binary that runs on a 2.28
machine, and handing them their own headers and their own libc gives them a binary that does not.
So the condition is the triple being the host and no release named, and what it costs is that a
pin equal to this machine’s own release also stops using this machine’s libc. That is not a loss:
the two should be the same text, and if they are not then this machine’s copy is patched and the
bundled tree is the one the pin asked for. tamnd/rucc#956.