This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH/RFC] libstdc++'s tr1/cstdint vs. IRIX's stdint.h


mips-sgi-irix6.5 currently fails to bootstrap due to an interesting
interaction between libstdc++'s configure logic and IRIX's stdint.h
header file.

The catch is that the top of IRIX's /usr/include/stdint.h contain the
problematic lines:

#ifndef __c99
#error This header file is to be used only for c99 mode compilations
...
#endif

It looks like its trying to avoid poluting the default namespace with
int_fast16_t and friends, unless the user has requested ISO compatability.

This, of course, means that <stdint.h> can't be used from C unless
the user explicitly uses -std=gnu99 or similar command line option,
c.f. http://gcc.gnu.org/ml/gcc-patches/2006-01/msg00139.html which
was a similar fix for a libgfortran failure.


The unanticipated interaction in the libstdc++, is that configure
first tests whether <stdint.h> is available using a C compiler but
without -std=gnu99, which therefore fails on IRIX, but later in the
same configure script tests "checking for ISO C99 support to TR1 in
<stdint.h>" using the g++ compiler, which confusingly returns true.
The irix backend of the g++ compiler, defines "__c99" by default.

This twisted logic results in c++config.h not defining the macro
_GLIBCXX_HAVE_STDINT_H but paradoxically defining the macro
_GLIBC_USE_C99_STDINT_TR1.  This then is sufficient to trigger
compilation failures in include/tr1/cstdint, which uses the first
to determine whether to include the system header, and the second
to determine whether to use the symbols defined in that header.


I'm not really sure the best way to fix this.  Conceptually, it would
make sense of libstdc++ to use the C++ compiler to detect whether headers
are available.  Unfortunately, my autoconf-foo isn't clever enough for
that.  The lesser alternative is the patch proposed below, which simply
teaches include/tr1/cstdint to include <stdint.h> if when it was detected
via _GLIBCXX_USE_C99_STDINT_TR1 even when _GLIBCXX_HAVE_STDINT_H is false.

The following patch has been tested on mips-sgi-irix6.5, with a "make
bootstrap", including c++, where it resolves the bootstrap failure and
completes the build of libstdc++.

Thoughts?



2006-07-18  Roger Sayle  <roger@eyesopen.com>

	* include/tr1/cstdint: Include <stdint.h> when _GLIBCXX_HAVE_STDINT_H
	is false, but _GLIBCXX_USE_C99_STDINT_TR1 is true.


Index: include/tr1/cstdint
===================================================================
*** include/tr1/cstdint	(revision 115528)
--- include/tr1/cstdint	(working copy)
***************
*** 36,42 ****

  #include <bits/c++config.h>

! #if _GLIBCXX_HAVE_STDINT_H
  // For 8.22.1/1 (see C99, Notes 219, 220, 222)
  #define __STDC_LIMIT_MACROS
  #define __STDC_CONSTANT_MACROS
--- 36,42 ----

  #include <bits/c++config.h>

! #if _GLIBCXX_HAVE_STDINT_H || _GLIBCXX_USE_C99_STDINT_TR1
  // For 8.22.1/1 (see C99, Notes 219, 220, 222)
  #define __STDC_LIMIT_MACROS
  #define __STDC_CONSTANT_MACROS


Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]