Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita559805

Browse files
committed
Add support for OpenSSL 1.1.0 and newer versions in MSVC scripts
Up to now, the MSVC build scripts are able to support only one fixedversion of OpenSSL, and they lacked logic to detect the version ofOpenSSL a given compilation of Postgres is linking to (currently 1.0.2,the latest LTS of upstream which will be EOL'd at the end of 2019).This commit adds more logic to detect the version of OpenSSL used by abuild and makes use of it to add support for compilation with OpenSSL1.1.0 which requires a new set of compilation flags to work properly.The supported OpenSSL installers have changed their library layer withvarious library renames with the upgrade to 1.1.0, making the logic abit more complicated. The scripts are now able to adapt to the newworld order.Reported-by: Sergey PashkovAuthor: Juan José Santamaría Flecha, Michael PaquierReviewed-by: Álvaro HerreraDiscussion:https://postgr.es/m/15789-8fc75dea3c5a17c8@postgresql.orgBackpatch-through: 9.4
1 parent8093144 commita559805

File tree

1 file changed

+106
-15
lines changed

1 file changed

+106
-15
lines changed

‎src/tools/msvc/Solution.pm

Lines changed: 106 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,34 @@ sub copyFile
113113
close($o);
114114
}
115115

116+
# Fetch version of OpenSSL based on a parsing of the command shipped with
117+
# the installer this build is linking to. This returns as result an array
118+
# made of the three first digits of the OpenSSL version, which is enough
119+
# to decide which options to apply depending on the version of OpenSSL
120+
# linking with.
121+
subGetOpenSSLVersion
122+
{
123+
my$self =shift;
124+
125+
# Attempt to get OpenSSL version and location. This assumes that
126+
# openssl.exe is in the specified directory.
127+
my$opensslcmd =
128+
$self->{options}->{openssl} ."\\bin\\openssl.exe version 2>&1";
129+
my$sslout =`$opensslcmd`;
130+
131+
$? >> 8 == 0
132+
or croak
133+
"Unable to determine OpenSSL version: The openssl.exe command wasn't found.";
134+
135+
if ($sslout =~/(\d+)\.(\d+)\.(\d+)(\D)/m)
136+
{
137+
return ($1,$2,$3);
138+
}
139+
140+
croak
141+
"Unable to determine OpenSSL version: The openssl.exe version could not be determined.";
142+
}
143+
116144
subGenerateFiles
117145
{
118146
my$self =shift;
@@ -167,10 +195,9 @@ s{PG_VERSION_STR "[^"]+"}{PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, c
167195
print$o"#ifndef IGNORE_CONFIGURED_SETTINGS\n";
168196
print$o"#define USE_ASSERT_CHECKING 1\n"
169197
if ($self->{options}->{asserts});
170-
print$o"#define USE_LDAP 1\n"if ($self->{options}->{ldap});
171-
print$o"#define HAVE_LIBZ 1\n"if ($self->{options}->{zlib});
172-
print$o"#define USE_OPENSSL 1\n"if ($self->{options}->{openssl});
173-
print$o"#define ENABLE_NLS 1\n"if ($self->{options}->{nls});
198+
print$o"#define USE_LDAP 1\n"if ($self->{options}->{ldap});
199+
print$o"#define HAVE_LIBZ 1\n"if ($self->{options}->{zlib});
200+
print$o"#define ENABLE_NLS 1\n"if ($self->{options}->{nls});
174201

175202
print$o"#define BLCKSZ", 1024 *$self->{options}->{blocksize},
176203
"\n";
@@ -221,6 +248,21 @@ s{PG_VERSION_STR "[^"]+"}{PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, c
221248
{
222249
print$o"#define ENABLE_GSS 1\n";
223250
}
251+
if ($self->{options}->{openssl})
252+
{
253+
print$o"#define USE_OPENSSL 1\n";
254+
255+
my ($digit1,$digit2,$digit3) =$self->GetOpenSSLVersion();
256+
257+
# More symbols are needed with OpenSSL 1.1.0 and above.
258+
if ($digit1 >='1' &&$digit2 >='1' &&$digit3 >='0')
259+
{
260+
print$o"#define HAVE_ASN1_STRING_GET0_DATA 1\n";
261+
print$o"#define HAVE_BIO_GET_DATA 1\n";
262+
print$o"#define HAVE_BIO_METH_NEW 1\n";
263+
print$o"#define HAVE_OPENSSL_INIT_SSL 1\n";
264+
}
265+
}
224266
if ($self->{options}->{icu})
225267
{
226268
print$o"#define USE_ICU 1\n";
@@ -529,21 +571,70 @@ sub AddProject
529571
if ($self->{options}->{openssl})
530572
{
531573
$proj->AddIncludeDir($self->{options}->{openssl} .'\include');
532-
if (-e"$self->{options}->{openssl}/lib/VC/ssleay32MD.lib")
574+
my ($digit1,$digit2,$digit3) =$self->GetOpenSSLVersion();
575+
576+
# Starting at version 1.1.0 the OpenSSL installers have
577+
# changed their library names from:
578+
# - libeay to libcrypto
579+
# - ssleay to libssl
580+
if ($digit1 >='1' &&$digit2 >='1' &&$digit3 >='0')
533581
{
534-
$proj->AddLibrary(
535-
$self->{options}->{openssl} .'\lib\VC\ssleay32.lib', 1);
536-
$proj->AddLibrary(
537-
$self->{options}->{openssl} .'\lib\VC\libeay32.lib', 1);
582+
my$dbgsuffix;
583+
my$libsslpath;
584+
my$libcryptopath;
585+
586+
# The format name of the libraries is slightly
587+
# different between the Win32 and Win64 platform, so
588+
# adapt.
589+
if (-e"$self->{options}->{openssl}/lib/VC/sslcrypto32MD.lib")
590+
{
591+
# Win32 here, with a debugging library set.
592+
$dbgsuffix = 1;
593+
$libsslpath ='\lib\VC\libssl32.lib';
594+
$libcryptopath ='\lib\VC\libcrypto32.lib';
595+
}
596+
elsif (-e"$self->{options}->{openssl}/lib/VC/sslcrypto64MD.lib")
597+
{
598+
# Win64 here, with a debugging library set.
599+
$dbgsuffix = 1;
600+
$libsslpath ='\lib\VC\libssl64.lib';
601+
$libcryptopath ='\lib\VC\libcrypto64.lib';
602+
}
603+
else
604+
{
605+
# On both Win32 and Win64 the same library
606+
# names are used without a debugging context.
607+
$dbgsuffix = 0;
608+
$libsslpath ='\lib\libssl.lib';
609+
$libcryptopath ='\lib\libcrypto.lib';
610+
}
611+
612+
$proj->AddLibrary($self->{options}->{openssl} .$libsslpath,
613+
$dbgsuffix);
614+
$proj->AddLibrary($self->{options}->{openssl} .$libcryptopath,
615+
$dbgsuffix);
538616
}
539617
else
540618
{
541-
# We don't expect the config-specific library to be here,
542-
# so don't ask for it in last parameter
543-
$proj->AddLibrary(
544-
$self->{options}->{openssl} .'\lib\ssleay32.lib', 0);
545-
$proj->AddLibrary(
546-
$self->{options}->{openssl} .'\lib\libeay32.lib', 0);
619+
# Choose which set of libraries to use depending on if
620+
# debugging libraries are in place in the installer.
621+
if (-e"$self->{options}->{openssl}/lib/VC/ssleay32MD.lib")
622+
{
623+
$proj->AddLibrary(
624+
$self->{options}->{openssl} .'\lib\VC\ssleay32.lib', 1);
625+
$proj->AddLibrary(
626+
$self->{options}->{openssl} .'\lib\VC\libeay32.lib', 1);
627+
}
628+
else
629+
{
630+
# We don't expect the config-specific library
631+
# to be here, so don't ask for it in last
632+
# parameter.
633+
$proj->AddLibrary(
634+
$self->{options}->{openssl} .'\lib\ssleay32.lib', 0);
635+
$proj->AddLibrary(
636+
$self->{options}->{openssl} .'\lib\libeay32.lib', 0);
637+
}
547638
}
548639
}
549640
if ($self->{options}->{nls})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp