rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.16k stars 12.69k forks source link

invalid -Ctarget-cpu could fail more gracefully? #102716

Open matthiaskrgr opened 2 years ago

matthiaskrgr commented 2 years ago

rustc helloworld.rs -C target-cpu=lol

will print a ton of identical/similar warnings:

'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
'lol' is not a recognized processor for this target (ignoring processor)
LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it!
pure virtual method called
terminate called without an active exception
[1]    2648405 IOT instruction (core dumped)  rustc helloworld.rs -C target-cpu=lol
nagisa commented 2 years ago

Once upon a time I looked into this and there isn’t a good way to do this (without changes to LLVM, anyway.) We will produce a warning for each LLVM context created, which is going to be 1 informational + 1 for each codegen unit. To the best of my knowledge there isn’t a way to either suppress nor to get LLVM to fail when this happens.

We could create an informational target and then check for the missing feature, but that would still show at least one warning.

We could also have our own allow-lists for the values here, just like we have for -Ctarget-feature.