Right, thank you for clarifying the terms here, Segher! Practically, for my case, build = target = host (it's `x86_64-pc-linux-gnu` for all environments). Yet, I specify a distinct target (it's `x86_64-linux-gnu`) to get a cross-compiler. Yes, it's a fake one. The point here is to bake the default "sysroot" value into the compiler to control the headers/libs visible to the compilation process (and exclude the system's ones). Oleg. On Tue, Sep 28, 2021 at 12:04 PM Segher Boessenkool < segher@xxxxxxxxxxxxxxxxxxx> wrote: > On Tue, Sep 28, 2021 at 09:09:43AM -0700, Oleg Smolsky via Gcc-help wrote: > > On Sat, Sep 25, 2021 at 3:18 AM Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx> > wrote: > > > If you want a compiler running in sysroot (after reboot/chroot into > it), > > > cross-compile it with a cross compiler (using --host=x86_64-sysroot- > > > linux-gnu). > > > > > > You may find some way to pretend the executables for sysroot "runnable > > > on the host", but it's not the expected usage of GCC building system > and > > > likely to be broken if something in the building system changes. > > > > I am trying to get both: such executables run on the host system, yet all > > run-time dependencies are located within the "sysroot". I vaguely > remember > > someone calling such a x86-to-x86 cross-compiler a "Canadian cross"... > The > > idea here is to enforce a tight, fully-encapsulated build environment for > > the host and then ship it all into the production. This combo runs on any > > Linux distro... > > "Cross compiler" means that the host is not the same as the build. A > Canadian cross has the build system a different system as well. > > build = host = target is the normal "native" case. > > build = host != target is the normal "cross" case. > > build != host = target is building a native compiler on a different > system. This is not often done anymore. > > build = target != host is sometimes called "cross-back". This is the > rarest kind perhaps. It is sometimes done as part of a new port, and > in that case you have various other of the above types as well, and > hopefully you fully know ewhat you are doing. It isn't useful for most > users. > > If host is linux and target is mingw, then this always is a cross, no > matter if the CPU architecture on both is the same. The full triple > matters. > > > Segher > >