Skip to content

Commit 4ecaf69

Browse files
committed
Fix LibreSSL version checking in openssl/
Previously it only did exact version matching -- different from how OpenSSL worked, and causing it to make many APIs exposed only on a single version of LibreSSL. This fixes that, and in the process identifies a bug in openssl-sys.
1 parent 8f92004 commit 4ecaf69

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

openssl-sys/build/cfgs.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
3131
if libressl_version >= 0x2_09_01_00_0 {
3232
cfgs.push("libressl291");
3333
}
34+
if libressl_version >= 0x3_01_00_00_0 {
35+
cfgs.push("libressl310");
36+
}
3437
if libressl_version >= 0x3_02_01_00_0 {
3538
cfgs.push("libressl321");
3639
}

openssl/build.rs

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,57 @@ fn main() {
1616
return;
1717
}
1818

19-
if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION") {
20-
println!("cargo:rustc-cfg=libressl{}", v);
19+
if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION_NUMBER") {
20+
let version = u64::from_str_radix(&v, 16).unwrap();
21+
22+
if version >= 0x2_05_00_00_0 {
23+
println!("cargo:rustc-cfg=libressl250");
24+
}
25+
if version >= 0x2_05_01_00_0 {
26+
println!("cargo:rustc-cfg=libressl251");
27+
}
28+
if version >= 0x2_06_01_00_0 {
29+
println!("cargo:rustc-cfg=libressl261");
30+
}
31+
if version >= 0x2_07_00_00_0 {
32+
println!("cargo:rustc-cfg=libressl270");
33+
}
34+
if version >= 0x2_07_01_00_0 {
35+
println!("cargo:rustc-cfg=libressl271");
36+
}
37+
if version >= 0x2_07_03_00_0 {
38+
println!("cargo:rustc-cfg=libressl273");
39+
}
40+
if version >= 0x2_08_00_00_0 {
41+
println!("cargo:rustc-cfg=libressl280");
42+
}
43+
if version >= 0x2_09_01_00_0 {
44+
println!("cargo:rustc-cfg=libressl291");
45+
}
46+
if version >= 0x3_01_00_00_0 {
47+
println!("cargo:rustc-cfg=libressl310");
48+
}
49+
if version >= 0x3_02_01_00_0 {
50+
println!("cargo:rustc-cfg=libressl321");
51+
}
52+
if version >= 0x3_03_02_00_0 {
53+
println!("cargo:rustc-cfg=libressl332");
54+
}
55+
if version >= 0x3_04_00_00_0 {
56+
println!("cargo:rustc-cfg=libressl340");
57+
}
58+
if version >= 0x3_05_00_00_0 {
59+
println!("cargo:rustc-cfg=libressl350");
60+
}
61+
if version >= 0x3_06_00_00_0 {
62+
println!("cargo:rustc-cfg=libressl360");
63+
}
64+
if version >= 0x3_06_01_00_0 {
65+
println!("cargo:rustc-cfg=libressl361");
66+
}
67+
if version >= 0x3_07_00_00_0 {
68+
println!("cargo:rustc-cfg=libressl370");
69+
}
2170
}
2271

2372
if let Ok(vars) = env::var("DEP_OPENSSL_CONF") {

0 commit comments

Comments
 (0)