Bug 270769 - databases/postgresql13-client fails to build WITH_LLVM_BINUTILS (LLVM strip)
Summary: databases/postgresql13-client fails to build WITH_LLVM_BINUTILS (LLVM strip)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: pgsql
URL:
Keywords:
Depends on:
Blocks: 258872
  Show dependency treegraph
 
Reported: 2023-04-11 20:13 UTC by Ed Maste
Modified: 2023-05-24 20:23 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (pgsql)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2023-04-11 20:13:31 UTC
From the exp-run in PR258872
https://pkg-status.freebsd.org/gohan05/data/mainamd64PR258872-default/2023-04-05_14h36m44s/logs/errors/postgresql13-client-13.10.log

==========
STRIPPROG='strip -x' /bin/sh ../../../config/install-sh -c -m 644 -s libpq.a '/wrkdirs/usr/ports/databases/postgresql13-client/work/stage/usr/local/lib/libpq.a'
strip: error: '/wrkdirs/usr/ports/databases/postgresql13-client/work/stage/usr/local/lib/_inst.20299_': not stripping symbol '.L.str' because it is named in a relocation
==========

pgsql's build has requested to strip all non-global symbols (strip -x), but there is at least one non-global symbol that in fact cannot be stripped because it is referenced by a relocation.

Both GNU strip and ELF Tool Chain strip silently handle this case (and just retain the local symbol), but LLVM strip is stricter and emits an error upon request to strip a non-removable local symbol.

There is an LLVM ticket open for this at https://github.com/llvm/llvm-project/issues/47468. It probably makes sense for LLVM strip to behave the same as GNU and ELF Tool Chain strip, but I believe pgsql should just not use strip -x when there are symbols that cannot be stripped. My suggestion would be to consider just not stripping .a archives.
Comment 1 Ed Maste freebsd_committer freebsd_triage 2023-04-15 03:46:51 UTC
Submitted pgsql bug:
BUG #17898: Build failure when strip is LLVM's version
Comment 2 Ed Maste freebsd_committer freebsd_triage 2023-04-15 22:20:20 UTC
https://reviews.freebsd.org/D39590
Comment 3 Palle Girgensohn freebsd_committer freebsd_triage 2023-04-20 09:39:01 UTC
I think this should propagate upstreams, to the postgresql community. Right?
Comment 4 Ed Maste freebsd_committer freebsd_triage 2023-04-21 02:15:23 UTC
Tom Lane replied and the change to use --strip-unneeded has been applied upstream: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=a14afd3bdc21c0c56401fb8cb2fce74f4b7dc446

I'm not sure what the timeline is for pgsql updates though, we might want to apply it as a local patch until the next update comes along?
Comment 5 Palle Girgensohn freebsd_committer freebsd_triage 2023-04-25 15:28:36 UTC
Yeah, I started the conversation upstreams, and it is now it is patched.

We should make a local patch until the upstream change hits us. I'll handle that. :)
Comment 6 Ed Maste freebsd_committer freebsd_triage 2023-05-24 19:18:32 UTC
I see that pgsql was updated in 3fd6f200dc8c12022515f7c3f662df148941e261, did it bring in the strip change?
Comment 7 Palle Girgensohn freebsd_committer freebsd_triage 2023-05-24 20:21:24 UTC
(In reply to Ed Maste from comment #6)
I hae to check, but yes, the idea was that this was fixed upstreams.
Comment 8 Palle Girgensohn freebsd_committer freebsd_triage 2023-05-24 20:23:58 UTC
This was fixed upstreams with the latest patch release:


commit 6dce37203410b011c0ccae40acf2649f79c38242
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date:   Thu Apr 20 18:12:32 2023 -0400

    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