install-strip causes dyld errors on OS X

From: "Meredith L(dot) Patterson" <mlp(at)osogato(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: install-strip causes dyld errors on OS X
Date: 2007-10-30 02:02:09
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Hi all,

Three years ago, Andrew MacRae logged the following bug:

In brief, when installing on OS X with "make install-strip",
installation goes fine, but initdb dies here:

creating conversions... ERROR: could not load library
"/usr/local/pgsql/lib/": dyld:
Undefined symbols:
/usr/local/pgsql/lib/ undefined reference to
_pg_ascii2mic expected to be defined in the executable

I encountered this problem today with OS X 10.4 and CVS HEAD, and came
up with a few possible solutions. The problem has to do with the
difference between shared libraries and dynamic libraries, and how strip
behaves with them on OS X.

Here's how it works: When called on an executable which uses dyld, strip
silently passes itself the -u (save all undefined symbols) and -r (save
all dynamically-referenced symbols) options. However, the
internationalization libraries (and a few others, like libplperl and
libplpython) are compiled as shared libraries (.so as opposed to
.dylib), so strip doesn't know that those libraries contain undefined
symbols and are expecting to acquire them from the executable.

I see three possible fixes:

1) Patch config/install-sh such that on OS X, install-strip calls 'strip
-x'. This removes local symbols only.
2) Determine which symbols are global and undefined in the shared
libraries that are built, make a list of them, and call 'strip -u -r -s
symbols_to_keep'. This saves undefined symbols, dynamically referenced
symbols, and symbols that the shared libraries need.
3) Change the OS X build such that the i18n libs and other shared libs
are instead built as dylibs.

I've tested (1) as far as getting through initdb, starting the
postmaster and a few quick things with psql. It would be about a
four-line patch to install-sh (check for the OS, set stripcmd
appropriately). It might not leave the resulting binary *as* small as it
could be, but it certainly works.

(2) sounds like a giant pain in the ass. It's scriptable and could be
added to the build, but the build takes pretty long as it is and I can't
imagine anyone wants to make it longer. Unless there's a good reason,
I'm pre-emptively -1'ing this one.

I haven't done any looking into (3) yet. Why *are* the i18n libs built
as shared on OS X, anyway?

Meredith L. Patterson
Founder and CTO
Osogato, Inc.


Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2007-10-30 02:34:48 pgsql: simple script to pull together a very small (<500k) tar file
Previous Message David Fetter 2007-10-29 23:42:54 Re: Proposal: real procedures again (8.4)

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-10-30 04:59:23 Re: install-strip causes dyld errors on OS X
Previous Message Tom Lane 2007-10-29 21:07:32 Re: pg_ctl configurable timeout