summaryrefslogtreecommitdiffstats
path: root/Configurations/unix-Makefile.tmpl
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-09-23 12:54:56 +0200
committerRichard Levitte <levitte@openssl.org>2020-09-25 10:08:41 +0200
commite07a7892ee1bb2a2b697d4ad636b02bdc742fa10 (patch)
treeb2d55867f347227984c99ef6d231ed605d4da35c /Configurations/unix-Makefile.tmpl
parent25b16562d386bfd30c7059366d09864260d9f271 (diff)
Configuration: Make it possible to have an argument file
Some compilers / linkers allow arguments to be given in a file instead of on the command line. We make it possible to specify this by giving the compiler / linker flag for it, using the config attribute 'shared_argfileflag'. This currently only impacts the build of shared libraries, as those are potentially made up of a massive amount of object files, which has been reported to overwhelm the command line on some platforms. Fixes #12797 Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12960)
Diffstat (limited to 'Configurations/unix-Makefile.tmpl')
-rw-r--r--Configurations/unix-Makefile.tmpl39
1 files changed, 33 insertions, 6 deletions
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
index 44bf206d00..20fe46e337 100644
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -1437,6 +1437,7 @@ EOF
my $simple = platform->sharedlib_simple($args{lib});
my $full = platform->sharedlib($args{lib});
+ my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef;
my $shared_soname = "";
$shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
if defined $target{shared_sonameflag};
@@ -1445,10 +1446,31 @@ EOF
if defined $target{shared_impflag};
my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
- my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
- my $deps = join(" \\\n" . ' ' x (length($full) + 2),
- fill_lines(' ', $COLUMNS - length($full) - 2,
- @objs, @defs, @deps));
+ # There is at least one platform where the compiler-as-linker needs to
+ # have one object file directly on the command line. That won't hurt
+ # any other platform, so we do that for everyone when there's an argfile
+ # to be had. This depends heavily on splice, which removes elements from
+ # the given array, and returns them so they can be captured.
+ my @argfileobjs = $argfile
+ ? splice(@objs, 1)
+ : ();
+ my $argfilecmds = $argfile
+ ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs)
+ : undef;
+ my $argfiledeps = $argfile
+ ? join(" \\\n" . ' ' x (length($argfile) + 2),
+ fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs))
+ : undef;
+ my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps);
+ my @fullobjs = (
+ @objs,
+ ($argfile ? $target{shared_argfileflag}.$argfile : ())
+ );
+ my $fulldeps =
+ join(" \\\n" . ' ' x (length($full) + 2),
+ fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps));
+ my $fullobjs =
+ join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs));
my $recipe = <<"EOF";
$simple: $full
@@ -1465,10 +1487,10 @@ EOF
EOF
}
$recipe .= <<"EOF";
-$full: $deps
+$full: $fulldeps
\$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
-o $full$shared_def \\
- $objs \\
+ $fullobjs \\
$linklibs \$(LIB_EX_LIBS)
EOF
if (windowsdll()) {
@@ -1481,6 +1503,11 @@ EOF
cp -p $full fuzz/
EOF
}
+ $recipe .= <<"EOF" if defined $argfile;
+$argfile: $argfiledeps
+ \$(RM) $argfile
+ $argfilecmds
+EOF
return $recipe;
}
sub obj2dso {