In fact I saw this thread in the weekly summary Discourse sends just before you pinged me. ![]()
The answer to the immediate question "why do forbidden target features not show up in cfg" is that when we introduced the concept of forbidden target features, we did not want to expose anything new on stable, so we didn't want the target features that we now marked as forbidden to show up in cfg. Most of them previously had not been in Rust's target feature list at all.
But there's a broader question here, about what to do with target features that cause ABI incompatibility. If e.g. ptx80 is a forbidden target feature, it is also forbidden in -Ctarget-feature=+ptx80, so there's no way to set it from rustc at all. This is because we explicitly support mixing code built with different -Ctarget-feature in the same binary -- in particular, if you set RUSTFLAGS=-Ctarget-feature=foo, that does not apply to the standard library, so it is crucial that linking code with and without that flag is sound.
I think LLVM target features like ptx80 should not be Rust target features at all. They should become a new thing that works under the umbrella of target modifiers, which ensures that the compiler will detect and prevent accidentally mixing code with incompatible target modifiers. -Ctarget-features should only be used for those target features that can be soundly toggled within a single binary.
However, there's also the option of saying that some target features are known to actually be "target modifiers" can thus are subject to the target modifier consistency check, but otherwise they use the same interface as normal target features regarding -Ctarget-feature and cfg(target_feature). That means we don't have to invent a new term, but it also could be easily confusing to mix two very different kind of flags ("locally enable some ISA extensions" vs "make a global choice for the entire binary") in the same -C option. LLVM chose to make them both target features, but arguably that's a hack.
Cc @alice with whom I also briefly discussed this last week.