Auto merge of #87402 - nagisa:nagisa/request-feature-requests-for-features, r=estebank
Direct users towards using Rust target feature names in CLI This PR consists of a couple of changes on how we handle target features. In particular there is a bug-fix wherein we avoid passing through features that aren't prefixed by `+` or `-` to LLVM. These appear to be causing LLVM to assert, which is pretty poor a behaviour (and also makes it pretty clear we expect feature names to be prefixed). The other commit, I anticipate to be somewhat more controversial is outputting a warning when users specify a LLVM-specific, or otherwise unknown, feature name on the CLI. In those situations we request users to either replace it with a known Rust feature name (e.g. `bmi` -> `bmi1`) or file a feature request. I've a couple motivations for this: first of all, if users are specifying these features on the command line, I'm pretty confident there is also a need for these features to be usable via `#[cfg(target_feature)]` machinery. And second, we're growing a fair number of backends recently and having ability to provide some sort of unified-ish interface in this place seems pretty useful to me. Sponsored by: standard.ai
This commit is contained in:
commit
39a3b52767
22 changed files with 253 additions and 108 deletions
|
@ -1033,6 +1033,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
} else {
|
||||
tcx.backend_optimization_level(())
|
||||
};
|
||||
let backend_features = tcx.global_backend_features(());
|
||||
let cgcx = CodegenContext::<B> {
|
||||
backend: backend.clone(),
|
||||
crate_types: sess.crate_types().to_vec(),
|
||||
|
@ -1054,7 +1055,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
regular_module_config: regular_config,
|
||||
metadata_module_config: metadata_config,
|
||||
allocator_module_config: allocator_config,
|
||||
tm_factory: backend.target_machine_factory(tcx.sess, ol),
|
||||
tm_factory: backend.target_machine_factory(tcx.sess, ol, backend_features),
|
||||
total_cgus,
|
||||
msvc_imps_needed: msvc_imps_needed(tcx),
|
||||
is_pe_coff: tcx.sess.target.is_like_windows,
|
||||
|
|
|
@ -4,6 +4,9 @@ use rustc_session::Session;
|
|||
use rustc_span::symbol::sym;
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
||||
/// Features that control behaviour of rustc, rather than the codegen.
|
||||
pub const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"];
|
||||
|
||||
// When adding features to the below lists
|
||||
// check whether they're named already elsewhere in rust
|
||||
// e.g. in stdarch and whether the given name matches LLVM's
|
||||
|
|
|
@ -134,6 +134,7 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se
|
|||
&self,
|
||||
sess: &Session,
|
||||
opt_level: config::OptLevel,
|
||||
target_features: &[String],
|
||||
) -> TargetMachineFactoryFn<Self>;
|
||||
fn target_cpu<'b>(&self, sess: &'b Session) -> &'b str;
|
||||
fn tune_cpu<'b>(&self, sess: &'b Session) -> Option<&'b str>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue