Bug 53348 - Conflicting fast-integer types on AIX: <sys/inttypes.h> vs. gcc/config/rs6000/aix-stdint.h
Summary: Conflicting fast-integer types on AIX: <sys/inttypes.h> vs. gcc/config/rs6000...
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 47902 47907 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-05-14 17:14 UTC by Daniel Richard G.
Modified: 2018-11-19 13:39 UTC (History)
1 user (show)

See Also:
Host: powerpc-ibm-aix4.3.2.0
Target: powerpc-ibm-aix4.3.2.0
Build: powerpc-ibm-aix4.3.2.0
Known to work:
Known to fail:
Last reconfirmed: 2012-05-15 00:00:00


Attachments
Patch against GCC SVN trunk (2.26 KB, patch)
2012-07-17 23:24 UTC, Daniel Richard G.
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Richard G. 2012-05-14 17:14:42 UTC
Bootstrapping 4.7.0 on AIX 4.3 fails with

[...]
Making all in include
gmake[5]: Entering directory `/tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include'
mkdir -p ./powerpc-ibm-aix4.3.2.0/bits/stdc++.h.gch
/tmp/gcc-build/./gcc/xgcc -shared-libgcc -B/tmp/gcc-build/./gcc -nostdinc++ -L/tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/src -L/tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/src/.libs -B/opt/tg/powerpc-ibm-aix4.3.2.0/bin/ -B/opt/tg/powerpc-ibm-aix4.3.2.0/lib/ -isystem /opt/tg/powerpc-ibm-aix4.3.2.0/include -isystem /opt/tg/powerpc-ibm-aix4.3.2.0/sys-include    -x c++-header -nostdinc++ -g  -I/tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/powerpc-ibm-aix4.3.2.0 -I/tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include -I/home/src/gcc-4.7.0/libstdc++-v3/libsupc++ -O2 -g -std=gnu++0x /home/src/gcc-4.7.0/libstdc++-v3/include/precompiled/stdc++.h \
-o powerpc-ibm-aix4.3.2.0/bits/stdc++.h.gch/O2ggnu++0x.gch
In file included from /tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/bits/atomic_base.h:37:0,
                 from /tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/atomic:41,
                 from /home/src/gcc-4.7.0/libstdc++-v3/include/precompiled/stdc++.h:100:
/tmp/gcc-build/./gcc/include/stdint.h:72:29: error: conflicting declaration 'typedef short int int_fast16_t'
In file included from /tmp/gcc-build/./gcc/include-fixed/sys/types.h:64:0,
                 from /usr/include/sys/lc_core.h:36,
                 from /usr/include/sys/localedef.h:43,
                 from /tmp/gcc-build/./gcc/include-fixed/ctype.h:131,
                 from /tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/cctype:44,
                 from /home/src/gcc-4.7.0/libstdc++-v3/include/precompiled/stdc++.h:36:
/usr/include/sys/inttypes.h:143:18: error: 'int_fast16_t' has a previous declaration as 'typedef int32_t int_fast16_t'
In file included from /tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/bits/atomic_base.h:37:0,
                 from /tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/atomic:41,
                 from /home/src/gcc-4.7.0/libstdc++-v3/include/precompiled/stdc++.h:100:
/tmp/gcc-build/./gcc/include/stdint.h:75:29: error: conflicting declaration 'typedef unsigned char uint_fast8_t'
In file included from /tmp/gcc-build/./gcc/include-fixed/sys/types.h:64:0,
                 from /usr/include/sys/lc_core.h:36,
                 from /usr/include/sys/localedef.h:43,
                 from /tmp/gcc-build/./gcc/include-fixed/ctype.h:131,
                 from /tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/cctype:44,
                 from /home/src/gcc-4.7.0/libstdc++-v3/include/precompiled/stdc++.h:36:
/usr/include/sys/inttypes.h:145:18: error: 'uint_fast8_t' has a previous declaration as 'typedef uint32_t uint_fast8_t'
In file included from /tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/bits/atomic_base.h:37:0,
                 from /tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/atomic:41,
                 from /home/src/gcc-4.7.0/libstdc++-v3/include/precompiled/stdc++.h:100:
/tmp/gcc-build/./gcc/include/stdint.h:76:30: error: conflicting declaration 'typedef short unsigned int uint_fast16_t'
In file included from /tmp/gcc-build/./gcc/include-fixed/sys/types.h:64:0,
                 from /usr/include/sys/lc_core.h:36,
                 from /usr/include/sys/localedef.h:43,
                 from /tmp/gcc-build/./gcc/include-fixed/ctype.h:131,
                 from /tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include/cctype:44,
                 from /home/src/gcc-4.7.0/libstdc++-v3/include/precompiled/stdc++.h:36:
/usr/include/sys/inttypes.h:146:18: error: 'uint_fast16_t' has a previous declaration as 'typedef uint32_t uint_fast16_t'
gmake[5]: *** [powerpc-ibm-aix4.3.2.0/bits/stdc++.h.gch/O2ggnu++0x.gch] Error 1
gmake[5]: Leaving directory `/tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3/include'
gmake[4]: *** [all-recursive] Error 1
gmake[4]: Leaving directory `/tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3'
gmake[3]: *** [all] Error 2
gmake[3]: Leaving directory `/tmp/gcc-build/powerpc-ibm-aix4.3.2.0/libstdc++-v3'
gmake[2]: *** [all-stage1-target-libstdc++-v3] Error 2
gmake[2]: Leaving directory `/tmp/gcc-build'
gmake[1]: *** [stage1-bubble] Error 2
gmake[1]: Leaving directory `/tmp/gcc-build'
gmake: *** [bootstrap-lean] Error 2


