Opened 9 years ago

Closed 8 years ago

#5135 closed bug (wontfix)

compilation failure on OS X 10.4 due to _POSIX_C_SOURCE

Reported by: guest Owned by: igloo
Priority: high Milestone: 7.4.1
Component: Compiler Version: 6.12.3
Keywords: Cc: grobian@…
Operating System: MacOS X Architecture: powerpc
Type of failure: Building GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

In rts/PosixSource.h various standards and extensions are enabled. This yields in sys/types.h on Darwin *not* defining u_* typedefs. The code however relies on this. This problem has been noted already, and hence a hack to define _DARWIN_C_SOURCE has been added which works on Darwin 9 and up.

On Darwin 8, however, this define doesn't exist in sys/types.h. Without wanting to change the u_*, I resorted to the rather hackish fix as attached, such that sys/types.h is included on Darwin before various standards are set, and hence the u_* types will disappear.

Attachments (1)

ghc-6.12.3-darwin8.patch (483 bytes) - added by guest 9 years ago.
patch to allow compilation on Darwin 8

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by guest

Attachment: ghc-6.12.3-darwin8.patch added

patch to allow compilation on Darwin 8

comment:1 Changed 9 years ago by igloo

Darwin 8 = OS X 10.4

Darwin 9 = OS X 10.5

Darwin 10 = OS X 10.6

comment:2 Changed 9 years ago by igloo

Milestone: 7.4.1
Priority: normalhigh
Status: newpatch

comment:3 Changed 8 years ago by igloo

Owner: set to igloo

In 10.7, in /usr/include/sys/types.h, we have:

#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
typedef unsigned char       u_char;
typedef unsigned short      u_short;
typedef unsigned int        u_int;
[...]

so presumably 10.4 has instead:

#if !defined(_POSIX_C_SOURCE)
typedef unsigned char       u_char;
typedef unsigned short      u_short;
typedef unsigned int        u_int;
[...]

The uses of u_* types are in other system headers, so we can't change the places they're used.

The patch validates on x86 32bit OS X 10.7.

It feels very hacky, but I don't really have a better suggestion (short of declaring 10.4 to be not supported).

comment:4 Changed 8 years ago by guest

10.4 has:

#ifndef _POSIX_C_SOURCE
typedef unsigned char       u_char;
typedef unsigned short      u_short;
typedef unsigned int        u_int;

while on 10.3:

#ifndef _POSIX_SOURCE
typedef unsigned char   u_char;
typedef unsigned short  u_short;
typedef unsigned int    u_int;
typedef unsigned long   u_long;
typedef unsigned short  ushort;     /* Sys V compatibility */
typedef unsigned int    uint;       /* Sys V compatibility */
#endif

(I just checked the headers, never tried to compile here.)

On the other hand, my Tiger box has died on me, so I'm stuck with G5/10.5, x86/10.6 and x64/10.7 now. I can imagine when you would want to close this bug.

comment:5 Changed 8 years ago by igloo

Resolution: wontfix
Status: patchclosed
Summary: compilation failure on Darwin 8 due to _POSIX_C_SOURCEcompilation failure on OS X 10.4 due to _POSIX_C_SOURCE

OK, if this bug is no longer a problem for you, and no-one else has reported the same problem, then let's just close it as wontfix rather than carrying around the hack forever. After all, 10.5 was released in 2007, and OS X users tend to be fast to upgrade.

Note: See TracTickets for help on using tickets.