Postgres will not compile on Mac 10.8 with contrib/uuid-ossp

Lists: pgsql-general
From: Steven Schlansker <steven(at)likeness(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Postgres will not compile on Mac 10.8 with contrib/uuid-ossp
Date: 2012-07-31 01:07:15
Message-ID: 05843630-E25D-442A-A6B0-5CA63622A400@likeness.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

It is not possible to compile Postgres contrib/uuid-ossp on the newest release of Mac OS X, 10.8

The specific compile error:

make -C uuid-ossp install

/bin/sh ../../config/install-sh -c -d '/usr/local/Cellar/postgresql/9.1.3/lib'
/usr/bin/clang -Os -w -pipe -march=native -Qunused-arguments -I/usr/local/Cellar/ossp-uuid/1.6.2/include -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -I. -I. -I../../src/include -I/usr/local/Cellar/readline/6.2.2/include -I/usr/include/libxml2 -I/usr/include/libxml2 -c -o uuid-ossp.o uuid-ossp.c

In file included from uuid-ossp.c:27:
In file included from /usr/local/Cellar/ossp-uuid/1.6.2/include/uuid.h:38:
/usr/include/unistd.h:689:26: error: expected identifier
int gethostuuid(uuid_t, const struct timespec *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
^
In file included from uuid-ossp.c:27:
/usr/local/Cellar/ossp-uuid/1.6.2/include/uuid.h:94:24: error: typedef redefinition with different types ('struct uuid_st' vs '__darwin_uuid_t' (aka 'unsigned char [16]'))
typedef struct uuid_st uuid_t;
^
/usr/include/uuid/uuid.h:42:25: note: previous definition is here
typedef __darwin_uuid_t uuid_t;
^
In file included from uuid-ossp.c:27:
/usr/local/Cellar/ossp-uuid/1.6.2/include/uuid.h:107:22: error: conflicting types for 'uuid_compare'
extern uuid_rc_t uuid_compare (const uuid_t *_uuid, const uuid_t *_uuid2, int *_result);
^
/usr/include/uuid/uuid.h:59:5: note: previous declaration is here
int uuid_compare(const uuid_t uu1, const uuid_t uu2);
^
3 errors generated.
make[2]: *** [uuid-ossp.o] Error 1
make[1]: *** [install-uuid-ossp-recurse] Error 2
make[1]: *** Waiting for unfinished jobs….

Full log available here (not mine, but I have the exact same problem):
https://gist.github.com/2287209

There is a workaround (disable uuid-ossp) but obviously this does not help those of us who require UUID support.

There are a number of bugs open:
https://github.com/mxcl/homebrew/issues/13639
https://trac.macports.org/ticket/35153

and a proposed fix which does fix the problem for me:

> This is caused by the inclusion of the system uuid.h in pwd.h. Just add the line :
>
> #define _XOPEN_SOURCE
>
> at the first line of uuid-ossp.c, and it should compile fine.

I am not sure what the "correct" fix is, but adding the above definition does fix the issue.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steven Schlansker <steven(at)likeness(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgres will not compile on Mac 10.8 with contrib/uuid-ossp
Date: 2012-07-31 02:35:13
Message-ID: 11991.1343702113@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Steven Schlansker <steven(at)likeness(dot)com> writes:
> It is not possible to compile Postgres contrib/uuid-ossp on the newest release of Mac OS X, 10.8

This looks like some variant of the same issue that OSSP's uuid
package has had on Macs all along, to wit an unreliable method for
avoiding conflicts with any OS-supplied uuid type. Back when we
last looked at this,
http://archives.postgresql.org/pgsql-hackers/2007-11/msg00551.php
we concluded that what we had to do was not include <unistd.h>
ahead of uuid.h, and as far as I can tell we're still not doing that;
for me, contrib/uuid-ossp still builds fine on Lion with uuid 1.6.2.

So assuming you're using a stock copy of 1.6.2, that leaves <unistd.h>
as the only variable in the equation that could have changed. It's
not obvious from here exactly how it changed, but in any case this
fight is ultimately between OSSP uuid and OS X; there's not a lot
Postgres can (or should) do to fix it. It's a bit distressing that
OSSP doesn't seem to have made any new uuid releases since 2008,
but maybe if you prod them they'll do something about this.

regards, tom lane


From: Steven Schlansker <steven(at)likeness(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgres will not compile on Mac 10.8 with contrib/uuid-ossp
Date: 2012-07-31 03:04:36
Message-ID: DF83DC97-A71F-48A0-B625-60D88A7BA3B5@likeness.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


On Jul 30, 2012, at 7:35 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Steven Schlansker <steven(at)likeness(dot)com> writes:
>> It is not possible to compile Postgres contrib/uuid-ossp on the newest release of Mac OS X, 10.8
>
> This looks like some variant of the same issue that OSSP's uuid
> package has had on Macs all along, to wit an unreliable method for
> avoiding conflicts with any OS-supplied uuid type. Back when we
> last looked at this,
> http://archives.postgresql.org/pgsql-hackers/2007-11/msg00551.php
> we concluded that what we had to do was not include <unistd.h>
> ahead of uuid.h, and as far as I can tell we're still not doing that;
> for me, contrib/uuid-ossp still builds fine on Lion with uuid 1.6.2.

Looks right to me.

>
> So assuming you're using a stock copy of 1.6.2,

(I am)

> that leaves <unistd.h>
> as the only variable in the equation that could have changed. It's
> not obvious from here exactly how it changed, but in any case this
> fight is ultimately between OSSP uuid and OS X; there's not a lot
> Postgres can (or should) do to fix it. It's a bit distressing that
> OSSP doesn't seem to have made any new uuid releases since 2008,
> but maybe if you prod them they'll do something about this.
>
> regards, tom lane

I've sent a message upstream. It seems that both their bug tracker and forum are either
nonexistent or so broken that they seem so. So I will work on the assumption that this bug
won't get fixed upstream…

Would it be reasonable to include the _XOPEN_SOURCE define in the contrib module?
It at least fixes this issue and hopefully wouldn't cause any ill effects.

There's a patch at https://github.com/stevenschlansker/homebrew/commit/d86e17cbcc5d287d7a393a6754aa8f94b995c5ea

It's not terribly extensively tested but it does compile and I would be very surprised if it caused problems.