[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Thu Nov 10 14:52:17 UTC 2016


The branch master has been updated
       via  cf551a51d2385f59536645f644f03a572cc232f9 (commit)
       via  473a954771508f4d488bfba5fc7699fe8b45bdcf (commit)
       via  186a31e510d1326063cfeca17e58fadec236ad2a (commit)
      from  42e055e12496a0eab72c64de845aa5bb18a9c4a2 (commit)


- Log -----------------------------------------------------------------
commit cf551a51d2385f59536645f644f03a572cc232f9
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Nov 9 20:09:03 2016 +0100

    Link internal tests with static OpenSSL libraries when needed
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1889)

commit 473a954771508f4d488bfba5fc7699fe8b45bdcf
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Nov 10 01:00:17 2016 +0100

    Document how to force linking with static libraries
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1889)

commit 186a31e510d1326063cfeca17e58fadec236ad2a
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Nov 9 20:01:51 2016 +0100

    Building: make it possible to force linking with static OpenSSL libs
    
    Very simply, support having the .a extension to denote depending on
    static libraries.  Note that this is not supported on native Windows
    when building shared libraries, as there is not static library then,
    just an import library with the same name.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1889)

-----------------------------------------------------------------------

Summary of changes:
 Configurations/README                |  11 ++++
 Configurations/README.design         |  23 ++++++--
 Configurations/common.tmpl           |  14 +++--
 Configurations/descrip.mms.tmpl      |  23 ++++----
 Configurations/unix-Makefile.tmpl    |  19 ++++---
 Configurations/windows-makefile.tmpl |   4 +-
 Configure                            |   7 +++
 test/build.info                      | 100 +++++++++++------------------------
 test/recipes/03-test_internal.t      |  10 ++--
 9 files changed, 112 insertions(+), 99 deletions(-)

diff --git a/Configurations/README b/Configurations/README
index 0b82ded..21a6f03 100644
--- a/Configurations/README
+++ b/Configurations/README
@@ -339,6 +339,17 @@ source as well.  However, the files given through SOURCE are expected
 to be located in the source tree while files given through DEPEND are
 expected to be located in the build tree)
 
+It's also possible to depend on static libraries explicitely:
+
+    DEPEND[foo]=libsomething.a
+    DEPEND[libbar]=libsomethingelse.a
+
+This should be rarely used, and care should be taken to make sure it's
+only used when supported.  For example, native Windows build doesn't
+support build static libraries and DLLs at the same time, so using
+static libraries on Windows can only be done when configured
+'no-shared'.
+
 For some libraries, we maintain files with public symbols and their
 slot in a transfer vector (important on some platforms).  It can be
 declared like this:
diff --git a/Configurations/README.design b/Configurations/README.design
index bea9790..41c2949 100644
--- a/Configurations/README.design
+++ b/Configurations/README.design
@@ -133,7 +133,7 @@ library 'libssl' is built from the source file 'ssl/tls.c'.
 
     ENGINES_NO_INST=ossltest
     SOURCE[ossltest]=e_ossltest.c
-    DEPEND[ossltest]=../libcrypto
+    DEPEND[ossltest]=../libcrypto.a
     INCLUDE[ossltest]=../include
 
 This is the build.info file in 'engines/', telling us that two engines
@@ -142,8 +142,9 @@ dasync's source is 'engines/e_dasync.c' and ossltest's source is
 'engines/e_ossltest.c' and that the include directory 'include/' may
 be used when building anything that will be part of these engines.
 Also, both engines depend on the library 'libcrypto' to function
-properly.  Finally, only dasync is being installed, as ossltest is
-only for internal testing.
+properly.  ossltest is explicitly linked with the static variant of
+the library 'libcrypto'.  Finally, only dasync is being installed, as
+ossltest is only for internal testing.
 
 When Configure digests these build.info files, the accumulated
 information comes down to this:
@@ -170,7 +171,7 @@ information comes down to this:
 
     ENGINES_NO_INST=engines/ossltest
     SOURCE[engines/ossltest]=engines/e_ossltest.c
