Repository: rust
Issue: i586-unknown-linux-gnu target generates binaries containing Intel CET opcodes which are illegal on i586 processors
Labels: T-compiler,C-bug,PG-exploit-mitigations,O-x86_32

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

As the title says, I generated an i586 rust toolchain by doing the following:

```
git clone https://github.com/rust-lang/rust
cd rust
git checkout 1.58.0
git submodule update --init --recursive
./x.py setup --build i686-unknown-linux-gnu --host i586-unknown-linux-gnu --target i586-unknown-linux-gnu -j 32
./x.py dist --build i686-unknown-linux-gnu --host i586-unknown-linux-gnu --target i586-unknown-linux-gnu -j 32
# transfer build/dist/rust-1.58.0-dev-i586-unknown-linux-gnu.tar.xz to an i586 target
```

However, after installing the toolchain, attempting to run any of the rust tooling throws an illegal instruction exception.

```
$ uname -a
Linux remembrance 5.16.0-gentoo #8 SMP PREEMPT Thu Jan 13 18:49:55 PST 2022 i586 AMD-K6(tm) 3D processor AuthenticAMD GNU/Linux
$ cargo new hello
Illegal instruction
$ rustc -vV
Illegal instruction
```

Running rustc under gdb and looking at the failing instruction shows that the binary contains the "endbr32" instruction, which is part of the Intel CET instruction set on Tiger Lake CPUs. These decode as "NOP" on i686 processors and x86_64 CPUs, but they are illegal opcodes for i586 processors. While I recognize that this processor is ancient, there is still one i586 processor series in production - the Vortex86. For any current Linux distros which still support i586, polkit depends on spidermonkey, which is partially written in rust.

```
$ gdb rustc
GNU gdb (Gentoo 11.1 vanilla) 11.1
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "i586-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from rustc...
(No debugging symbols found in rustc)
(gdb) r
Starting program: /usr/bin/rustc
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0xadc94000 in ?? () from /opt/rust-bin-1.58.0/bin/../lib/libstd-89b7c7054cbe007e.so
(gdb) x/i $pc
=> 0xadc94000:	endbr32
(gdb)
```

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`: (from a chroot on an x86_64 desktop)
```
rustc 1.58.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: i586-unknown-linux-gnu
release: 1.58.0-dev
LLVM version: 13.0.0
```