Commit 4c939db 1 parent dc04c0c commit 4c939db Copy full SHA for 4c939db
File tree 2 files changed +24
-9
lines changed
compiler/rustc_codegen_ssa/src
2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -87,12 +87,17 @@ pub(crate) fn from_target_feature_attr(
87
87
// But ensure the ABI does not forbid enabling this.
88
88
// Here we do assume that LLVM doesn't add even more implied features
89
89
// we don't know about, at least no features that would have ABI effects!
90
- if abi_feature_constraints. incompatible . contains ( & name. as_str ( ) ) {
91
- tcx. dcx ( ) . emit_err ( errors:: ForbiddenTargetFeatureAttr {
92
- span : item. span ( ) ,
93
- feature : name. as_str ( ) ,
94
- reason : "this feature is incompatible with the target ABI" ,
95
- } ) ;
90
+ // We skip this logic in rustdoc, where we want to allow all target features of
91
+ // all targets, so we can't check their ABI compatibility and anyway we are not
92
+ // generating code so "it's fine".
93
+ if !tcx. sess . opts . actually_rustdoc {
94
+ if abi_feature_constraints. incompatible . contains ( & name. as_str ( ) ) {
95
+ tcx. dcx ( ) . emit_err ( errors:: ForbiddenTargetFeatureAttr {
96
+ span : item. span ( ) ,
97
+ feature : name. as_str ( ) ,
98
+ reason : "this feature is incompatible with the target ABI" ,
99
+ } ) ;
100
+ }
96
101
}
97
102
target_features. push ( TargetFeature { name, implied : name != feature_sym } )
98
103
}
Original file line number Diff line number Diff line change 1
1
//! This is a regression test for <https://github.com/rust-lang/rust/issues/137366>, ensuring
2
- //! that we can use the `neon` target feature on ARM-32 targets in rustdoc despite there
2
+ //! that we can use the `neon` target feature on ARM32 targets in rustdoc despite there
3
3
//! being a "forbidden" feature of the same name for aarch64, and rustdoc merging the
4
4
//! target features of all targets.
5
5
//@ check-pass
6
- //@ compile-flags: --target armv7-unknown-linux-gnueabihf
6
+ //@ revisions: arm aarch64
7
+ //@[arm] compile-flags: --target armv7-unknown-linux-gnueabihf
8
+ //@[arm] needs-llvm-components: arm
9
+ //@[aarch64] compile-flags: --target aarch64-unknown-none-softfloat
10
+ //@[aarch64] needs-llvm-components: aarch64
7
11
8
12
#![ crate_type = "lib" ]
9
13
#![ feature( no_core, lang_items) ]
@@ -15,4 +19,10 @@ pub trait Sized {}
15
19
16
20
// `fp-armv8` is "forbidden" on aarch64 as we tie it to `neon`.
17
21
#[ target_feature( enable = "fp-armv8" ) ]
18
- pub fn fun ( ) { }
22
+ pub fn fun1 ( ) { }
23
+
24
+ // This would usually be rejected as it changes the ABI.
25
+ // But we disable that check in rustdoc since we are building "for all targets" and the
26
+ // check can't really handle that.
27
+ #[ target_feature( enable = "soft-float" ) ]
28
+ pub fn fun2 ( ) { }
You can’t perform that action at this time.
0 commit comments