Re: Build universal binary on Mac OS X 10.6? - Mailing list pgsql-general

From Tom Lane
Subject Re: Build universal binary on Mac OS X 10.6?
Date
Msg-id 13212.1259870063@sss.pgh.pa.us
Whole thread Raw
In response to Re: Build universal binary on Mac OS X 10.6?  (Israel Brewster <israel@frontierflying.com>)
Responses Re: Build universal binary on Mac OS X 10.6?  (Israel Brewster <israel@frontierflying.com>)
List pgsql-general
Israel Brewster <israel@frontierflying.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

pgsql-general by date:

Previous
From: Dave Huber
Date:
Subject: Re: code example for PQgetCopyData
Next
From: "Bret"
Date:
Subject: Re: code example for PQgetCopyData