The system defines the three types in question as follows:

$ pcregrep '\b(uint_fast8_t|u?int_fast16_t)\b' /usr/include/sys/inttypes.h 
typedef int32_t         int_fast16_t;
typedef uint32_t        uint_fast8_t;
typedef uint32_t        uint_fast16_t;


These definitions conflict with GCC's idea of the AIX definitions:

$ pcregrep -i '\b(uint_fast8_t|u?int_fast16_t)' /home/src/gcc-4.7.0/gcc/config/rs6000/aix-stdint.h
#define INT_FAST16_TYPE "short int"
#define UINT_FAST8_TYPE "unsigned char"
#define UINT_FAST16_TYPE "short unsigned int"


Adding the following blurb to the top of $(builddir)/gcc/include/stdint.h allows the build to proceed:

    #undef __INT_FAST16_TYPE__
    #undef __UINT_FAST8_TYPE__ 
    #undef __UINT_FAST16_TYPE__         

    #define __INT_FAST16_TYPE__  int32_t           
    #define __UINT_FAST8_TYPE__  uint32_t        
    #define __UINT_FAST16_TYPE__ uint32_t


The real fix, however, is probably to adjust aix-stdint.h so that its definitions agree with the system's.
Comment 1 Daniel Richard G. 2012-05-14 22:51:36 UTC
*** Bug 47907 has been marked as a duplicate of this bug. ***
Comment 2 Daniel Richard G. 2012-05-14 22:54:02 UTC
*** Bug 47902 has been marked as a duplicate of this bug. ***
Comment 3 David Edelsohn 2012-05-15 13:45:38 UTC
AIX 4.3.2 was announced in 1998 and end of service in 2003. The AIX header is wrong and was fixed in later versions. You have a work-around. I am not aware of anyone else trying to use recent versions of GCC on ancient versions of AIX. Customers who continue to use an old version generally freeze all software on the system. Patches are welcome.
Comment 4 Daniel Richard G. 2012-05-15 17:35:20 UTC
(In reply to comment #3)
> AIX 4.3.2 was announced in 1998 and end of service in 2003. The AIX header is
> wrong and was fixed in later versions. You have a work-around. I am not aware
> of anyone else trying to use recent versions of GCC on ancient versions of AIX.
> Customers who continue to use an old version generally freeze all software on
> the system. Patches are welcome.

So if I understand correctly: GCC may still nominally support AIX 4.3, but no one here really wants to spend time dealing with it.

If that's the case, could you set these PRs to WAITING/IN_PROGRESS, and assign them to me? I'll gladly try my hand at some patches, as long as someone here is willing to review them and get them in if they're good.

I was under the impression that fast-integer types could be N bits or more in size, so e.g. "typedef int32_t int_fast16_t" would be valid (and may make sense for the architecture). So you're saying that's not it, and sys/inttypes.h needs fixincluding?
Comment 5 David Edelsohn 2012-05-15 17:53:00 UTC
I am willing to review patches, although I do not have access to AIX 4.3 systems to test.

More recent versions of AIX define inttypes that correspond to the current definition in GCC. The 4.3.2 definitions are not invalid, but probably are not the best choices or consistent with current definitions.

Changing AIX headers with fixincludes may introduce inconsistencies. This could be fixed in aix-stdint.h, but I am concerned about complicating that file to support current GCC on a 15 year old system that few people are interested in. This isn't zero cost for future maintenance. You can change aix-stdint.h yourself and continue to apply the patches if you care about building GCC 4.8 and later.
Comment 6 Daniel Richard G. 2012-05-15 19:01:45 UTC
My first thought had been to put in AIX-version-dependent cpp conditionals in aix-stdint.h, but admittedly, that would have been an ugly way to go.

I have an AIX 5.3 system here as well. There is no sys/inttypes.h, but [u]int_fastNN_t is defined in sys/stdint.h, and all the types are the same size as [u]intNN_t. This is presumably the case for newer AIXes as well.

Fixincluding sys/inttypes.h should be safe IMO, and any bad fallout from that should be limited to AIX releases that still have this header, and use the unequal-sized-types, and somehow depend on those types. I'll double-check that this isn't the case for 4.3.
Comment 7 Daniel Richard G. 2012-07-17 23:24:13 UTC
Created attachment 27821 [details]
Patch against GCC SVN trunk

Hi David,

The attached patch is everything I've got so far to address issues in building GCC on AIX 4.3. This covers issues beyond this bug report, but I figured you'd rather take care of everything in one go. A walk-through of the changes:

++ gcc/opt-functions.awk

* Escape "{" characters to not annoy older awk programs

++ gcc/config/rs6000/rs6000.c

* legitimate_indirect_address_p() was coming up as undefined when declared with the "inline" keyword

* ASM_WEAKEN_DECL() was coming up undefined, too, even though the call is in a section of code not actually used on this platform

++ fixincludes/tests/base/*.h

* Updates to the test suite

++ fixincludes/inclhack.def

* Fixinclude for the oddly-sized fast-integer types

* Fixinclude for the broken PRIxNN macros in inttypes.h

* Fixinclude for an incomplete PTHREAD_ONCE_INIT (breaks -Werror builds)

* Tweaked the aix_pthread hack, as pthread.h has a tab character immediately after the "#define" on my system

* Fixinclude for an strtof() declaration lacking a const keyword (bug #48009)


Please let me know what you think.
Comment 8 David Edelsohn 2015-02-07 01:13:35 UTC
Patches are reviewed on gcc-patches mailinglist, not in Bugzilla

> The attached patch is everything I've got so far to address issues in
> building GCC on AIX 4.3. This covers issues beyond this bug report, but I
> figured you'd rather take care of everything in one go. A walk-through of
> the changes:
> 
> ++ gcc/opt-functions.awk
> 
> * Escape "{" characters to not annoy older awk programs

Prerequisites for GCC explicitly states that POSIX or SVR4 awk is required, so I don't think that this work-around would be accepted.  For example, you can install GNU Awk.

> 
> ++ gcc/config/rs6000/rs6000.c
> 
> * legitimate_indirect_address_p() was coming up as undefined when declared
> with the "inline" keyword

This already has been changed.

> * ASM_WEAKEN_DECL() was coming up undefined, too, even though the call is in
> a section of code not actually used on this platform
> 
> ++ fixincludes/tests/base/*.h
> 
> * Updates to the test suite
> 
> ++ fixincludes/inclhack.def
> 
> * Fixinclude for the oddly-sized fast-integer types
> 
> * Fixinclude for the broken PRIxNN macros in inttypes.h
> 
> * Fixinclude for an incomplete PTHREAD_ONCE_INIT (breaks -Werror builds)
> 
> * Tweaked the aix_pthread hack, as pthread.h has a tab character immediately
> after the "#define" on my system
> 
> * Fixinclude for an strtof() declaration lacking a const keyword (bug #48009)

The fixincludes changes are the most plausible ones.
Comment 9 David Edelsohn 2015-02-07 02:55:41 UTC
Author: dje
Date: Sat Feb  7 02:55:03 2015
New Revision: 220502

URL: https://gcc.gnu.org/viewcvs?rev=220502&root=gcc&view=rev
Log:
        PR bootstrap/53348
        * inclhack.def (aix_pthread): Accept tab after define.
        * fixincl.x: Regenerate.

Modified:
    trunk/fixincludes/ChangeLog
    trunk/fixincludes/fixincl.x
    trunk/fixincludes/inclhack.def
Comment 10 David Edelsohn 2015-02-16 15:19:51 UTC
Author: dje
Date: Mon Feb 16 15:19:20 2015
New Revision: 220736

URL: https://gcc.gnu.org/viewcvs?rev=220736&root=gcc&view=rev
Log:
Daniel Richard G. <skunk@iskunk.org>
        PR bootstrap/48009
        PR bootstrap/53348
        * inclhack.def (aix_strtof_const): New fix.
        * fixincl.x: Regenerate.
        * tests/base/inttypes.h: New test.

Modified:
    trunk/fixincludes/ChangeLog
    trunk/fixincludes/fixincl.x
    trunk/fixincludes/inclhack.def
Comment 11 David Edelsohn 2015-02-16 15:33:43 UTC
Author: dje
Date: Mon Feb 16 15:33:09 2015
New Revision: 220737

URL: https://gcc.gnu.org/viewcvs?rev=220737&root=gcc&view=rev
Log:
2015-02-16  Michael Haubenwallner  <michael.haubenwallner@ssi-schaefer.com>
            David Edelsohn  <dje.gcc@gmail.com>

        PR target/65058
        * config/rs6000/rs6000.c (rs6000_output_symbol_ref): Append storage
        mapping class to external variable or function reference.
        * config/rs6000/xcoff.h (ASM_OUTPUT_EXTERNAL): Do not append storage
        mapping class.

2015-02-16  David Eelsohn  <dje.gcc@gmail.com>

        PR target/53348
        * config/rs6000/rs6000.c (rs6000_declare_alias): Only use
        ASM_WEAKEN_DECL if defined.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/config/rs6000/xcoff.h
Comment 12 Daniel Richard G. 2015-02-17 06:40:41 UTC
(In reply to David Edelsohn from comment #8)
> Patches are reviewed on gcc-patches mailinglist, not in Bugzilla

Sorry, I'm not properly set up for mailing lists at the moment...

> > * Escape "{" characters to not annoy older awk programs
> 
> Prerequisites for GCC explicitly states that POSIX or SVR4 awk is required,
> so I don't think that this work-around would be accepted.  For example, you
> can install GNU Awk.

POSIX/SVR4 is significant if the system awk is missing major features that would make the script awkward/impossible to maintain. But a small syntax tweak like this, so long as it doesn't hurt other awk implementations, is no big deal. Especially for a script that is run by users who are only compiling the code, as opposed to developers.

> This already has been changed.
> 
[...]
> 
> The fixincludes changes are the most plausible ones.

As an aside, is there documentation somewhere on how to generate a GCC dist tarball from SVN? "make dist" doesn't do it, Web searches turn up nothing, and I'd rather not have to wait a few days for the next snapshot...
Comment 13 David Edelsohn 2015-02-17 14:50:39 UTC
The GCC build process has requirements, including SVR4/POSIX awk.  GCC works on a wide variety of systems, but needs to have a base set of requirements and limit accommodation to prevent things from getting out of control.  Building and installing Gawk or Nawk or another implementation is not an unreasonable burden.
Comment 14 Daniel Richard G. 2015-02-17 16:33:24 UTC
(In reply to David Edelsohn from comment #13)
> The GCC build process has requirements, including SVR4/POSIX awk.  GCC works
> on a wide variety of systems, but needs to have a base set of requirements
> and limit accommodation to prevent things from getting out of control. 

I understand that; my point is, escaping a couple of characters falls under the rubric of "limited accommodation." It would be a different story if I wanted GCC to build with an awk that, say, doesn't support variables.

> Building and installing Gawk or Nawk or another implementation is not an
> unreasonable burden.

It's less reasonable than a two-line patch.

(Any info on building a dist tarball? I don't have enough space on my AIX 4.3 system to take the entire SVN tree)
Comment 15 Martin Liška 2018-11-19 12:03:30 UTC
Can the bug be marked as resolved?
Comment 16 David Edelsohn 2018-11-19 13:39:30 UTC
Workarounds are available.