Skip site navigation (1) Skip section navigation (2)

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
Message-ID: 472690A1.7060100@osogato.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Hi all,

Three years ago, Andrew MacRae logged the following bug:

http://archives.postgresql.org/pgsql-bugs/2004-02/msg00042.php

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/ascii_and_mic.so": dyld: 
/usr/local/pgsql/bin/postgres
Undefined symbols:
         /usr/local/pgsql/lib/ascii_and_mic.so 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?

Cheers,
--mlp
_____________________
Meredith L. Patterson
Founder and CTO
Osogato, Inc.

Responses

pgsql-hackers by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group