VMS: Make sure to include MAIN from static libraries if needed
authorRichard Levitte <levitte@openssl.org>
Wed, 19 Apr 2017 10:32:42 +0000 (12:32 +0200)
committerRichard Levitte <levitte@openssl.org>
Mon, 24 Apr 2017 16:09:01 +0000 (18:09 +0200)
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3243)

Configurations/descrip.mms.tmpl
test/build.info

index 27b407d02826a654b0804465e14c9f9751dd83c7..e0ded0b667c176cc974cd8ac98f3629390d212e9 100644 (file)
@@ -756,21 +756,38 @@ EOF
       my $bind = dirname($bin);
       my $binn = basename($bin);
       my @objs = map { "$_.OBJ" } @{$args{objs}};
+      my $objs = join(",", @objs);
       my @deps = compute_lib_depends(@{$args{deps}});
       my $deps = join(", -\n\t\t", @objs, @deps);
+
+      my $olb_count = scalar grep(m|\.OLB$|, @deps);
+      my $analyse_objs = "@ !";
+      if ($olb_count > 0) {
+          my $analyse_quals =
+              $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
+          $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
+      }
       # The "[]" hack is because in .OPT files, each line inherits the
       # previous line's file spec as default, so if no directory spec
       # is present in the current line and the previous line has one that
       # doesn't apply, you're in for a surprise.
       my $write_opt1 =
           join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
-                                 "WRITE OPT_FILE \"$x" } @objs).
+                                 "\@ WRITE OPT_FILE \"$x" } @objs).
           "\"";
       my $write_opt2 =
-          join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
-                             $x =~ s|(\.EXE)|$1/SHARE|;
-                             $x =~ s|(\.OLB)|$1/LIB|;
-                             "WRITE OPT_FILE \"$x\"" } @deps)
+          join("\n\t", map { my @lines = ();
+                             my $x = $_ =~ /\[/ ? $_ : "[]".$_;
+                             if ($x =~ m|\.EXE$|) {
+                                 push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\"";
+                             } elsif ($x =~ m|\.OLB$|) {
+                                 (my $l = $x) =~ s/\W/_/g;
+                                 push @lines, 
+                                     "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB\$(INCLUDE_MAIN_$l)\"",
+                                     "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\""
+                             }
+                             @lines
+                           } @deps)
           || "\@ !";
       # The linking commands looks a bit complex, but it's for good reason.
       # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
@@ -792,10 +809,12 @@ EOF
       # and let it break the build.
       return <<"EOF"
 $bin.EXE : $deps
-        OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
+        $analyse_objs
+        @ OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
         $write_opt1
         $write_opt2
-        CLOSE OPT_FILE
+        @ CLOSE OPT_FILE
+        TYPE $bin.opt ! For debugging
         - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG -
                     LINK \$(LDFLAGS)/EXEC=\$\@ $bin.OPT/OPT \$(EX_LIBS) ; -
                link_status = \$status ; link_severity = link_status .AND. 7
@@ -817,7 +836,7 @@ $bin.EXE : $deps
         @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
         - PURGE $bin.EXE,$bin.OPT
 EOF
-        . ($config{target} =~ m|alpha| ? "" : <<"EOF"
+      . ($config{target} =~ m|alpha| ? "" : <<"EOF"
         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
 EOF
         );
index f75b85a6414c3f0f2a8b4c0ee4d6bc85efb2d2de..d17a4b087ba785d199d55ffd56159d4bae0fbecd 100644 (file)
@@ -15,6 +15,13 @@ IF[{- !$disabled{tests} -}]
   INCLUDE[libtestutil.a]=../include
   DEPEND[libtestutil.a]=../libcrypto
 
+  # Special hack for descrip.mms to include the MAIN object module
+  # explicitely.  This will only be done if there isn't a MAIN in the
+  # program's object modules already.
+  BEGINRAW[descrip.mms]
+INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
+  ENDRAW[descrip.mms]
+
   PROGRAMS_NO_INST=\
           aborttest test_test \
           sanitytest exdatatest bntest \