-    DEPEND[engines/ossltest]=libcrypto
+    DEPEND[engines/ossltest]=libcrypto.a
     INCLUDE[engines/ossltest]=include
     
     GENERATE[crypto/buildinf.h]=util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)"
@@ -281,10 +282,14 @@ section above would be digested into a %unified_info table:
                     [
                         "crypto/buildinf.h",
                     ],
-                "engines/ossltest" =>
+                "engines/dasync" =>
                     [
                         "libcrypto",
                     ],
+                "engines/ossltest" =>
+                    [
+                        "libcrypto.a",
+                    ],
                 "libssl" =>
                     [
                         "libcrypto",
@@ -396,6 +401,14 @@ section above would be digested into a %unified_info table:
                     [
                         "crypto/evp.c",
                     ],
+                "engines/e_dasync.o" =>
+                    [
+                        "engines/e_dasync.c",
+                    ],
+                "engines/dasync" =>
+                    [
+                        "engines/e_dasync.o",
+                    ],
                 "engines/e_ossltest.o" =>
                     [
                         "engines/e_ossltest.c",
diff --git a/Configurations/common.tmpl b/Configurations/common.tmpl
index d811a2a..5fd6b97 100644
--- a/Configurations/common.tmpl
+++ b/Configurations/common.tmpl
@@ -9,15 +9,22 @@
  # there are no duplicate dependencies and that they are in the
  # right order.  This is especially used to sort the list of
  # libraries that a build depends on.
+ sub extensionlesslib {
+     my @result = map { $_ =~ /(\.a)?$/; $` } @_;
+     return @result if wantarray;
+     return $result[0];
+ }
  sub resolvedepends {
      my $thing = shift;
+     my $extensionlessthing = extensionlesslib($thing);
      my @listsofar = @_;    # to check if we're looping
-     my @list = @{$unified_info{depends}->{$thing}};
+     my @list = @{$unified_info{depends}->{$extensionlessthing}};
      my @newlist = ();
      if (scalar @list) {
          foreach my $item (@list) {
+             my $extensionlessitem = extensionlesslib($item);
              # It's time to break off when the dependency list starts looping
-             next if grep { $_ eq $item } @listsofar;
+             next if grep { extensionlesslib($_) eq $extensionlessitem } @listsofar;
              push @newlist, $item, resolvedepends($item, @listsofar, $item);
          }
      }
@@ -28,8 +35,9 @@
      my @newlist = ();
      while (@list) {
          my $item = shift @list;
+         my $extensionlessitem = extensionlesslib($item);
          push @newlist, $item
-             unless grep { $item eq $_ } @list;
+             unless grep { $extensionlessitem eq extensionlesslib($_) } @list;
      }
      @newlist;
  }
diff --git a/Configurations/descrip.mms.tmpl b/Configurations/descrip.mms.tmpl
index 5a6e8d1..cde5144 100644
--- a/Configurations/descrip.mms.tmpl
+++ b/Configurations/descrip.mms.tmpl
@@ -525,6 +525,17 @@ configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{bu
   use File::Basename;
   use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
 
+  # Helper function to figure out dependencies on libraries
+  # It takes a list of library names and outputs a list of dependencies
+  sub compute_lib_depends {
+      if ($disabled{shared}) {
+          return map { $_ =~ /\.a$/ ? $`.".OLB" : $_.".OLB" } @_;
+      }
+      return map { $_ =~ /\.a$/
+                   ? $`.".OLB"
+                   : $unified_info{sharednames}->{$_}.".EXE" } @_;
+  }
+
   sub generatesrc {
       my %args = @_;
       my $generator = join(" ", @{$args{generator}});
@@ -627,9 +638,7 @@ EOF
       my $libd = dirname($lib);
       my $libn = basename($lib);
       (my $mkdef_key = $libn) =~ s/^${osslprefix_q}lib([^0-9]*)\d*/$1/i;
-      my @deps = map {
-          $disabled{shared} ? $_.".OLB"
-              : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
+      my @deps = compute_lib_depends(@{$args{deps}});
       my $deps = join(", -\n\t\t", @deps);
       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
       my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
@@ -675,9 +684,7 @@ EOF
       my $libn = basename($lib);
       (my $libn_nolib = $libn) =~ s/^lib//;
       my @objs = map { "$_.OBJ" } @{$args{objs}};
-      my @deps = map {
-          $disabled{shared} ? $_.".OLB"
-              : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
+      my @deps = compute_lib_depends(@{$args{deps}});
       my $deps = join(", -\n\t\t", @objs, @deps);
       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
@@ -727,9 +734,7 @@ EOF
       my $bind = dirname($bin);
       my $binn = basename($bin);
       my @objs = map { "$_.OBJ" } @{$args{objs}};
-      my @deps = map {
-          $disabled{shared} ? $_.".OLB"
-              : $unified_info{sharednames}->{$_}.".EXE"; } @{$args{deps}};
+      my @deps = compute_lib_depends(@{$args{deps}});
       my $deps = join(", -\n\t\t", @objs, @deps);
       # The "[]" hack is because in .OPT files, each line inherits the
       # previous line's file spec as default, so if no directory spec
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
index 1c85637..84ceb76 100644
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -844,13 +844,13 @@ configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build
   # It takes a list of library names and outputs a list of dependencies
   sub compute_lib_depends {
       if ($disabled{shared}) {
-          return map { $_.$libext } @_;
+          return map { $_ =~ /\.a$/ ? $`.$libext : $_.$libext } @_;
       }
 
       # Depending on shared libraries:
       # On Windows POSIX layers, we depend on {libname}.dll.a
       # On Unix platforms, we depend on {shlibname}.so
-      return map { shlib_simple($_) } @_;
+      return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
   }
 
   sub generatesrc {
@@ -1073,11 +1073,16 @@ EOF
       my $binn = basename($bin);
       my $objs = join(" ", map { $_.$objext } @{$args{objs}});
       my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
-      my $linklibs = join("", map { my $d = dirname($_);
-                                    my $f = basename($_);
-                                    $d = "." if $d eq $f;
-                                    (my $l = $f) =~ s/^lib//;
-                                    " -L$d -l$l" } @{$args{deps}});
+      my $linklibs = join("", map { if ($_ =~ /\.a$/) {
+                                        " $_";
+                                    } else {
+                                        my $d = dirname($_);
+                                        my $f = basename($_);
+                                        $d = "." if $d eq $f;
+                                        (my $l = $f) =~ s/^lib//;
+                                        " -L$d -l$l"
+                                    }
+                                  } @{$args{deps}});
       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
       my $cc = '$(CC)';
       my $cflags = '$(CFLAGS) $(BIN_CFLAGS)';
diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl
index a0ee953..d744110 100644
--- a/Configurations/windows-makefile.tmpl
+++ b/Configurations/windows-makefile.tmpl
@@ -347,8 +347,10 @@ configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{b
  # It takes a list of library names and outputs a list of dependencies
  sub compute_lib_depends {
      if ($disabled{shared}) {
-	 return map { $_.$libext } @_;
+	 return map { $_ =~ /\.a$/ ? $`.$libext : $_.$libext } @_;
      }
+     die "Linking with static OpenSSL libraries is not supported in this configuration\n"
+         if grep /\.a$/, @_;
      return map { shlib_import($_) } @_;
  }
 
diff --git a/Configure b/Configure
index 3289e9f..307b1d8 100755
--- a/Configure
+++ b/Configure
@@ -1856,9 +1856,16 @@ EOF
                     $d = cleanfile($buildd, $_, $blddir);
                 }
                 # Take note if the file to depend on is being renamed
+                # Take extra care with files ending with .a, they should
+                # be treated without that extension, and the extension
+                # should be added back after treatment.
+                $d =~ /(\.a)?$/;
+                my $e = $1 // "";
+                $d = $`;
                 if ($unified_info{rename}->{$d}) {
                     $d = $unified_info{rename}->{$d};
                 }
+                $d .= $e;
                 $unified_info{depends}->{$ddest}->{$d} = 1;
                 # If we depend on a header file or a perl module, let's make
                 # sure it can get included
diff --git a/test/build.info b/test/build.info
index f51866a..e9f87ed 100644
--- a/test/build.info
+++ b/test/build.info
@@ -312,79 +312,39 @@ IF[{- !$disabled{tests} -}]
   ENDIF
 
   # Internal test programs.  These are essentially a collection of internal
-  # test routines.  Because they sometimes need to reach internal symbols that
-  # aren't available through the shared library (at least on Linux, Solaris,
-  # Windows and VMS, where the exported symbols are those listed in util/*.num),
-  # these programs may be built on files directly picked from inside crypto/
-  # or ssl/, to test using symbols that exist in those specific files.  These
-  # programs will also be linked with libcrypto / libssl, so we don't pick
-  # out more specific files than necessary.
-  # This might mean we have multiply defined symbols, but since linking is
-  # ordered with object files first and libraries after, the symbols from the
-  # object files will be chosen before those in the libraries.  This is handled
-  # properly by all linkers.
-  # Note that when building with static libraries, none of those extra files
-  # are needed, since all symbols are available anyway, regardless of what's
-  # listed in util/*.num.
-  PROGRAMS_NO_INST=asn1_internal_test modes_internal_test x509_internal_test
-  IF[{- !$disabled{mdc2} -}]
-    PROGRAMS_NO_INST=mdc2_internal_test
-  ENDIF
-  IF[{- !$disabled{poly1305} -}]
-    PROGRAMS_NO_INST=poly1305_internal_test
-  ENDIF
-
-  SOURCE[poly1305_internal_test]=poly1305_internal_test.c testutil.c test_main_custom.c
-  IF[{- !$disabled{shared} -}]
-    SOURCE[poly1305_internal_test]= ../crypto/poly1305/poly1305.c \
-        {- rebase_files("../crypto/poly1305", $target{poly1305_asm_src}) -} \
-        {- rebase_files("../crypto", $target{cpuid_asm_src}) -} \
-        ../crypto/cryptlib.c
+  # test routines.  Some of them need to reach internal symbols that aren't
+  # available through the shared library (at least on Linux, Solaris, Windows
+  # and VMS, where the exported symbols are those listed in util/*.num), these
+  # programs are forcebly linked with the static libraries, where all symbols
+  # are always available.  This excludes linking these programs natively on
+  # Windows when building shared libraries, since the static libraries share
+  # names with the DLL import libraries.
+  IF[{- $disabled{shared} || $target{build_scheme}->[1] ne 'windows' -}]
+    PROGRAMS_NO_INST=asn1_internal_test modes_internal_test x509_internal_test
+    IF[{- !$disabled{poly1305} -}]
+      PROGRAMS_NO_INST=poly1305_internal_test
+    ENDIF
+
+    SOURCE[poly1305_internal_test]=poly1305_internal_test.c testutil.c test_main_custom.c
+    INCLUDE[poly1305_internal_test]=.. ../include ../crypto/include
+    DEPEND[poly1305_internal_test]=../libcrypto.a
+
+    SOURCE[asn1_internal_test]=asn1_internal_test.c testutil.c test_main.c
+    INCLUDE[asn1_internal_test]=.. ../include ../crypto/include
+    DEPEND[asn1_internal_test]=../libcrypto.a
+
+    SOURCE[modes_internal_test]=modes_internal_test.c testutil.c test_main_custom.c
+    INCLUDE[modes_internal_test]=.. ../include
+    DEPEND[modes_internal_test]=../libcrypto.a
+
+    SOURCE[x509_internal_test]=x509_internal_test.c testutil.c test_main.c
+    INCLUDE[x509_internal_test]=.. ../include
+    DEPEND[x509_internal_test]=../libcrypto.a
   ENDIF
-  INCLUDE[poly1305_internal_test]=.. ../include ../crypto/include
-  DEPEND[poly1305_internal_test]=../libcrypto
 
-  SOURCE[asn1_internal_test]=asn1_internal_test.c testutil.c test_main.c
-  IF[{- !$disabled{shared} -}]
-    SOURCE[asn1_internal_test]= ../crypto/asn1/a_strnid.c \
-        ../crypto/rsa/rsa_ameth.c ../crypto/dsa/dsa_ameth.c \
-        ../crypto/dh/dh_ameth.c ../crypto/ec/ec_ameth.c \
-        ../crypto/hmac/hm_ameth.c ../crypto/cmac/cm_ameth.c \
-        ../crypto/ec/ecx_meth.c ../crypto/ec/curve25519.c
-  ENDIF
-  INCLUDE[asn1_internal_test]=.. ../include ../crypto/include
-  DEPEND[asn1_internal_test]=../libcrypto
-
-  SOURCE[modes_internal_test]=modes_internal_test.c testutil.c test_main_custom.c
-  IF[{- !$disabled{shared} -}]
-    SOURCE[modes_internal_test]= \
-        {- rebase_files("../crypto", $target{cpuid_asm_src}); -} \
-        ../crypto/cryptlib.c
-  ENDIF
-  INCLUDE[modes_internal_test]=.. ../include
-  DEPEND[modes_internal_test]=../libcrypto
-
-  # The reason for the huge amount of directly included x509v3 files
-  # is that a table that is checked by x509_internal_test refers to
-  # structures that are spread all over those files.
-  SOURCE[x509_internal_test]=x509_internal_test.c testutil.c test_main.c
-  IF[{- !$disabled{shared} -}]
-    SOURCE[x509_internal_test]= ../crypto/x509v3/v3_bitst.c \
-        ../crypto/x509v3/v3_ia5.c ../crypto/x509v3/v3_skey.c \
-        ../crypto/x509v3/v3_pku.c ../crypto/x509v3/v3_alt.c \
-        ../crypto/x509v3/v3_bcons.c ../crypto/x509v3/v3_int.c \
-        ../crypto/x509v3/v3_cpols.c ../crypto/x509v3/v3_akey.c \
-        ../crypto/x509v3/v3_crld.c ../crypto/x509v3/v3_utl.c \
-        ../crypto/x509v3/v3_extku.c ../crypto/x509v3/v3_enum.c \
-        ../crypto/x509v3/v3_sxnet.c ../crypto/x509v3/v3_info.c \
-        ../crypto/x509v3/v3_addr.c ../crypto/x509v3/v3_asid.c \
-        ../crypto/x509v3/v3_pcons.c ../crypto/x509v3/v3_pmaps.c \
-        ../crypto/x509v3/v3_pci.c ../crypto/x509v3/v3_ncons.c \
-        ../crypto/x509v3/v3_tlsf.c ../crypto/ocsp/v3_ocsp.c \
-        ../crypto/ct/ct_x509v3.c ../crypto/asn1/a_strex.c
+  IF[{- !$disabled{mdc2} -}]
+    PROGRAMS_NO_INST=mdc2_internal_test
   ENDIF
-  INCLUDE[x509_internal_test]=.. ../include
-  DEPEND[x509_internal_test]=../libcrypto
 
   SOURCE[mdc2_internal_test]=mdc2_internal_test.c testutil.c test_main.c
   INCLUDE[mdc2_internal_test]=.. ../include
diff --git a/test/recipes/03-test_internal.t b/test/recipes/03-test_internal.t
index 5c7e897..33cb7a3 100644
--- a/test/recipes/03-test_internal.t
+++ b/test/recipes/03-test_internal.t
@@ -12,12 +12,14 @@ use OpenSSL::Test::Utils;
 
 setup("test_internal");
 
+my $shared_windows = $^O eq 'MSWin32' && !disabled("shared");
+
 my %known_internal_tests =
   ( mdc2_internal_test => !disabled("mdc2"),
-    poly1305_internal_test => !disabled("poly1305"),
-    modes_internal_test => 1,
-    asn1_internal_test => 1,
-    x509_internal_test => 1 );
+    poly1305_internal_test => !disabled("poly1305") && !$shared_windows,
+    modes_internal_test => !$shared_windows,
+    asn1_internal_test => !$shared_windows,
+    x509_internal_test => !$shared_windows );
 
 plan tests => scalar keys %known_internal_tests;
 


More information about the openssl-commits mailing list