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

From Israel Brewster
Subject Re: Build universal binary on Mac OS X 10.6?
Date
Msg-id CD7931DD-22EF-4981-AD1A-CE6D8918C8A0@frontierflying.com
Whole thread Raw
In response to Re: Build universal binary on Mac OS X 10.6?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Build universal binary on Mac OS X 10.6?
List pgsql-general
On Dec 2, 2009, at 5:16 PM, Tom Lane wrote:

> Israel Brewster <israel@frontierflying.com> writes:
>> Well, I'm not trying to use the server or client programs from this
>> build - I just want the universal libraries for my programs. My point
>> in this last section, however, doesn't necessarily extend as far as
>> actual function, but rather is just with the build. MySQL and SQLite
>> build for multiple architectures quite happily, Postgres doesn't
>> build
>> at all except for single architectures (the way I am trying at
>> least).
>
> Well, it's been done.

On 10.5. By myself among others. Thus the reason I think there is
something wrong about the way I am going about this, and thus my
question to this list. If I didn't think it was possible, I wouldn't
bother asking how to do it :-)

> Searching the PG archives for prior discussions
> I find
> http://archives.postgresql.org/pgsql-hackers/2008-07/msg00884.php
> which describes success with multiple -arch flags in CFLAGS plus
> hand creation of relevant .h files.

Thanks for the link. It explains why I wasn't finding anything in my
searches - I was searching for "OS X", while the post references
"Darwin". I'll keep that distinction in mind in the future - may help
me solve my problems on my own, without needing outside help :-) That
said, the post hilights a few  points:

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,
as it references a successful compile resulting in unusable binaries-
not a failed compile, which is what I am dealing with.

The post goes on to say that "if you only do that, only the arch you
build on will work", but as I have already pointed out, I don't care -
I just need the libraries. My app already runs fine on multiple
platforms, I just need the multi-arch libraries to link against. From
a Mac OS X 10.6 build machine - I already have it working just fine on
a 10.5 build machine (with no header hacking), albeit with Postgres 8.2.

2) The post explains quite elegantly my point about Postgres being
more difficult to create a universal binary with than other programs.
I have compiled Qt, MySQL, SQLite, and several of my own programs for
all four architectures, and never once needed to hack around with
header files to get it to work. See, for example, this: <
http://www.malisphoto.com/tips/mysql-on-os-x.html#Anchor-Build 
  >. A Single configure command, with the right arguments, creates a 4-
way universal binary of MySQL on Mac OS X.

That said, this really isn't an issue for me - I mean, it's not like
I'm rebuilding Postgres every day or anything, so If I need to hack
around with headers or whatever to get the build to work, that's fine.
However, see point 1 - apparently the headers aren't the issue,
because according to the posts you linked, incorrect headers result in
non-functioning binaries, NOT in a failed build (it explicitly said
the build itself worked).

> [snip] On the whole
> I'd still recommend building the reference .h files on the actual
> target
> arch rather than trusting cross-compile to create them correctly.

If I was simply trying to build the Postgres server and/or client to
run on my machines, I would agree. However, as that is not what I am
doing (I'm not using the client or server portions of the build at
all) this is simply not an option, for two reasons. First, it would
require that I have four different machines to build on: ppc 32 and 64
bit, and Intel 32 and 64 bit. I could probably get away with two (ppc
and intel 32 bit) but regardless it would still require multiple build
machines, and that will never happen.

Secondly, even if I had the machines, it wouldn't help me achieve what
I need - a single, universal binary build of my application that can
run on as many Mac OS X machines as possible. There is no way I am
going to be distributing different binaries of my application for
different machine architectures. That might be fine for your average
Linux/Unix user, perhaps even for your average PosgreSQL database
admin- but not for the general public  to whom my app is targeted.
Most of my target audience is going to go "machine type? I dunno...
it's a mac". So I need to distribute an application that will run on a
"mac" regardless of what chip is inside. For that, I need a single,
universal, build of the Postgres libraries. Doing multiple builds on
multiple machines is, quite simply, not an option.

I thank you for the time you have taken trying to explain this to me,
and I apologize if I am being dense or stubborn. I'm not trying to be
difficult, it just feels to me that your posts don't address my issue,
that of a failed compile on 10.6. Rather, it feels like you are stuck
on the fact that the generated binaries won't work on other platforms,
which as I stated I don't care about. Again, I apologize if I am
missing your point or being a nusance - I don't want to be difficult,
I just want to get this working. Thanks for your time and patience.

>             regards, tom lane

-----------------------------------------------
Israel Brewster
Computer Support Technician II
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------




Attachment

pgsql-general by date:

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