Generalize link rule in windows-makefile.tmpl
authorTanzinul Islam <tanzinul.islam@gmail.com>
Thu, 19 Nov 2020 17:57:46 +0000 (17:57 +0000)
committerDmitry Belyavskiy <beldmit@gmail.com>
Mon, 19 Apr 2021 09:05:54 +0000 (11:05 +0200)
C++Builder's [`ilink32.exe`][1] expects its different types of input /
output files to be in a particular sequence and comma-separated -- even
in the response file as experimentation revealed, contrary to what is
documented. The lines of the response file need to end with `+`.

Also [`setargv.obj`][2] is MSVC-specific. The C++Builder equivalent is
[`wildargs.obj`][3].

[1]: http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_ILINK32_and_ILINK64_on_the_Command_Line
[2]: https://docs.microsoft.com/en-us/cpp/c-language/expanding-wildcard-arguments?view=msvc-160
[3]: http://docwiki.embarcadero.com/RADStudio/Sydney/en/Wildcard_Arguments

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/13540)

Configurations/10-main.conf
Configurations/windows-makefile.tmpl

index fbab220360404f96e21accb2733aaf3319b12ad9..f65fd30e5d24cba490c8f235c1f498dfb16bf02c 100644 (file)
@@ -1281,6 +1281,9 @@ my %targets = (
         LD               => "link",
         LDFLAGS          => "/nologo /debug",
         ldoutflag        => "/out:",
+        ldpostoutflag    => "",
+        ld_resp_delim    => "\n",
+        ld_wildcard_args => "setargv.obj",
         AR               => "lib",
         ARFLAGS          => "/nologo",
         aroutflag        => "/out:",
index 51b29515a73051289b38f16ee6a380939c42dd1a..feb9bb1a11cad822d39cf791dbb7b0cd716fc477 100644 (file)
@@ -858,8 +858,8 @@ EOF
                 @{$args{objs}};
      my @deps = compute_lib_depends(@{$args{deps}});
      die "More than one exported symbols list" if scalar @defs > 1;
-     my $linklibs = join("", map { "$_\n" } @deps);
-     my $objs = join("\n", @objs);
+     my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
+     my $objs = join($target{ld_resp_delim}, @objs);
      my $deps = join(" ", @objs, @defs, @deps);
      my $import = platform->sharedlib_import($lib);
      my $dll =  platform->sharedlib($lib);
@@ -874,8 +874,7 @@ $dll: $deps
        IF EXIST \$@ DEL /F /Q \$@
        \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
                /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import; EXIT 1)
-$objs
-$linklibs\$(LIB_EX_LIBS)
+$objs$target{ld_resp_delim}$linklibs\$(LIB_EX_LIBS)
 <<
        IF EXIST $dll.manifest \\
           \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
@@ -898,8 +897,8 @@ EOF
                 grep { platform->isdef($_) }
                 @{$args{objs}};
      my @deps = compute_lib_depends(@{$args{deps}});
-     my $objs = join("\n", @objs);
-     my $linklibs = join("", map { "$_\n" } @deps);
+     my $objs = join($target{ld_resp_delim}, @objs);
+     my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
      my $deps = join(" ", @objs, @defs, @deps);
      my $shared_def = join("", map { " /def:$_" } @defs);
      return <<"EOF";
@@ -907,8 +906,7 @@ $dso: $deps
        IF EXIST $dso.manifest DEL /F /Q $dso.manifest
        \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
                \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.*; EXIT 1)
-$objs
-$linklibs \$(DSO_EX_LIBS)
+$objs$target{ld_resp_delim}$linklibs \$(DSO_EX_LIBS)
 <<
        IF EXIST $dso.manifest \\
           \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
@@ -934,16 +932,14 @@ EOF
                 grep { platform->isobj($_) || platform->isres($_) }
                 @{$args{objs}};
      my @deps = compute_lib_depends(@{$args{deps}});
-     my $objs = join("\n", @objs);
-     my $linklibs = join("", map { "$_\n" } @deps);
+     my $objs = join($target{ld_resp_delim}, @objs);
+     my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
      my $deps = join(" ", @objs, @deps);
      return <<"EOF";
 $bin: $deps
        IF EXIST $bin.manifest DEL /F /Q $bin.manifest
-       \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
-$objs
-setargv.obj
-$linklibs\$(BIN_EX_LIBS)
+       \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) @<<
+$objs$target{ld_resp_delim}$target{ld_wildcard_args}$target{ld_resp_delim}\$(LDOUTFLAG)$bin$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(BIN_EX_LIBS)
 <<
        IF EXIST $bin.manifest \\
           \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin