The old EAPI 5-hdepend had a USE flag called targetroot for when ROOT != /. This wasn't a very good name for the flag, and the condition was too broad. We need a flag that allows a package to conditionally BDEPEND on itself, but BDEPEND applies to the src_* phases while ROOT applies to the pkg_* phases. I am therefore proposing a flag with a slightly different name and condition. The name is tentatively other-sysroot, but I am open to other suggestions. The condition would be SYSROOT != /. The flag would be implicit. It is to be used for cases like llvm-core/clang where we need the same package to be present on the build host in order to cross-compile it. The ebuild currently calls "has_version -b" with "die" as a workaround. We did not take or adapt USE=targetroot from EAPI 5-hdepend when working on EAPI 7 because we had hoped to make do with temporary builds for the build host as part of the target host build. Sometimes this does work, but it's not practical for cases like llvm-core/clang, and even when it does work, it's often quite awkward. With this new USE flag, developers should use whichever approach feels best. I have not chosen CBUILD != CHOST (tc-is-cross-compiler) as the condition because you should generally not try to directly execute binaries built for the SYSROOT even when the tuple is the same. SYSROOT might have a newer glibc or otherwise require different libraries. There is one exception to this. I considered whether the condition should be ESYSROOT != BROOT. This would make it trigger during cross-prefix builds. I don't think it should because cross-prefix binaries should be directly executable without issue.
After some discussion in #gentoo-pms, we've agreed to have crossdev set this flag instead, at least for the time being. Maybe we can make it part of the spec later.