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 c804db7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
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
51 changes: 50 additions & 1 deletion openssl/build.rs
Expand Up @@ -17,7 +17,56 @@ fn main() {
}

if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION") {
println!("cargo:rustc-cfg=libressl{}", v);
let version = v.parse::<u64>().unwrap();

if version >= 250 {
println!("cargo:rustc-cfg=libressl{}", 250);
}
if version >= 251 {
println!("cargo:rustc-cfg=libressl{}", 251);
}
if version >= 261 {
println!("cargo:rustc-cfg=libressl{}", 261);
}
if version >= 270 {
println!("cargo:rustc-cfg=libressl{}", 270);
}
if version >= 271 {
println!("cargo:rustc-cfg=libressl{}", 271);
}
if version >= 273 {
println!("cargo:rustc-cfg=libressl{}", 273);
}
if version >= 280 {
println!("cargo:rustc-cfg=libressl{}", 280);
}
if version >= 291 {
println!("cargo:rustc-cfg=libressl{}", 291);
}
if version >= 310 {
println!("cargo:rustc-cfg=libressl{}", 310);
}
if version >= 321 {
println!("cargo:rustc-cfg=libressl{}", 321);
}
if version >= 332 {
println!("cargo:rustc-cfg=libressl{}", 332);
}
if version >= 340 {
println!("cargo:rustc-cfg=libressl{}", 340);
}
if version >= 350 {
println!("cargo:rustc-cfg=libressl{}", 350);
}
if version >= 360 {
println!("cargo:rustc-cfg=libressl{}", 360);
}
if version >= 361 {
println!("cargo:rustc-cfg=libressl{}", 361);
}
if version >= 370 {
println!("cargo:rustc-cfg=libressl{}", 370);
}
}

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

0 comments on commit c804db7

Please sign in to comment.