File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ use std::process::Command;
3
3
use std:: str;
4
4
5
5
fn main ( ) {
6
- let rustc_minor_ver =
7
- rustc_minor_version ( ) . expect ( "Failed to get rustc version" ) ;
6
+ let ( rustc_minor_ver, is_nightly ) =
7
+ rustc_minor_nightly ( ) . expect ( "Failed to get rustc version" ) ;
8
8
let rustc_dep_of_std = env:: var ( "CARGO_FEATURE_RUSTC_DEP_OF_STD" ) . is_ok ( ) ;
9
9
let align_cargo_feature = env:: var ( "CARGO_FEATURE_ALIGN" ) . is_ok ( ) ;
10
10
let const_extern_fn_cargo_feature = env:: var ( "CARGO_FEATURE_CONST_EXTERN_FN" ) . is_ok ( ) ;
@@ -75,11 +75,14 @@ fn main() {
75
75
}
76
76
77
77
if const_extern_fn_cargo_feature {
78
+ if !is_nightly || rustc_minor_ver < 40 {
79
+ panic ! ( "const-extern-fn requires a nightly compiler >= 1.40" )
80
+ }
78
81
println ! ( "cargo:rustc-cfg=libc_const_extern_fn" ) ;
79
82
}
80
83
}
81
84
82
- fn rustc_minor_version ( ) -> Option < u32 > {
85
+ fn rustc_minor_nightly ( ) -> Option < ( u32 , bool ) > {
83
86
macro_rules! otry {
84
87
( $e: expr) => {
85
88
match $e {
@@ -98,7 +101,12 @@ fn rustc_minor_version() -> Option<u32> {
98
101
return None ;
99
102
}
100
103
101
- otry ! ( pieces. next( ) ) . parse ( ) . ok ( )
104
+ let minor = pieces. next ( ) ;
105
+ let nightly_raw = otry ! ( otry!( pieces. next( ) ) . split( '-' ) . nth( 1 ) ) ;
106
+ let nightly = nightly_raw. starts_with ( "dev" ) || nightly_raw. starts_with ( "nightly" ) ;
107
+ let minor = otry ! ( otry!( minor) . parse( ) . ok( ) ) ;
108
+
109
+ Some ( ( minor, nightly) )
102
110
}
103
111
104
112
fn which_freebsd ( ) -> Option < i32 > {
You can’t perform that action at this time.
0 commit comments