Skip to content

Commit

Permalink
Fix LibreSSL version checking in openssl/
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alex committed Mar 21, 2023
1 parent 8f92004 commit 4ecaf69
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
3 changes: 3 additions & 0 deletions openssl-sys/build/cfgs.rs
Expand Up @@ -31,6 +31,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
if libressl_version >= 0x2_09_01_00_0 {
cfgs.push("libressl291");
}
if libressl_version >= 0x3_01_00_00_0 {
cfgs.push("libressl310");
}
if libressl_version >= 0x3_02_01_00_0 {
cfgs.push("libressl321");
}
Expand Down
53 changes: 51 additions & 2 deletions openssl/build.rs
Expand Up @@ -16,8 +16,57 @@ fn main() {
return;
}

if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION") {
println!("cargo:rustc-cfg=libressl{}", v);
if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION_NUMBER") {
let version = u64::from_str_radix(&v, 16).unwrap();

if version >= 0x2_05_00_00_0 {
println!("cargo:rustc-cfg=libressl250");
}
if version >= 0x2_05_01_00_0 {
println!("cargo:rustc-cfg=libressl251");
}
if version >= 0x2_06_01_00_0 {
println!("cargo:rustc-cfg=libressl261");
}
if version >= 0x2_07_00_00_0 {
println!("cargo:rustc-cfg=libressl270");
}
if version >= 0x2_07_01_00_0 {
println!("cargo:rustc-cfg=libressl271");
}
if version >= 0x2_07_03_00_0 {
println!("cargo:rustc-cfg=libressl273");
}
if version >= 0x2_08_00_00_0 {
println!("cargo:rustc-cfg=libressl280");
}
if version >= 0x2_09_01_00_0 {
println!("cargo:rustc-cfg=libressl291");
}
if version >= 0x3_01_00_00_0 {
println!("cargo:rustc-cfg=libressl310");
}
if version >= 0x3_02_01_00_0 {
println!("cargo:rustc-cfg=libressl321");
}
if version >= 0x3_03_02_00_0 {
println!("cargo:rustc-cfg=libressl332");
}
if version >= 0x3_04_00_00_0 {
println!("cargo:rustc-cfg=libressl340");
}
if version >= 0x3_05_00_00_0 {
println!("cargo:rustc-cfg=libressl350");
}
if version >= 0x3_06_00_00_0 {
println!("cargo:rustc-cfg=libressl360");
}
if version >= 0x3_06_01_00_0 {
println!("cargo:rustc-cfg=libressl361");
}
if version >= 0x3_07_00_00_0 {
println!("cargo:rustc-cfg=libressl370");
}
}

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

0 comments on commit 4ecaf69

Please sign in to comment.