Use --strip-unneeded when stripping static libraries with GNU strip.

We've long used "--strip-unneeded" for shared libraries but plain
"-x" for static libraries when stripping symbols with GNU strip.
There doesn't seem to be any really good reason for that though,
since --strip-unneeded produces smaller output (as "-x" alone
does not remove debug symbols).  Moreover it seems that
llvm-strip, although it identifies as GNU strip, misbehaves when
given "-x" for this purpose.  It's unclear whether that's
intentional or a bug in llvm-strip, but in any case it seems like
changing to use --strip-unneeded in all cases should be a win.

Note that this doesn't change our behavior when dealing with
non-GNU strip.

Per gripes from Ed Maste and Palle Girgensohn.  Back-patch,
in case anyone wants to use llvm-strip with stable branches.

Discussion: https://postgr.es/m/17898-5308d09543463266@postgresql.org
Discussion: https://postgr.es/m/20230420153338.bbj2g5jiyy3afhjz@awork3.anarazel.de
This commit is contained in:
Tom Lane 2023-04-20 18:12:32 -04:00
parent a9781ae11b
commit eab2d3147e
3 changed files with 3 additions and 3 deletions

View File

@ -307,7 +307,7 @@ AC_DEFUN([PGAC_CHECK_STRIP],
AC_MSG_CHECKING([whether it is possible to strip libraries])
if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
STRIP_STATIC_LIB="$STRIP -x"
STRIP_STATIC_LIB="$STRIP --strip-unneeded"
STRIP_SHARED_LIB="$STRIP --strip-unneeded"
AC_MSG_RESULT(yes)
else

2
configure vendored
View File

@ -9712,7 +9712,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is possible to strip libraries" >&5
$as_echo_n "checking whether it is possible to strip libraries... " >&6; }
if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
STRIP_STATIC_LIB="$STRIP -x"
STRIP_STATIC_LIB="$STRIP --strip-unneeded"
STRIP_SHARED_LIB="$STRIP --strip-unneeded"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }

View File

@ -16,7 +16,7 @@ if strip_bin.found()
strip_version.stdout().contains('GNU strip') or
strip_version.stderr().contains('GNU strip'))
working_strip = true
strip_static_cmd = strip_cmd + ['-x']
strip_static_cmd = strip_cmd + ['--strip-unneeded']
strip_shared_cmd = strip_cmd + ['--strip-unneeded']
elif host_system == 'darwin'
working_strip = true