@@ -25,11 +25,14 @@ macro_rules! public_test_dep {
25
25
/// platforms need and elsewhere in this library it just looks like normal Rust
26
26
/// code.
27
27
///
28
- /// When the weak-intrinsics feature is enabled, all intrinsics functions are
29
- /// marked with #[linkage = "weak"] so that they can be replaced by another
30
- /// implementation at link time. This is particularly useful for mixed Rust/C++
31
- /// binaries that want to use the C++ intrinsics, otherwise linking against the
32
- /// Rust stdlib will replace those from the compiler-rt library.
28
+ /// All intrinsics functions are marked with #[linkage = "weak"] when
29
+ /// `not(windows) and not(target_vendor = "apple")` except `mem` intrinsics, which
30
+ /// will only have the `#[linkage = "weak"]` attribute when the `mem-weak-intrinsics`
31
+ /// feature is enabled.
32
+ /// `weak` linkage attribute is used so that these functions can be replaced
33
+ /// by another implementation at link time. This is particularly useful for mixed
34
+ /// Rust/C++ binaries that want to use the C++ intrinsics, otherwise linking against
35
+ /// the Rust stdlib will replace those from the compiler-rt library.
33
36
///
34
37
/// This macro is structured to be invoked with a bunch of functions that looks
35
38
/// like:
@@ -53,10 +56,6 @@ macro_rules! public_test_dep {
53
56
///
54
57
/// A quick overview of attributes supported right now are:
55
58
///
56
- /// * `weak` - indicates that the function should always be given weak linkage.
57
- /// This attribute must come before other attributes, as the other attributes
58
- /// will generate the final output function and need to have `weak` modify
59
- /// them.
60
59
/// * `maybe_use_optimized_c_shim` - indicates that the Rust implementation is
61
60
/// ignored if an optimized C version was compiled.
62
61
/// * `aapcs_on_arm` - forces the ABI of the function to be `"aapcs"` on ARM and
@@ -128,67 +127,6 @@ macro_rules! intrinsics {
128
127
intrinsics!( $( $rest) * ) ;
129
128
) ;
130
129
131
- // Explicit weak linkage gets dropped when weak-intrinsics is on since it
132
- // will be added unconditionally to all intrinsics and would conflict
133
- // otherwise.
134
- (
135
- #[ weak]
136
- $( #[ $( $attr: tt) * ] ) *
137
- pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) $( -> $ret: ty) ? {
138
- $( $body: tt) *
139
- }
140
-
141
- $( $rest: tt) *
142
- ) => (
143
- #[ cfg( feature = "weak-intrinsics" ) ]
144
- intrinsics! {
145
- $( #[ $( $attr) * ] ) *
146
- pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
147
- $( $body) *
148
- }
149
- }
150
-
151
- #[ cfg( not( feature = "weak-intrinsics" ) ) ]
152
- intrinsics! {
153
- $( #[ $( $attr) * ] ) *
154
- #[ linkage = "weak" ]
155
- pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
156
- $( $body) *
157
- }
158
- }
159
-
160
- intrinsics!( $( $rest) * ) ;
161
- ) ;
162
- // Same as above but for unsafe.
163
- (
164
- #[ weak]
165
- $( #[ $( $attr: tt) * ] ) *
166
- pub unsafe extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) $( -> $ret: ty) ? {
167
- $( $body: tt) *
168
- }
169
-
170
- $( $rest: tt) *
171
- ) => (
172
- #[ cfg( feature = "weak-intrinsics" ) ]
173
- intrinsics! {
174
- $( #[ $( $attr) * ] ) *
175
- pub unsafe extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
176
- $( $body) *
177
- }
178
- }
179
-
180
- #[ cfg( not( feature = "weak-intrinsics" ) ) ]
181
- intrinsics! {
182
- $( #[ $( $attr) * ] ) *
183
- #[ linkage = "weak" ]
184
- pub unsafe extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
185
- $( $body) *
186
- }
187
- }
188
-
189
- intrinsics!( $( $rest) * ) ;
190
- ) ;
191
-
192
130
// Right now there's a bunch of architecture-optimized intrinsics in the
193
131
// stock compiler-rt implementation. Not all of these have been ported over
194
132
// to Rust yet so when the `c` feature of this crate is enabled we fall back
@@ -211,7 +149,7 @@ macro_rules! intrinsics {
211
149
$( $rest: tt) *
212
150
) => (
213
151
#[ cfg( $name = "optimized-c" ) ]
214
- #[ cfg_attr( feature = "weak-intrinsics" , linkage = "weak" ) ]
152
+ #[ cfg_attr( all ( not ( windows ) , not ( target_vendor = "apple" ) ) , linkage = "weak" ) ]
215
153
pub $( unsafe $( $empty) ? ) ? extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
216
154
extern $abi {
217
155
fn $name( $( $argname: $ty) ,* ) $( -> $ret) ?;
@@ -311,15 +249,14 @@ macro_rules! intrinsics {
311
249
) => (
312
250
#[ cfg( all( any( windows, target_os = "uefi" ) , target_arch = "x86_64" ) ) ]
313
251
$( #[ $( $attr) * ] ) *
314
- #[ cfg_attr( feature = "weak-intrinsics" , linkage = "weak" ) ]
315
252
pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
316
253
$( $body) *
317
254
}
318
255
319
256
#[ cfg( all( any( windows, target_os = "uefi" ) , target_arch = "x86_64" ) ) ]
320
257
pub mod $name {
321
258
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
322
- #[ cfg_attr( feature = "weak-intrinsics" , linkage = "weak" ) ]
259
+ #[ cfg_attr( all ( not ( windows ) , not ( target_vendor = "apple" ) ) , linkage = "weak" ) ]
323
260
pub extern $abi fn $name( $( $argname: $ty) ,* )
324
261
-> $crate:: macros:: win64_128bit_abi_hack:: U64x2
325
262
{
@@ -360,7 +297,7 @@ macro_rules! intrinsics {
360
297
#[ cfg( target_arch = "arm" ) ]
361
298
pub mod $name {
362
299
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
363
- #[ cfg_attr( feature = "weak-intrinsics" , linkage = "weak" ) ]
300
+ #[ cfg_attr( all ( not ( windows ) , not ( target_vendor = "apple" ) ) , linkage = "weak" ) ]
364
301
pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
365
302
super :: $name( $( $argname) ,* )
366
303
}
@@ -369,7 +306,7 @@ macro_rules! intrinsics {
369
306
#[ cfg( target_arch = "arm" ) ]
370
307
pub mod $alias {
371
308
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
372
- #[ cfg_attr( any ( all( not( windows) , not( target_vendor="apple" ) ) , feature = "weak-intrinsics" ) , linkage = "weak" ) ]
309
+ #[ cfg_attr( all( not( windows) , not( target_vendor="apple" ) ) , linkage = "weak" ) ]
373
310
pub extern "aapcs" fn $alias( $( $argname: $ty) ,* ) $( -> $ret) ? {
374
311
super :: $name( $( $argname) ,* )
375
312
}
@@ -405,7 +342,7 @@ macro_rules! intrinsics {
405
342
pub mod $name {
406
343
$( #[ $( $attr) * ] ) *
407
344
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
408
- #[ cfg_attr( feature = "weak-intrinsics" , linkage = "weak" ) ]
345
+ #[ cfg_attr( all ( not ( windows ) , not ( target_vendor = "apple" ) , not ( target_env = "gnu" ) , feature = "mem- weak-intrinsics" ) , linkage = "weak" ) ]
409
346
pub unsafe extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
410
347
super :: $name( $( $argname) ,* )
411
348
}
@@ -429,7 +366,7 @@ macro_rules! intrinsics {
429
366
#[ naked]
430
367
$( #[ $( $attr) * ] ) *
431
368
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
432
- #[ cfg_attr( feature = "weak-intrinsics" , linkage = "weak" ) ]
369
+ #[ cfg_attr( all ( not ( windows ) , not ( target_vendor = "apple" ) ) , linkage = "weak" ) ]
433
370
pub unsafe extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
434
371
$( $body) *
435
372
}
@@ -495,7 +432,7 @@ macro_rules! intrinsics {
495
432
pub mod $name {
496
433
$( #[ $( $attr) * ] ) *
497
434
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
498
- #[ cfg_attr( feature = "weak-intrinsics" , linkage = "weak" ) ]
435
+ #[ cfg_attr( all ( not ( windows ) , not ( target_vendor = "apple" ) ) , linkage = "weak" ) ]
499
436
pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
500
437
super :: $name( $( $argname) ,* )
501
438
}
@@ -521,7 +458,7 @@ macro_rules! intrinsics {
521
458
pub mod $name {
522
459
$( #[ $( $attr) * ] ) *
523
460
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
524
- #[ cfg_attr( feature = "weak-intrinsics" , linkage = "weak" ) ]
461
+ #[ cfg_attr( all ( not ( windows ) , not ( target_vendor = "apple" ) ) , linkage = "weak" ) ]
525
462
pub unsafe extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
526
463
super :: $name( $( $argname) ,* )
527
464
}
0 commit comments