Re: Build universal binary on Mac OS X 10.6?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Israel Brewster <israel(at)frontierflying(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Build universal binary on Mac OS X 10.6?
Date: 2009-12-03 19:54:23
Message-ID: 13212.1259870063@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Israel Brewster <israel(at)frontierflying(dot)com> writes:
> 1) From the second paragraph of that post:
>> If you add something like "-arch i386 -arch ppc" to CFLAGS and build
>> normally, you get real working multiarch binaries and libraries.
> Which is exactly the problem that started this whole thread - on 10.6,
> you DON'T (or at least I don't) get "real working multiarch binaries
> and libraries". In fact, you don't get anything - the compile fails.
> Already we see that this post does not address my issue in any form,

The reason it's failing is that you continue to ignore the important
point: you need arch-specific header files.

I tried this on current sources and found that the failure occurs in
code like this:

#if SIZEOF_DATUM == 8
...
switch (attlen) \
{ \
case sizeof(char): \
...
case sizeof(int16): \
...
case sizeof(int32): \
...
case sizeof(Datum): \
...
...
#else /* SIZEOF_DATUM != 8 */

Since I configured on a 64-bit Mac, the generated header file
sets SIZEOF_DATUM to 8. When this code is fed to the 32-bit
compiler, it thinks sizeof(Datum) is 4, so it spits up on the
duplicated case values. Had it been fed the correct header file for
a 32-bit machine, it would have gone to the other part of the #if
(which doesn't have the intended-to-be-for-8-bytes case branch).

I don't really recall whether I hit this in the experiment I did
last year. It's possible, maybe even likely, that the code was
different then and happened not to have any compiler-visible
inconsistencies when the header was wrong for the target arch.
That doesn't change the fact that it'd fail at runtime whether
the compiler could detect a problem or not.

There's really no way around building the correct header files
if you want a usable multiarch library.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bret 2009-12-03 19:54:52 Re: code example for PQgetCopyData
Previous Message Dave Huber 2009-12-03 19:35:07 Re: code example for PQgetCopyData