From 66ace52c4a24a811b405ffd9e9010163352a6186 Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Wed, 6 Oct 2021 00:04:04 -0500 Subject: [PATCH] Fix OpenSSL linking on Windows Technically this is a breaking change moving from `libeay32` to `libcrypto` but no one should be using an openssl version from <=2016. --- libsqlite3-sys/build.rs | 22 +++++++--------------- libsqlite3-sys/src/lib.rs | 4 ++++ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index d6b2b7e..ab32f7d 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -181,31 +181,23 @@ mod build_bundled { if cfg!(feature = "bundled-sqlcipher-vendored-openssl") { cfg.include(std::env::var("DEP_OPENSSL_INCLUDE").unwrap()); - println!("cargo:rustc-link-lib=static=crypto"); // cargo will - // resolve downstream - // to the static - // lib in openssl-sys + // cargo will resolve downstream to the static lib in openssl-sys } else if is_windows { - // FIXME README says that bundled-sqlcipher is Unix only, and the sources are - // configured on a Unix machine. So maybe this should be made unreachable. + // Windows without `-vendored-openssl` takes this to link against a prebuilt OpenSSL lib cfg.include(inc_dir.to_string_lossy().as_ref()); - let mut lib = String::new(); - lib.push_str(lib_dir.to_string_lossy().as_ref()); - lib.push('\\'); - lib.push_str("libeay32.lib"); - cfg.flag(&lib); + let lib = lib_dir.join("libcrypto.lib"); + cfg.flag(lib.to_string_lossy().as_ref()); } else if use_openssl { cfg.include(inc_dir.to_string_lossy().as_ref()); + // branch not taken on Windows, just `crypto` is fine. println!("cargo:rustc-link-lib=dylib=crypto"); - println!( - "cargo:rustc-link-search={}", - lib_dir.to_string_lossy().as_ref() - ); + println!("cargo:rustc-link-search={}", lib_dir.to_string_lossy()); } else if is_apple { cfg.flag("-DSQLCIPHER_CRYPTO_CC"); println!("cargo:rustc-link-lib=framework=SecurityFoundation"); println!("cargo:rustc-link-lib=framework=CoreFoundation"); } else { + // branch not taken on Windows, just `crypto` is fine. println!("cargo:rustc-link-lib=dylib=crypto"); } } diff --git a/libsqlite3-sys/src/lib.rs b/libsqlite3-sys/src/lib.rs index 36552f3..5757194 100644 --- a/libsqlite3-sys/src/lib.rs +++ b/libsqlite3-sys/src/lib.rs @@ -1,6 +1,10 @@ #![allow(non_snake_case, non_camel_case_types)] #![cfg_attr(test, allow(deref_nullptr))] // https://github.com/rust-lang/rust-bindgen/issues/2066 +// force linking to openssl +#[cfg(feature = "bundled-sqlcipher-vendored-openssl")] +extern crate openssl_sys; + pub use self::error::*; use std::default::Default;