Skip to content

Commit

Permalink
Also link openssl on windows
Browse files Browse the repository at this point in the history
This commit adds openssl as dependency for bundled windows builds. This
is required as otherwise the scram-sha-256 authentication method is
broken for bundled windows builds. I've verified the issue locally using
a recent postgres docker container + wine. I also verifed that this
change fixes the issue.
  • Loading branch information
weiznich committed Jun 8, 2024
1 parent 1bfca6b commit 13f1158
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ jobs:
- name: Windows setup (bundled)
if: runner.os == 'Windows' && matrix.features == 'bundled'
shell: bash
run: |
echo "OPENSSL_RUST_USE_NASM=0" >> $GITHUB_ENV
echo OPENSSL_SRC_PERL=C:/Strawberry/perl/bin/perl >> $GITHUB_ENV
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV
vcpkg install openssl:x64-windows-static-md
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand All @@ -89,7 +88,7 @@ jobs:
- name: Test compile diesel
shell: bash
# currently broken as diesel does not allow pq-sys 0.5 yet
# allow to fail as diesel might not pull in the right feature yet
continue-on-error: true
run: |
cargo new test_diesel
Expand Down
2 changes: 1 addition & 1 deletion pq-src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ keywords = ["bindings", "libpq", "pq-sys", "bundled"]
categories = ["database", "external-ffi-bindings"]
readme = "README.md"

[target.'cfg(not(target_os = "windows"))'.dependencies]
[dependencies]
openssl-sys = "0.9.93"

[build-dependencies]
Expand Down
7 changes: 4 additions & 3 deletions pq-src/additional_include/pg_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,8 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1


#ifndef __WIN32__
/* Define to 1 to build with OpenSSL support. (--with-ssl=openssl) */
#define USE_OPENSSL 1
#endif

/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
Expand Down Expand Up @@ -276,3 +273,7 @@
#if defined _WIN32
#define HAVE_INET_ATON 1
#endif

#if defined _WIN32
#define HAVE_DECL_STRNLEN 1
#endif
23 changes: 9 additions & 14 deletions pq-src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const LIBPORTS_WINDOWS: &[&str] = &[
"win32stat.c",
"open.c",
"dirmod.c",
"inet_aton.c",
];

const LIBCOMMON_BASE: &[&str] = &[
Expand Down Expand Up @@ -78,22 +79,14 @@ const LIBCOMMON_BASE: &[&str] = &[
"restricted_token.c",
"sprompt.c",
"logging.c",
];

const LIBCOMMON_NOT_WINDOWS: &[&str] = &[
"cryptohash_openssl.c",
"hmac_openssl.c",
"protocol_openssl.c",
];

const LIBCOMMON_WINDOWS: &[&str] = &[
"cryptohash.c",
"hmac.c",
"md5.c",
"sha1.c",
"sha2.c",
"wchar.c",
];
const LIBCOMMON_NOT_WINDOWS: &[&str] = &[];

const LIBCOMMON_WINDOWS: &[&str] = &["wchar.c"];

const LIBPQ_BASE: &[&str] = &[
"fe-auth-scram.c",
Expand All @@ -109,9 +102,11 @@ const LIBPQ_BASE: &[&str] = &[
"legacy-pqsignal.c",
"libpq-events.c",
"pqexpbuffer.c",
"fe-secure-common.c",
"fe-secure-openssl.c",
];

const LIBPQ_NOT_WINDOWS: &[&str] = &["fe-secure-common.c", "fe-secure-openssl.c"];
const LIBPQ_NOT_WINDOWS: &[&str] = &[];

const LIBPQ_WINDOWS: &[&str] = &["fe-secure.c", "pthread-win32.c", "win32.c"];

Expand Down Expand Up @@ -173,6 +168,7 @@ fn main() {
format!("{path}src/include"),
format!("{crate_dir}/additional_include"),
temp_include.clone(),
env::var("DEP_OPENSSL_INCLUDE").unwrap().clone(),
][..];

let includes = if target_os == "windows" {
Expand All @@ -182,8 +178,7 @@ fn main() {
];
[base_includes, includes_windows].concat()
} else {
let includes_not_windows = &[env::var("DEP_OPENSSL_INCLUDE").unwrap().clone()];
[base_includes, includes_not_windows].concat()
base_includes.to_vec()
};

basic_build
Expand Down
1 change: 0 additions & 1 deletion pq-src/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#[cfg(not(target_os = "windows"))]
extern crate openssl_sys;

0 comments on commit 13f1158

Please sign in to comment.