macports and brew postgresql --universal builds

Lists: pgsql-hackers
From: Doug Coleman <doug(dot)coleman(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: macports and brew postgresql --universal builds
Date: 2012-08-10 17:14:05
Message-ID: CAEb+CXUb+cz-m_WRCOFJKF-Xq12y+e1zgxtbNTbdgXBnuRO4AQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The MacPorts Project (http://www.macports.org/) supports building
universal binaries (32/64bit binaries in one file) for most projects.
For PostgreSQL, they apply two patches after the configure script to
correct some of the typedefs. Otherwise, the build fails in compiling
a switch statement with duplicate cases.

The HomeBrew Project (http://mxcl.github.com/homebrew/) is a worthy
successor to MacPorts, but they don't yet support a --universal
argument for building PostgreSQL. There is currently a pull request on
github to add universal support, but it's based on the patches from
the MacPorts project.

It would be nice if the PostgreSQL project would make these patches unnecessary.

A diff of the HomeBrew pull request to add universal support:
https://github.com/mxcl/homebrew/pull/14111/files

The patches in question:
https://trac.macports.org/export/96361/trunk/dports/databases/postgresql91/files/pg_config.h.ed
https://trac.macports.org/export/96361/trunk/dports/databases/postgresql91/files/ecpg_config.h.ed

If someone were to fix this, to test if the fix worked you would need
a Mac with HomeBrew, the HomeBrew pull request above but without lines
70-74, and this command:

brew install postgresql --universal

Note that if you previously had postgresql installed with HomeBrew,
you would need to uninstall it first.

Cheers,
Doug


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Doug Coleman <doug(dot)coleman(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: macports and brew postgresql --universal builds
Date: 2012-08-10 22:44:39
Message-ID: 27044.1344638679@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Doug Coleman <doug(dot)coleman(at)gmail(dot)com> writes:
> The MacPorts Project (http://www.macports.org/) supports building
> universal binaries (32/64bit binaries in one file) for most projects.
> For PostgreSQL, they apply two patches after the configure script to
> correct some of the typedefs. Otherwise, the build fails in compiling
> a switch statement with duplicate cases.

> The HomeBrew Project (http://mxcl.github.com/homebrew/) is a worthy
> successor to MacPorts, but they don't yet support a --universal
> argument for building PostgreSQL. There is currently a pull request on
> github to add universal support, but it's based on the patches from
> the MacPorts project.

The files you link to don't make much sense to me (they do not look
like patch diffs) but they seem to suggest hard-wiring configure results
into the source code, which does not sound like an acceptable solution
from our standpoint.

The approach we've suggested to people in the past is running configure
for each architecture and then building against that copy of
pg_config.h, or more likely combining the .h files with arch-specific
#ifdefs. You can find more info in our list archives --- the most
relevant thread I could find easily starts here:
http://archives.postgresql.org/pgsql-hackers/2008-07/msg00884.php

regards, tom lane


From: Daniel Farina <daniel(at)heroku(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Doug Coleman <doug(dot)coleman(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: macports and brew postgresql --universal builds
Date: 2012-08-10 22:58:31
Message-ID: CAAZKuFacruDHWA-dGcqBoeXY+gDAwRAeO2neuhaQWtKHaSeuNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Aug 10, 2012 at 3:44 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> The files you link to don't make much sense to me (they do not look
> like patch diffs) but they seem to suggest hard-wiring configure results
> into the source code, which does not sound like an acceptable solution
> from our standpoint.

I've also never seen this format before, which are...ed expressions.
I guess that makes them less sensitive to line churn. Cute, but...wow.

--
fdr


From: Doug Coleman <doug(dot)coleman(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: macports and brew postgresql --universal builds
Date: 2012-08-10 23:12:08
Message-ID: CAEb+CXV-0ZEEd5gUcY59uAYZXtF6HL3VRTU3irgNJHJzp7RXbg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

What it looks like is the first line of each section is pattern matching.

If __LP64__ is defined, then it's a 64-bit architecture, and we want
to use the top part of the if statement. The #defines they target seem
to be all of the ones that are different on 32bit platforms.

I agree that you would want to do this in the configure script somehow.

Doug

On Fri, Aug 10, 2012 at 3:44 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Doug Coleman <doug(dot)coleman(at)gmail(dot)com> writes:
>> The MacPorts Project (http://www.macports.org/) supports building
>> universal binaries (32/64bit binaries in one file) for most projects.
>> For PostgreSQL, they apply two patches after the configure script to
>> correct some of the typedefs. Otherwise, the build fails in compiling
>> a switch statement with duplicate cases.
>
>> The HomeBrew Project (http://mxcl.github.com/homebrew/) is a worthy
>> successor to MacPorts, but they don't yet support a --universal
>> argument for building PostgreSQL. There is currently a pull request on
>> github to add universal support, but it's based on the patches from
>> the MacPorts project.
>
> The files you link to don't make much sense to me (they do not look
> like patch diffs) but they seem to suggest hard-wiring configure results
> into the source code, which does not sound like an acceptable solution
> from our standpoint.
>
> The approach we've suggested to people in the past is running configure
> for each architecture and then building against that copy of
> pg_config.h, or more likely combining the .h files with arch-specific
> #ifdefs. You can find more info in our list archives --- the most
> relevant thread I could find easily starts here:
> http://archives.postgresql.org/pgsql-hackers/2008-07/msg00884.php
>
> regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Doug Coleman <doug(dot)coleman(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: macports and brew postgresql --universal builds
Date: 2012-08-11 02:04:26
Message-ID: 5025BDAA.7020004@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 08/10/2012 06:44 PM, Tom Lane wrote:
> Doug Coleman <doug(dot)coleman(at)gmail(dot)com> writes:
>> The MacPorts Project (http://www.macports.org/) supports building
>> universal binaries (32/64bit binaries in one file) for most projects.
>> For PostgreSQL, they apply two patches after the configure script to
>> correct some of the typedefs. Otherwise, the build fails in compiling
>> a switch statement with duplicate cases.
>> The HomeBrew Project (http://mxcl.github.com/homebrew/) is a worthy
>> successor to MacPorts, but they don't yet support a --universal
>> argument for building PostgreSQL. There is currently a pull request on
>> github to add universal support, but it's based on the patches from
>> the MacPorts project.
> The files you link to don't make much sense to me (they do not look
> like patch diffs)

OMG, I think they are ed scripts, possibly produced using "diff -e". I'm
having flashbacks to when I used such stuff twenty or so years ago.

cheers

andrew


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Doug Coleman <doug(dot)coleman(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: macports and brew postgresql --universal builds
Date: 2012-08-14 21:55:55
Message-ID: 502AC96B.9000505@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 8/10/12 7:12 PM, Doug Coleman wrote:
> What it looks like is the first line of each section is pattern matching.
>
> If __LP64__ is defined, then it's a 64-bit architecture, and we want
> to use the top part of the if statement. The #defines they target seem
> to be all of the ones that are different on 32bit platforms.
>
> I agree that you would want to do this in the configure script somehow.

That's not going to work. The configure script can only test one target
at a time. You can probably get away with it on many simple programs,
but when a configure script checks size and alignment of types, the
whole concept of universal builds is at odds with the approach Autoconf
takes. OK, so you get away with it by patching up a few sites, but
you're effectively overriding the configure checks with hardcoded results.

I think the only sane approach in general is to build the entire project
twice and merge the resulting binaries together.