powerpc/181502: /usr/include/stdint.h 9.2-RC1/powerpc does not compile on powerpc32

Keve Nagy keve at safe-mail.net
Sat Aug 24 13:20:02 UTC 2013


>Number:         181502
>Category:       powerpc
>Synopsis:       /usr/include/stdint.h 9.2-RC1/powerpc does not compile on powerpc32
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ppc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 24 13:20:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Keve Nagy
>Release:        FreeBSD 9.2-RC1/powerpc
>Organization:
N/A
>Environment:
FreeBSD g4mini.homeoffice.internal 9.2-RC1 FreeBSD 9.2-RC1 #0 r253912: Sat Aug  3 18:51:06 UTC 2013     root at snap.freebsd.org:/usr/obj/powerpc.powerpc/usr/src/sys/GENERIC  powerpc
>Description:
I thought you might want to know that icu-50.1.2 does not build on FreeBSD-9.2-RC1/powerpc.
I believe this is a PowerPC ONLY issue, as the same code appears to build fine on i386 and amd64.
I attempted to build x11/gnome2-lite from the ports, which failed building icu as a dependency.

I tracked the origin of the problem back to /usr/include/stdint.h, line 68.
#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX)

For reference, that line sits at the top of the block:
/* GNU and Darwin define this and people seem to think it's portable */
#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX)
#define __WORDSIZE              64
#else
#define __WORDSIZE              32
#endif

Compilation of icu stops with the error:
/usr/include/stdint.h:68:68 error: missing binary operator before token "("

The particular source the compiler complains about looks perfectly correct. This is not a typo issue.
I did some very basic testing to identify what is wrong.
It looks that referring to the value of UINT64_MAX is what makes the compiler choke.
At the time of compilation, both UINTPTR_MAX and UINT64_MAX appears to be in the "defined" state.

A line of:
#if defined(UINT64_MAX)
or a line of:
#ifndef UINT64_MAX
does not trigger an error.
Neither does reassigning the value of UINT64_MAX to another variable/macro, like:
#define __KEVE  UINT64_MAX

However, testing against the value of UINT64_MAX
#if (UINT64_MAX == 1)
 raises the above mentioned error.
So does
#if (UINT64_MAX != 2)
and after assigning the value of UINT64_MAX to __KEVE as I showed above, testing against the value of __KEVE
#if (__KEVE == 123)
  or
#if (__KEVE != 6)
also raises the same error.

I believe that on i386 and amd64 the code compiles fine because that block of code is ignored, probably due to the fact of UINT64_MAX or UINTPTR_MAX not being defined, hence the evaluation stops before getting to the (UINTPTR_MAX == UINT64_MAX) portion at the end of the line.

This is how deep my capabilities allowed me to go. Someone smarter needs to take this over to identify the real origin of the error and fix it.
Until then, the workaround I used is to comment-out the troublesome block and simply define __WORDSIZE. In my particular case, as I was building on powerpc32 on a G4 Mac mini, I just added this line:
#define __WORDSIZE              32


***WORKAROUND***

/usr/include/stdint.h, lines 67-72 as comes with FreeBSD-9.2-RC2/powerpc:

/* GNU and Darwin define this and people seem to think it's portable */
#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX)
#define __WORDSIZE              64
#else
#define __WORDSIZE              32
#endif


/usr/include/stdint.h, lines 67-75 after workaround applied:

/* GNU and Darwin define this and people seem to think it's portable */
/*** commented out as it does not build on powerpc G4 Mac mini ***
#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX)
#define __WORDSIZE              64
#else
#define __WORDSIZE              32
#endif
***/
#define __WORDSIZE              32

*** For reference ***
I was attempting to build x11/gnome2-lite on a G4 Mac mini with 512MB memory.
>How-To-Repeat:
Get a G4 Mac mini, iMac, iBook or PowerBook machine and try to build devel/icu from ports.
cd /usr/ports/devel/icu
make

Should apply to everything else that tries to include /usr/include/stdint.h, but devel/icu is the only thing I came accross.
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-ppc mailing list