Build dynamic engines even if configured "no-shared"

Until now, the engines in engines/ were only built as dynamicaly
loadable ones if shared libraries were built.

We not dissociate the two and can build dynamicaly loadable engines
even if we only build static libcrypto and libssl.  This is controlled
with the option (enable|disable|no)-static-engine, defaulting to
no-static-engine.

Note that the engines in crypto/engine/ (dynamic and cryptodev) will
always be built into libcrypto.

Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Richard Levitte 2016-02-19 22:08:37 +01:00
parent 45502bfe19
commit 343ec2b083
5 changed files with 36 additions and 24 deletions

View file

@ -261,7 +261,7 @@ my @disablables = (
"dsa", "dsa",
"dso", "dso",
"dtls", "dtls",
"dynamic[-_]engine", "dynamic-engine",
"ec", "ec",
"ec2m", "ec2m",
"ecdh", "ecdh",
@ -335,6 +335,7 @@ my %disabled = ( # "what" => "comment"
"sctp" => "default", "sctp" => "default",
"shared" => "default", "shared" => "default",
"ssl-trace" => "default", "ssl-trace" => "default",
"static-engine" => "default",
"unit-test" => "default", "unit-test" => "default",
"zlib" => "default", "zlib" => "default",
"crypto-mdebug" => "default", "crypto-mdebug" => "default",
@ -380,6 +381,9 @@ my @disable_cascades = (
"tlsext" => [ "srp", "heartbeats" ], "tlsext" => [ "srp", "heartbeats" ],
"crypto-mdebug" => [ "crypto-mdebug-backtrace" ], "crypto-mdebug" => [ "crypto-mdebug-backtrace" ],
# Without DSO, we can't load dynamic engines, so don't build them dynamic
"dso" => [ "dynamic-engine" ],
); );
# Avoid protocol support holes. Also disable all versions below N, if version # Avoid protocol support holes. Also disable all versions below N, if version
@ -544,6 +548,14 @@ foreach (@argvcopy)
$disabled{$proto} = "option(tls)"; $disabled{$proto} = "option(tls)";
} }
} }
elsif ($1 eq "static-engine")
{
$disabled{"static-engine"} = "option";
}
elsif ($1 eq "dynamic-engine")
{
delete $disabled{"static-engine"};
}
else else
{ {
$disabled{$1} = "option"; $disabled{$1} = "option";
@ -551,6 +563,14 @@ foreach (@argvcopy)
} }
elsif (/^enable-(.+)$/) elsif (/^enable-(.+)$/)
{ {
if ($1 eq "static-engine")
{
delete $disabled{"static-engine"};
}
elsif ($1 eq "dynamic-engine")
{
$disabled{"static-engine"} = "option";
}
my $algo = $1; my $algo = $1;
delete $disabled{$algo}; delete $disabled{$algo};
@ -984,20 +1004,13 @@ if ($target{shared_target} eq "")
$config{no_shared} = 1; $config{no_shared} = 1;
} }
if ($builder ne "mk1mf") if ($disabled{"static-engine"}) {
{ push @{$config{defines}}, "OPENSSL_NO_STATIC_ENGINE";
# add {no-}static-engine to options to allow mkdef.pl to work without extra arguments $config{dynamic_engines} = 1;
if ($config{no_shared}) } else {
{ push @{$config{defines}}, "OPENSSL_NO_DYNAMIC_ENGINE";
push @{$config{openssl_other_defines}}, "OPENSSL_NO_DYNAMIC_ENGINE"; $config{dynamic_engines} = 0;
$config{options}.=" static-engine"; }
}
else
{
push @{$config{openssl_other_defines}}, "OPENSSL_NO_STATIC_ENGINE";
$config{options}.=" no-static-engine";
}
}
# #
# Platform fix-ups # Platform fix-ups
@ -1371,8 +1384,8 @@ if ($builder eq "unified") {
$unified_info{libraries}->{$library} = 1; $unified_info{libraries}->{$library} = 1;
} }
die <<"EOF" if $config{no_shared} && scalar @engines; die <<"EOF" if scalar @engines and !$config{dynamic_engines};
ENGINES can only be used if configured with 'shared'. ENGINES can only be used if configured with 'static-enginex'.
This is usually a fault in a build.info file. This is usually a fault in a build.info file.
EOF EOF
foreach (@engines) { foreach (@engines) {

View file

@ -210,6 +210,7 @@ SHARED_LDFLAG={- $target{shared_ldflag}
. ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$| . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -} ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
SHARED_RCFLAG={- $target{shared_rcflag} -} SHARED_RCFLAG={- $target{shared_rcflag} -}
DYNAMIC_ENGINES={- $config{dynamic_engines} -}
GENERAL= Makefile GENERAL= Makefile
BASENAME= openssl BASENAME= openssl
@ -254,7 +255,7 @@ BUILDENV= LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
AS='$(CC)' ASFLAG='$(CFLAG) -c' \ AS='$(CC)' ASFLAG='$(CFLAG) -c' \
AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)' \ AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)' \
CROSS_COMPILE='$(CROSS_COMPILE)' \ CROSS_COMPILE='$(CROSS_COMPILE)' \
PERL='$(PERL)' \ PERL='$(PERL)' DYNAMIC_ENGINES='$(DYNAMIC_ENGINES)' \
SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)' \ SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)' \
DESTDIR='$(DESTDIR)' \ DESTDIR='$(DESTDIR)' \
INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)' \ INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)' \

View file

@ -57,7 +57,7 @@ top:
all: lib all: lib
lib: $(LIBOBJ) $(TESTLIBOBJ) lib: $(LIBOBJ) $(TESTLIBOBJ)
@if [ -n "$(SHARED_LIBS)" ]; then \ @if [ "$(DYNAMIC_ENGINES)" = 1 ]; then \
set -e; \ set -e; \
for l in $(LIBNAMES) $(TESTLIBNAMES); do \ for l in $(LIBNAMES) $(TESTLIBNAMES); do \
$(MAKE) -f ../Makefile.shared -e \ $(MAKE) -f ../Makefile.shared -e \

View file

@ -1,5 +1,5 @@
{- use File::Spec::Functions qw/:DEFAULT rel2abs/; -} {- use File::Spec::Functions qw/:DEFAULT rel2abs/; -}
IF[{- $config{no_shared} -}] IF[{- !$config{dynamic_engines} -}]
LIBS=../libcrypto LIBS=../libcrypto
SOURCE[../libcrypto]=\ SOURCE[../libcrypto]=\
e_padlock.c {- $target{padlock_asm_src} -} \ e_padlock.c {- $target{padlock_asm_src} -} \

View file

@ -176,8 +176,6 @@ foreach (grep(!/^$/, split(/ /, $OPTIONS)))
print STDERR "unknown option - $_\n" if !&read_options; print STDERR "unknown option - $_\n" if !&read_options;
} }
$no_static_engine = 0 if (!$shlib);
$no_mdc2=1 if ($no_des); $no_mdc2=1 if ($no_des);
$no_ssl3=1 if ($no_md5); $no_ssl3=1 if ($no_md5);
@ -1463,11 +1461,11 @@ sub read_options
{ {
$zlib_opt = 2; $zlib_opt = 2;
} }
elsif (/^no-static-engine/) elsif (/^no-static-engine/ or /^enable-dynamic-engine/)
{ {
$no_static_engine = 1; $no_static_engine = 1;
} }
elsif (/^enable-static-engine/) elsif (/^no-dynamic-engine/ or /^enable-static-engine/)
{ {
$no_static_engine = 0; $no_static_engine = 0;
} }