diff options
| author | bors <bors@rust-lang.org> | 2022-03-02 03:03:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-02 03:03:22 +0000 |
| commit | 39a3b527674c1c8d2b9d3edc0cfae67abe6b3ecb (patch) | |
| tree | 19cad78e9c5434d03b45ff81ef169449e409a12b /compiler/rustc_codegen_ssa/src | |
| parent | f0c4da49983aa699f715caf681e3154b445fb60b (diff) | |
| parent | df701a292ce552fddad2048cfcb6edaf90222d85 (diff) | |
| download | rust-39a3b527674c1c8d2b9d3edc0cfae67abe6b3ecb.tar.gz rust-39a3b527674c1c8d2b9d3edc0cfae67abe6b3ecb.zip | |
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
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/write.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/target_features.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/traits/backend.rs | 1 |
3 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 55ea0c4d727..e23572104c4 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -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, diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index 77166c89735..fd4adfea808 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -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 diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index c6abb3f6eb4..a71eadd3d75 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -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>; |
