@@ -25,11 +25,12 @@ macro_rules! public_test_dep {
2525/// platforms need and elsewhere in this library it just looks like normal Rust 
2626/// code. 
2727/// 
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")`. 
30+ /// `weak` linkage attribute is used so that these functions can be replaced 
31+ /// by another implementation at link time. This is particularly useful for mixed 
32+ /// Rust/C++ binaries that want to use the C++ intrinsics, otherwise linking against 
33+ /// the Rust stdlib will replace those from the compiler-rt library. 
3334/// 
3435/// This macro is structured to be invoked with a bunch of functions that looks 
3536/// like: 
@@ -53,10 +54,6 @@ macro_rules! public_test_dep {
5354/// 
5455/// A quick overview of attributes supported right now are: 
5556/// 
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. 
6057/// * `maybe_use_optimized_c_shim` - indicates that the Rust implementation is 
6158///   ignored if an optimized C version was compiled. 
6259/// * `aapcs_on_arm` - forces the ABI of the function to be `"aapcs"` on ARM and 
@@ -128,67 +125,6 @@ macro_rules! intrinsics {
128125        intrinsics!( $( $rest) * ) ; 
129126    ) ; 
130127
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- 
192128    // Right now there's a bunch of architecture-optimized intrinsics in the 
193129    // stock compiler-rt implementation. Not all of these have been ported over 
194130    // to Rust yet so when the `c` feature of this crate is enabled we fall back 
@@ -211,7 +147,7 @@ macro_rules! intrinsics {
211147        $( $rest: tt) * 
212148    )  => ( 
213149        #[ cfg( $name = "optimized-c" ) ] 
214-         #[ cfg_attr( feature  = "weak-intrinsics"  ,  linkage = "weak" ) ] 
150+         #[ cfg_attr( all ( not ( windows ) ,  not ( target_vendor  = "apple"  ) ) ,  linkage = "weak" ) ] 
215151        pub  $( unsafe  $( $empty) ? ) ? extern $abi fn  $name(  $( $argname:  $ty) ,*  )  $( -> $ret) ? { 
216152            extern $abi { 
217153                fn  $name( $( $argname:  $ty) ,* )  $( -> $ret) ?; 
@@ -311,15 +247,14 @@ macro_rules! intrinsics {
311247    )  => ( 
312248        #[ cfg( all( any( windows,  target_os = "uefi" ) ,  target_arch = "x86_64" ) ) ] 
313249        $( #[ $( $attr) * ] ) * 
314-         #[ cfg_attr( feature = "weak-intrinsics" ,  linkage = "weak" ) ] 
315250        pub  extern $abi fn  $name(  $( $argname:  $ty) ,*  )  $( -> $ret) ? { 
316251            $( $body) * 
317252        } 
318253
319254        #[ cfg( all( any( windows,  target_os = "uefi" ) ,  target_arch = "x86_64" ) ) ] 
320255        pub  mod  $name { 
321256            #[ cfg_attr( not( feature = "mangled-names" ) ,  no_mangle) ] 
322-             #[ cfg_attr( feature  = "weak-intrinsics"  ,  linkage = "weak" ) ] 
257+             #[ cfg_attr( all ( not ( windows ) ,  not ( target_vendor  = "apple"  ) ) ,  linkage = "weak" ) ] 
323258            pub  extern $abi fn  $name(  $( $argname:  $ty) ,*  ) 
324259                -> $crate:: macros:: win64_128bit_abi_hack:: U64x2 
325260            { 
@@ -360,7 +295,7 @@ macro_rules! intrinsics {
360295        #[ cfg( target_arch = "arm" ) ] 
361296        pub  mod  $name { 
362297            #[ cfg_attr( not( feature = "mangled-names" ) ,  no_mangle) ] 
363-             #[ cfg_attr( feature  = "weak-intrinsics"  ,  linkage = "weak" ) ] 
298+             #[ cfg_attr( all ( not ( windows ) ,  not ( target_vendor  = "apple"  ) ) ,  linkage = "weak" ) ] 
364299            pub  extern $abi fn  $name(  $( $argname:  $ty) ,*  )  $( -> $ret) ? { 
365300                super :: $name( $( $argname) ,* ) 
366301            } 
@@ -369,7 +304,7 @@ macro_rules! intrinsics {
369304        #[ cfg( target_arch = "arm" ) ] 
370305        pub  mod  $alias { 
371306            #[ cfg_attr( not( feature = "mangled-names" ) ,  no_mangle) ] 
372-             #[ cfg_attr( any ( all( not( windows) ,  not( target_vendor="apple" ) ) ,  feature =  "weak-intrinsics" ) ,  linkage = "weak" ) ] 
307+             #[ cfg_attr( all( not( windows) ,  not( target_vendor="apple" ) ) ,  linkage = "weak" ) ] 
373308            pub  extern "aapcs"  fn  $alias(  $( $argname:  $ty) ,*  )  $( -> $ret) ? { 
374309                super :: $name( $( $argname) ,* ) 
375310            } 
@@ -405,7 +340,7 @@ macro_rules! intrinsics {
405340        pub  mod  $name { 
406341            $( #[ $( $attr) * ] ) * 
407342            #[ cfg_attr( not( feature = "mangled-names" ) ,  no_mangle) ] 
408-             #[ cfg_attr( feature  = "weak-intrinsics"  ,  linkage = "weak" ) ] 
343+             #[ cfg_attr( all ( not ( windows ) ,  not ( target_vendor  = "apple"  ) ) ,  linkage = "weak" ) ] 
409344            pub  unsafe  extern $abi fn  $name(  $( $argname:  $ty) ,*  )  $( -> $ret) ? { 
410345                super :: $name( $( $argname) ,* ) 
411346            } 
@@ -429,7 +364,7 @@ macro_rules! intrinsics {
429364            #[ naked] 
430365            $( #[ $( $attr) * ] ) * 
431366            #[ cfg_attr( not( feature = "mangled-names" ) ,  no_mangle) ] 
432-             #[ cfg_attr( feature  = "weak-intrinsics"  ,  linkage = "weak" ) ] 
367+             #[ cfg_attr( all ( not ( windows ) ,  not ( target_vendor  = "apple"  ) ) ,  linkage = "weak" ) ] 
433368            pub  unsafe  extern $abi fn  $name(  $( $argname:  $ty) ,*  )  $( -> $ret) ? { 
434369                $( $body) * 
435370            } 
@@ -495,7 +430,7 @@ macro_rules! intrinsics {
495430        pub  mod  $name { 
496431            $( #[ $( $attr) * ] ) * 
497432            #[ cfg_attr( not( feature = "mangled-names" ) ,  no_mangle) ] 
498-             #[ cfg_attr( feature  = "weak-intrinsics"  ,  linkage = "weak" ) ] 
433+             #[ cfg_attr( all ( not ( windows ) ,  not ( target_vendor  = "apple"  ) ) ,  linkage = "weak" ) ] 
499434            pub  extern $abi fn  $name(  $( $argname:  $ty) ,*  )  $( -> $ret) ? { 
500435                super :: $name( $( $argname) ,* ) 
501436            } 
@@ -521,7 +456,7 @@ macro_rules! intrinsics {
521456        pub  mod  $name { 
522457            $( #[ $( $attr) * ] ) * 
523458            #[ cfg_attr( not( feature = "mangled-names" ) ,  no_mangle) ] 
524-             #[ cfg_attr( feature  = "weak-intrinsics"  ,  linkage = "weak" ) ] 
459+             #[ cfg_attr( all ( not ( windows ) ,  not ( target_vendor  = "apple"  ) ) ,  linkage = "weak" ) ] 
525460            pub  unsafe  extern $abi fn  $name(  $( $argname:  $ty) ,*  )  $( -> $ret) ? { 
526461                super :: $name( $( $argname) ,* ) 
527462            } 
0 commit comments