@@ -7,6 +7,8 @@ fn main() {
7
7
rustc_minor_version ( ) . 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
+ #[ allow( unused) ]
11
+ let libc_ci = env:: var ( "LIBC_CI" ) . is_ok ( ) ;
10
12
11
13
if env:: var ( "CARGO_FEATURE_USE_STD" ) . is_ok ( ) {
12
14
println ! (
@@ -15,15 +17,20 @@ fn main() {
15
17
) ;
16
18
}
17
19
18
- if env:: var ( "LIBC_CI" ) . is_ok ( ) {
19
- if let Some ( 11 ) = which_freebsd ( ) {
20
- println ! ( "cargo:rustc-cfg=freebsd11" ) ;
21
- }
22
- if let Some ( 12 ) = which_freebsd ( ) {
23
- println ! ( "cargo:rustc-cfg=freebsd12" ) ;
24
- }
25
- if let Some ( 13 ) = which_freebsd ( ) {
26
- println ! ( "cargo:rustc-cfg=freebsd13" ) ;
20
+ // The ABI of libc is backward compatible with FreeBSD 11.
21
+ //
22
+ // On CI, we detect the actual FreeBSD version and match its ABI exactly,
23
+ // running tests to ensure that the ABI is correct.
24
+ #[ cfg( target_os = "freebsd" ) ]
25
+ match which_freebsd ( ) {
26
+ Some ( 11 ) if libc_ci => println ! ( "cargo:rustc-cfg=freebsd11" ) ,
27
+ Some ( 12 ) if libc_ci => println ! ( "cargo:rustc-cfg=freebsd12" ) ,
28
+ Some ( 13 ) if libc_ci => println ! ( "cargo:rustc-cfg=freebsd13" ) ,
29
+ Some ( _) => println ! ( "cargo:rustc-cfg=freebsd11" ) ,
30
+ None =>
31
+ /* not FreeBSD - nothing to do here */
32
+ {
33
+ ( )
27
34
}
28
35
}
29
36
@@ -87,6 +94,7 @@ fn rustc_minor_version() -> Option<u32> {
87
94
otry ! ( pieces. next( ) ) . parse ( ) . ok ( )
88
95
}
89
96
97
+ #[ cfg( target_os = "freebsd" ) ]
90
98
fn which_freebsd ( ) -> Option < i32 > {
91
99
let output = std:: process:: Command :: new ( "freebsd-version" ) . output ( ) . ok ( ) ;
92
100
if output. is_none ( ) {
0 commit comments