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

Commit0e08a3a

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 parentbf27089 commit0e08a3a

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
@@ -118,6 +118,34 @@ sub copyFile
118118
return;
119119
}
120120

121+
# Fetch version of OpenSSL based on a parsing of the command shipped with
122+
# the installer this build is linking to. This returns as result an array
123+
# made of the three first digits of the OpenSSL version, which is enough
124+
# to decide which options to apply depending on the version of OpenSSL
125+
# linking with.
126+
subGetOpenSSLVersion
127+
{
128+
my$self =shift;
129+
130+
# Attempt to get OpenSSL version and location. This assumes that
131+
# openssl.exe is in the specified directory.
132+
my$opensslcmd =
133+
$self->{options}->{openssl} ."\\bin\\openssl.exe version 2>&1";
134+
my$sslout =`$opensslcmd`;
135+
136+
$? >> 8 == 0
137+
or croak
138+
"Unable to determine OpenSSL version: The openssl.exe command wasn't found.";
139+
140+
if ($sslout =~/(\d+)\.(\d+)\.(\d+)(\D)/m)
141+
{
142+
return ($1,$2,$3);
143+
}
144+
145+
croak
146+
"Unable to determine OpenSSL version: The openssl.exe version could not be determined.";
147+
}
148+
121149
subGenerateFiles
122150
{
123151
my$self =shift;
@@ -172,10 +200,9 @@ sub GenerateFiles
172200
print$o"#ifndef IGNORE_CONFIGURED_SETTINGS\n";
173201
print$o"#define USE_ASSERT_CHECKING 1\n"
174202
if ($self->{options}->{asserts});
175-
print$o"#define USE_LDAP 1\n"if ($self->{options}->{ldap});
176-
print$o"#define HAVE_LIBZ 1\n"if ($self->{options}->{zlib});
177-
print$o"#define USE_OPENSSL 1\n"if ($self->{options}->{openssl});
178-
print$o"#define ENABLE_NLS 1\n"if ($self->{options}->{nls});
203+
print$o"#define USE_LDAP 1\n"if ($self->{options}->{ldap});
204+
print$o"#define HAVE_LIBZ 1\n"if ($self->{options}->{zlib});
205+
print$o"#define ENABLE_NLS 1\n"if ($self->{options}->{nls});
179206

180207
print$o"#define BLCKSZ", 1024 *$self->{options}->{blocksize},
181208
"\n";
@@ -223,6 +250,21 @@ sub GenerateFiles
223250
{
224251
print$o"#define ENABLE_GSS 1\n";
225252
}
253+
if ($self->{options}->{openssl})
254+
{
255+
print$o"#define USE_OPENSSL 1\n";
256+
257+
my ($digit1,$digit2,$digit3) =$self->GetOpenSSLVersion();
258+
259+
# More symbols are needed with OpenSSL 1.1.0 and above.
260+
if ($digit1 >='1' &&$digit2 >='1' &&$digit3 >='0')
261+
{
262+
print$o"#define HAVE_ASN1_STRING_GET0_DATA 1\n";
263+
print$o"#define HAVE_BIO_GET_DATA 1\n";
264+
print$o"#define HAVE_BIO_METH_NEW 1\n";
265+
print$o"#define HAVE_OPENSSL_INIT_SSL 1\n";
266+
}
267+
}
226268
if ($self->{options}->{icu})
227269
{
228270
print$o"#define USE_ICU 1\n";
@@ -579,21 +621,70 @@ sub AddProject
579621
if ($self->{options}->{openssl})
580622
{
581623
$proj->AddIncludeDir($self->{options}->{openssl} .'\include');
582-
if (-e"$self->{options}->{openssl}/lib/VC/ssleay32MD.lib")
624+
my ($digit1,$digit2,$digit3) =$self->GetOpenSSLVersion();
625+
626+
# Starting at version 1.1.0 the OpenSSL installers have
627+
# changed their library names from:
628+
# - libeay to libcrypto
629+
# - ssleay to libssl
630+
if ($digit1 >='1' &&$digit2 >='1' &&$digit3 >='0')
583631
{
584-
$proj->AddLibrary(
585-
$self->{options}->{openssl} .'\lib\VC\ssleay32.lib', 1);
586-
$proj->AddLibrary(
587-
$self->{options}->{openssl} .'\lib\VC\libeay32.lib', 1);
632+
my$dbgsuffix;
633+
my$libsslpath;
634+
my$libcryptopath;
635+
636+
# The format name of the libraries is slightly
637+
# different between the Win32 and Win64 platform, so
638+
# adapt.
639+
if (-e"$self->{options}->{openssl}/lib/VC/sslcrypto32MD.lib")
640+
{
641+
# Win32 here, with a debugging library set.
642+
$dbgsuffix = 1;
643+
$libsslpath ='\lib\VC\libssl32.lib';
644+
$libcryptopath ='\lib\VC\libcrypto32.lib';
645+
}
646+
elsif (-e"$self->{options}->{openssl}/lib/VC/sslcrypto64MD.lib")
647+
{
648+
# Win64 here, with a debugging library set.
649+
$dbgsuffix = 1;
650+
$libsslpath ='\lib\VC\libssl64.lib';
651+
$libcryptopath ='\lib\VC\libcrypto64.lib';
652+
}
653+
else
654+
{
655+
# On both Win32 and Win64 the same library
656+
# names are used without a debugging context.
657+
$dbgsuffix = 0;
658+
$libsslpath ='\lib\libssl.lib';
659+
$libcryptopath ='\lib\libcrypto.lib';
660+
}
661+
662+
$proj->AddLibrary($self->{options}->{openssl} .$libsslpath,
663+
$dbgsuffix);
664+
$proj->AddLibrary($self->{options}->{openssl} .$libcryptopath,
665+
$dbgsuffix);
588666
}
589667
else
590668
{
591-
# We don't expect the config-specific library to be here,
592-
# so don't ask for it in last parameter
593-
$proj->AddLibrary(
594-
$self->{options}->{openssl} .'\lib\ssleay32.lib', 0);
595-
$proj->AddLibrary(
596-
$self->{options}->{openssl} .'\lib\libeay32.lib', 0);
669+
# Choose which set of libraries to use depending on if
670+
# debugging libraries are in place in the installer.
671+
if (-e"$self->{options}->{openssl}/lib/VC/ssleay32MD.lib")
672+
{
673+
$proj->AddLibrary(
674+
$self->{options}->{openssl} .'\lib\VC\ssleay32.lib', 1);
675+
$proj->AddLibrary(
676+
$self->{options}->{openssl} .'\lib\VC\libeay32.lib', 1);
677+
}
678+
else
679+
{
680+
# We don't expect the config-specific library
681+
# to be here, so don't ask for it in last
682+
# parameter.
683+
$proj->AddLibrary(
684+
$self->{options}->{openssl} .'\lib\ssleay32.lib', 0);
685+
$proj->AddLibrary(
686+
$self->{options}->{openssl} .'\lib\libeay32.lib', 0);
687+
}
597688
}
598689
}
599690
if ($self->{options}->{nls})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp