GCC-3.0.4 (pre) on AIX requires pthreads

Loren James Rittle rittle@latour.rsch.comm.mot.com
Thu Feb 21 04:45:00 GMT 2002


> This is why I initially raised a concern about going down this
> path: libstdc++ is trying to use multilibs for something which is not
> orthogonal at the installed header file level.

I think David is absolutely correct on the root cause of the problem.
This exact problem is seen on HPUX10 (known to me before today by
report); OSF1 with multilibs keyed off the threading model (known to
me before today by personal inspection); AIX (known to me as of
today).

Until today, I thought recent versions of AIX were fine on this point.
That these ports do not work in this regard is partly/mainly my fault
(at least I didn't improve this area when I last worked on it).  But
my patch also fixes architectural breakage well outside any
incremental damage I caused.

People didn't care about the OSF1 breakage since the default
configuration in the gcc tree didn't kill it.  HPUX10 was considered
on life support and not worth fixing properly.

Attached below is my preferred way to fix this problem with (now out
of date) patch written Dec. 2001.  But this is the first public posting.

Comments? (after the patch is additional commentary on the proposed
solution)

Regards,
Loren

This patch fixes, in a general manner, the HPUX10 configuration bug
recently uncovered by Jeff Law related to multilib'd libgcc
construction when a multilib option affects the proper creation of
(what had been known as) gthr-default.h .  The root issue was that
gthr-default.h was built only once yet required a different contents
for each multilib that impacted selection of the thread abstraction
layer.  A related problem hasn't been reported yet but multilib'd
libstdc++-v3 has a similar potential problem to that Jeff uncovered
with libgcc and it is not solvable with the same technique used by
Jeff since there is a race between which built copy of gthr-default.h
would be installed.  Few ports are normally configured in this manner.
As problems were found, they have been fixed in a manner useful for
the port.  Now that we have about 7 months of experience with ``Thread
model'' reporting, it is time to retune some things to bring port
configurations closer together.

This patch has the pleasant side-effect of removing more dependencies
between support library configuration and gcc itself (and I confess is
something that I wanted to further cleanup for some time).

Bootstrapped and checked on i386-unknown-freebsd4.4,
alphaev67-dec-osf5.1 (along with a simple patch to enable multilib
keyed on -pthread for this platform), sparc-sun-solaris2.7.  Passed
`make check' with no new regressions.  Manually inspected output from:
``./xgcc -B./ -E -dM - [-pthread] [-no-gcc] </dev/null'' to ensure
that multilib'd platform with similar keying of thread abstraction now
worked without an extra per-port hack.  After converting the
alpha*-dec-osf5.1 port (--enable-thread=posix configuration) to use
multilib and setting a proper THREAD_MODEL_SPEC along with this patch,
I saw all non-fatal bootstrap warnings about missing pthread_* symbols
and the requirement that all compiler runs provide -pthread to produce
useful executables disappear.

(In gcc:)
	* doc/cpp.texi: Document __GNUC_THREADMODEL__.
	* gcc.c: Document new spec string, %t.
	(cpp_options): Add __GNUC_THREADMODEL__ which maps to the
	dynamically-computed thread model (same as textually reported
	via -v switch).
	(do_spec_1): New 't' case.

	* Makefile.in: Remove GTHREAD_FLAGS and all use of @gthread_flags@.
	* configure.in: Remove gthread_flags.  Do not create gthr-default.h.
	* gthr.h: Remove outdated comment regarding supported
	abstraction layers (the real list is the set of gthr-*.h
	files).  Remove ability for user to silently change thread
	abstraction layer with undocumented macros.  Remove test on
	HAVE_GTHR_DEFAULT.  Remove fallback to gthr-single.h.  Compute
	thread abstraction layer file to include from compiler-set
	__GNUC_THREADMODEL__ macro (i.e. we now directly aligned with
	per-platform multilib support which might change the thread
	abstraction; ports need now only set THREAD_MODEL_SPEC
	properly to express multilib changes as was previously
	documented; additional, undocumented, per-port hacking
	should no longer be required in these cases.)
	* configure: Rebuilt.
	* config/m68hc11/t-m68hc11-gas (LIBGCC2_CFLAGS): Remove use of
	GTHREAD_FLAGS.

[Since I can't test it and not strictly required, not done.  I invite
 an HPUX maintainer to:
	* gthr-dce.h: Unroll -j1.14 -j1.15.
]
[Since I can't test it and not strictly required, not done.  I invite
 an AIX maintainer to:
	* config.gcc (rs6000-ibm-aix4.[3456789]*): Set thread_file to posix.
	(rs6000-ibm-aix[56789].*): Likewise.
	* gthr-aix.h: Remove file.
]
[To be provided under separate cover, since not strictly required for this
 work and must investigate whether it works for alpha*-dec-osf4* as well
 as alpha*-dec-osf5* and why -pthread vfork configuration test hangs:
	* config.gcc (alpha*-dec-osf*): Provide default thread_file setting.
	* config/alpha/t-osf4 (MULTILIB_OPTIONS): Set to pthread .
	(LIBGCC): Set to stmp-multilib .
	(INSTALL_LIBGCC): Set to install-multilib .
	(SHLIB_LINK): Handle pthread multilib configuration.
	* config/alpha/osf.h (THREAD_MODEL_SPEC):  Add.
]

(In libobjc:)
	* Makefile.in: Remove GTHREAD_FLAGS and all use of @GTHREAD_FLAGS@.
	* configure.in: Remove GTHREAD_FLAGS, objc_cv_gthread_flags
	and related code that was really cozy with the internals of
	the gcc Makefile.
	* configure: Rebuilt.

(In libstdc++-v3:)
	* acinclude.m4 (HAVE_GTHR_DEFAULT): Remove.
	* acconfig.h (HAVE_GTHR_DEFAULT): Remove.
	* aclocal.m4: Rebuilt.
	* configure: Rebuilt.
	* config.h.in: Rebuilt.
	* include/Makefile.am: Change both occurrences of
        gthr-default.h to ${glibcpp_thread_h}.  Headers from multilib
        configurations with unique content but sharing the same name,
        no longer trash each other upon installation since this gives
	them unique names.
	(${thread_builddir}/gthr.h): Update staging rule.
	* include/Makefile.in: Rebuilt.

Index: doc/cpp.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/cpp.texi,v
retrieving revision 1.2.2.13
diff -c -r1.2.2.13 cpp.texi
*** cpp.texi	2001/11/14 22:33:36	1.2.2.13
--- cpp.texi	2001/12/05 08:04:14
***************
*** 1887,1892 ****
--- 1887,1906 ----
  @noindent
  Many people find this form easier to understand.
  
+ @item __GNUC_THREADMODEL__
+ This macro expands to the canonical name of the dynamically-computed
+ thread model, in the form of a C symbol suitable for pasting or
+ conversion to a C string constant.  In all cases, the value will be one
+ of the following: @samp{single}, the canonical name for the value
+ provided to @option{--enable-threads} when gcc was originally
+ configured, or the default thread model for the system.  The value
+ should only change based on command-line options that affect multilib
+ selection for a platform.  Although the possibility exists for general
+ use, the main purpose of this macro is to simplify the configuration of
+ language libraries bundled with gcc.
+ 
+ @code{__GNUC_THREADMODEL__} is new to GCC 3.1.
+ 
  @item __GNUG__
  The GNU C++ compiler defines this.  Testing it is equivalent to
  testing @code{@w{(__GNUC__ && __cplusplus)}}.
Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.205.2.23
diff -c -r1.205.2.23 gcc.c
*** gcc.c	2001/12/03 22:44:36	1.205.2.23
--- gcc.c	2001/12/05 08:04:15
***************
*** 370,375 ****
--- 370,376 ----
  	(For version 2.5.3, this is 5.)
   %v3	Substitute the patch level number of GCC.
  	(For version 2.5.3, this is 3.)
+  %t	Substitute the threading model of GCC.
   %a     process ASM_SPEC as a spec.
          This allows config.h to specify part of the spec for running as.
   %A	process ASM_FINAL_SPEC as a spec.  A capital A is actually
***************
*** 596,602 ****
   %{MD:-M -MF %W{!o: %b.d}%W{o*:%.d%*}}\
   %{MMD:-MM -MF %W{!o: %b.d}%W{o*:%.d%*}}\
   %{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{M|MD|MM|MMD:%{o*:-MQ %*}}\
!  %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
   %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
   %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
   %{fno-inline|O0|!O*:-D__NO_INLINE__} %{ffast-math:-D__FAST_MATH__}\
--- 597,604 ----
   %{MD:-M -MF %W{!o: %b.d}%W{o*:%.d%*}}\
   %{MMD:-MM -MF %W{!o: %b.d}%W{o*:%.d%*}}\
   %{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{M|MD|MM|MMD:%{o*:-MQ %*}}\
!  %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3\
!  -D__GNUC_THREADMODEL__=%t}\
   %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
   %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
   %{fno-inline|O0|!O*:-D__NO_INLINE__} %{ffast-math:-D__FAST_MATH__}\
***************
*** 4937,4942 ****
--- 4939,4954 ----
  		/* Default to "0" */
  		obstack_grow (&obstack, &zeroc, 1);
  	      arg_going = 1;
+ 	    }
+ 	    break;
+ 
+ 	  case 't':
+ 	    {
+ #ifdef THREAD_MODEL_SPEC
+ 	      do_spec_1 (THREAD_MODEL_SPEC, 0, thread_model);
+ #else
+ 	      do_spec_1 (thread_model, 1, NULL_PTR);
+ #endif
  	    }
  	    break;
  
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.602.2.43
diff -c -r1.602.2.43 Makefile.in
*** Makefile.in	2001/11/19 00:46:43	1.602.2.43
--- Makefile.in	2001/12/05 10:02:00
***************
*** 294,300 ****
  target_cpu_default=@target_cpu_default@
  GCC_THREAD_FILE=@thread_file@
  OBJC_BOEHM_GC=@objc_boehm_gc@
- GTHREAD_FLAGS=@gthread_flags@
  # Be prepared for gcc2 merges.
  gcc_version=@gcc_version@
  gcc_version_trigger=@gcc_version_trigger@
--- 294,299 ----
***************
*** 407,413 ****
  # so that -g1 will be tested.
  #
  LIBGCC2_DEBUG_CFLAGS = -g1
! LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(TARGET_LIBGCC2_CFLAGS) $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED @inhibit_libc@
  
  # Additional options to use when compiling libgcc2.a.
  # Some targets override this to -isystem include
--- 406,412 ----
  # so that -g1 will be tested.
  #
  LIBGCC2_DEBUG_CFLAGS = -g1
! LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(TARGET_LIBGCC2_CFLAGS) $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED @inhibit_libc@
  
  # Additional options to use when compiling libgcc2.a.
  # Some targets override this to -isystem include
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.in,v
retrieving revision 1.483.2.30
diff -c -r1.483.2.30 configure.in
*** configure.in	2001/12/04 19:42:38	1.483.2.30
--- configure.in	2001/12/05 10:02:00
***************
*** 1706,1720 ****
  	esac
  done
  
- # Make gthr-default.h if we have a thread file.
- gthread_flags=
- if test $thread_file != single; then
-     rm -f gthr-default.h
-     echo "#include \"gthr-${thread_file}.h\"" > gthr-default.h
-     gthread_flags=-DHAVE_GTHR_DEFAULT
- fi
- AC_SUBST(gthread_flags)
- 
  # Find out what GC implementation we want, or may, use.
  AC_ARG_WITH(gc,
  [  --with-gc={simple,page} choose the garbage collection mechanism to use
--- 1706,1711 ----
Index: gcc/gthr.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gthr.h,v
retrieving revision 1.7
diff -c -r1.7 gthr.h
*** gthr.h	2000/01/27 18:49:12	1.7
--- gthr.h	2001/12/05 10:02:00
***************
*** 1,6 ****
  /* Threads compatibility routines for libgcc2.  */
  /* Compile this one with gcc.  */
! /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
  
--- 1,6 ----
  /* Threads compatibility routines for libgcc2.  */
  /* Compile this one with gcc.  */
! /* Copyright (C) 1997, 1998, 2001 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
  
***************
*** 73,105 ****
  
     All functions returning int should return zero on success or the error
     number.  If the operation is not supported, -1 is returned.
- 
-    Currently supported threads packages are
-      POSIX threads with -D_PTHREADS
-      DCE threads with -D_DCE_THREADS
-      Solaris/UI threads with -D_SOLARIS_THREADS
  */
  
- /* Check first for thread specific defines. */
- #if _PTHREADS
- #include "gthr-posix.h"
- #elif _DCE_THREADS
- #include "gthr-dce.h"
- #elif _SOLARIS_THREADS
- #include "gthr-solaris.h"
- 
- /* Include GTHREAD_FILE if one is defined. */
- #elif defined(HAVE_GTHR_DEFAULT)
  #if SUPPORTS_WEAK
  #ifndef GTHREAD_USE_WEAK
  #define GTHREAD_USE_WEAK 1
  #endif
  #endif
- #include "gthr-default.h"
  
! /* Fallback to single thread definitions. */
! #else
! #include "gthr-single.h"
! #endif
  
  #endif /* not __gthr_h */
--- 73,88 ----
  
     All functions returning int should return zero on success or the error
     number.  If the operation is not supported, -1 is returned.
  */
  
  #if SUPPORTS_WEAK
  #ifndef GTHREAD_USE_WEAK
  #define GTHREAD_USE_WEAK 1
  #endif
  #endif
  
! #define STRX(a) #a
! #define STR(a) STRX(a)
! #include STR(gthr-__GNUC_THREADMODEL__.h)
  
  #endif /* not __gthr_h */
Index: config/m68hc11/t-m68hc11-gas
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/t-m68hc11-gas,v
retrieving revision 1.2.4.2
diff -c -r1.2.4.2 t-m68hc11-gas
*** t-m68hc11-gas	2001/08/03 21:05:49	1.2.4.2
--- t-m68hc11-gas	2001/12/05 10:02:00
***************
*** 36,42 ****
  
  # Don't compile with -g1 this reduces the size of some sections (.eh_frame).
  LIBGCC2_DEBUG_CFLAGS =
! LIBGCC2_CFLAGS = -Os $(LIBGCC2_INCLUDES) $(TARGET_LIBGCC2_CFLAGS) $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) -DIN_LIBGCC2
  
  MULTILIB_OPTIONS  = m68hc11/m68hc12 mshort fshort-double
  MULTILIB_DIRNAMES =
--- 36,42 ----
  
  # Don't compile with -g1 this reduces the size of some sections (.eh_frame).
  LIBGCC2_DEBUG_CFLAGS =
! LIBGCC2_CFLAGS = -Os $(LIBGCC2_INCLUDES) $(TARGET_LIBGCC2_CFLAGS) $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2
  
  MULTILIB_OPTIONS  = m68hc11/m68hc12 mshort fshort-double
  MULTILIB_DIRNAMES =
Index: libobjc/Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/Makefile.in,v
retrieving revision 1.16.6.3
diff -c -r1.16.6.3 Makefile.in
*** Makefile.in	2001/05/09 14:20:01	1.16.6.3
--- Makefile.in	2001/12/05 10:02:00
***************
*** 60,68 ****
  
  CC = @CC@
  CFLAGS = @CFLAGS@
- GTHREAD_FLAGS=@GTHREAD_FLAGS@
  ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) \
! 	$(GTHREAD_FLAGS) -DIN_GCC -DIN_TARGET_LIBS
  
  # Libtool
  # The following strings describe the version of the obj-C library 
--- 60,67 ----
  
  CC = @CC@
  CFLAGS = @CFLAGS@
  ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) \
! 	-DIN_GCC -DIN_TARGET_LIBS
  
  # Libtool
  # The following strings describe the version of the obj-C library 
Index: libobjc/configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/configure.in,v
retrieving revision 1.14
diff -c -r1.14 configure.in
*** configure.in	2001/02/09 07:14:34	1.14
--- configure.in	2001/12/05 10:02:00
***************
*** 109,126 ****
  
  AC_CHECK_HEADERS(sched.h)
  
- # Determine CFLAGS for gthread.
- 
- AC_CACHE_CHECK([for gthread cflags],objc_cv_gthread_flags,
- [if test -f "$r"/gcc/Makefile
- then
-   objc_cv_gthread_flags=`grep \^GTHREAD_FLAGS "$r"/gcc/Makefile | awk -F= '{ print $2 }'`
- else
-   AC_MSG_ERROR([not found])
- fi])
- GTHREAD_FLAGS=$objc_cv_gthread_flags
- AC_SUBST(GTHREAD_FLAGS)
- 
  # Disable shared libs by default
  AC_DISABLE_SHARED
  # Enable Win32 DLL on MS Windows - FIXME 
--- 109,114 ----
Index: libstdc++-v3/acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.129.2.31
diff -c -r1.129.2.31 acinclude.m4
*** acinclude.m4	2001/11/09 21:35:14	1.129.2.31
--- acinclude.m4	2001/12/06 22:10:32
***************
*** 1148,1154 ****
    AC_MSG_RESULT([$target_thread_file])
  
    if test $target_thread_file != single; then
-     AC_DEFINE(HAVE_GTHR_DEFAULT)
      AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
    fi
  
--- 1148,1153 ----
Index: libstdc++-v3/acconfig.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acconfig.h,v
retrieving revision 1.15.4.5
diff -c -r1.15.4.5 acconfig.h
*** acconfig.h	2001/11/02 22:39:01	1.15.4.5
--- acconfig.h	2001/12/06 22:10:32
***************
*** 3,11 ****
  // Define if GCC supports weak symbols.
  #undef _GLIBCPP_SUPPORTS_WEAK
  
- // Define if gthr-default.h exists (meaning that threading support is enabled).
- #undef HAVE_GTHR_DEFAULT
- 
  // Include I/O support for 'long long' and 'unsigned long long'.
  #undef _GLIBCPP_USE_LONG_LONG
  
--- 3,8 ----
Index: libstdc++-v3/include/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/Makefile.am,v
retrieving revision 1.1.6.6
diff -c -r1.1.6.6 Makefile.am
*** Makefile.am	2001/08/29 00:41:56	1.1.6.6
--- Makefile.am	2001/12/06 22:10:32
***************
*** 291,297 ****
  thread_headers = \
  	${thread_builddir}/gthr.h \
  	${thread_builddir}/gthr-single.h \
! 	${thread_builddir}/gthr-default.h
  
  # List of all timestamp files.  By keeping only one copy of this list, both
  # CLEANFILES and all-local are kept up-to-date.
--- 291,297 ----
  thread_headers = \
  	${thread_builddir}/gthr.h \
  	${thread_builddir}/gthr-single.h \
! 	${thread_builddir}/${glibcpp_thread_h}
  
  # List of all timestamp files.  By keeping only one copy of this list, both
  # CLEANFILES and all-local are kept up-to-date.
***************
*** 398,403 ****
--- 398,404 ----
  
  ${thread_builddir}/gthr.h:
  	sed -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCPP_\1/g' \
+ 	    -e '/^#/s/_GLIBCPP___/__/g' \
  	    -e 's,^#include "\(.*\)",#include <bits/\1>,g' \
  	    < ${toplevel_srcdir}/gcc/gthr.h > $@
  
***************
*** 406,412 ****
  	    -e 's/\(GCC${uppercase}*_H\)/_GLIBCPP_\1/g' \
  	    < ${toplevel_srcdir}/gcc/gthr-single.h > $@
  
! ${thread_builddir}/gthr-default.h:
  	sed -e 's/\(UNUSED\)/_GLIBCPP_\1/g' \
  	    -e 's/\(GCC${uppercase}*_H\)/_GLIBCPP_\1/g' \
  	    -e 's/\(${uppercase}*WEAK\)/_GLIBCPP_\1/g' \
--- 407,413 ----
  	    -e 's/\(GCC${uppercase}*_H\)/_GLIBCPP_\1/g' \
  	    < ${toplevel_srcdir}/gcc/gthr-single.h > $@
  
! ${thread_builddir}/${glibcpp_thread_h}:
  	sed -e 's/\(UNUSED\)/_GLIBCPP_\1/g' \
  	    -e 's/\(GCC${uppercase}*_H\)/_GLIBCPP_\1/g' \
  	    -e 's/\(${uppercase}*WEAK\)/_GLIBCPP_\1/g' \

Date: Wed, 5 Dec 2001 00:00:26 -0600 (CST)
From: Loren James Rittle <rittle>
Message-Id: <200112050600.fB560QB18436@latour.rsch.comm.mot.com>
To: XXX (not a public list)
Subject: Simplification of gthr-X.h section code; kill gthr-default.h

[...]

As the author of the original radical improvements related to
threading configuration as used in modern language support libraries
and as a general gcc configuration file hacker, I wanted to get your
advice about something.  You may have spotted an e-mail exchange I had
with Jeff Law on gcc-patches regarding a bad interaction between
libgcc and multilibs (where a multilib option may affect which
gthr-*.h is selected as the default).  As someone that used your
reporting mechanism to improve how we did things under libstdc++-v3
(you were involved with that but I take all the blame for when we
messed up ;-), here is my considered opinion on the best way to make
another simplification to configuration files while also improving the
odds that gcc users don't hang themselves (or get hung without any
fault of their own on less-used ports).  This direction will allow us
to fix the general problem that Jeff found and fixed for one case.  It
will also allow random simplification of configuration files.

Would you support exposing the value normally output with ``gcc -v''
on the ``Thread model'' line as a standardized preprocessing symbol?

Proposed name:

__GNUC_THREADMODEL__ 

It would be documented along with the three existing __GNUC* macros.
However, it's main expected use is with gcc support library configuration.

Example proposed value (in form as reported by ``gcc -E -dM -''):

#define __GNUC_THREADMODEL__ "single"

In general, it is a string that exactly matches the canonical name as
would be given to the --enable-threads configuration option.

Or, if you read the idea and like it better having a value such as:

#define __GNUC_THREADMODEL__ single

we can use the obvious trick to make it a string.  One example use
within libgcc code under the assumption that __GNUC_THREADMODEL__ is
defined as in the second case:

#define STRX(a) #a
#define STR(a) STRX(a)
#include "gthr-" STR(__GNUC_THREADMODEL__) ".h"

With this change, we could remove and, more importantly, avoid having
to add *a lot* of complex stuff to configuration files.  If you would
be willing to support this additional reporting mechanism (i.e. please
don't take this as a request to remove the textual reporting to the
user, it so cool to be able to tell users: ``But, of course, you don't
have a thread-safe gcc since it is reporting it's thread model as
single not posix or somesuch'' ;-) THEN I could fix Jeff's HPUX
problem and OSF's similar problem directly without having to make the
configuration process any trickier.  I personally think the easiest
way to do so is to remove all such code which writes a gthr-default.h
file in $objdir/gcc and change gthr.h to use the technique I display
above.  I would probably also like to take the opportunity to nail all
the remaining macro selections which can override the selection of the
abstraction layer.  As we have discussed, it changes the ABI thus it
should have been converted to use multilibs a long time ago...

Are you sold enough to help me go public with the idea?  If so, I
would just assume we develop and test a patch for the whole
problem-space before we go public.  I think I am capable of doing as
much of the solution as you would like me to.  I just wanted to give
you the opportunity to be involved as the original author of
improvements in this area and the early veto or tweak.

Final sell.  Before you become disgusted with the idea of adding a
macro, please consider that the g++ compiler already reports the
status of weak symbol linkage support via __GXX_WEAK__.  This is used
to de-link configuration complexity between the C++ compiler and its
support library.  Humm, similar goal, similar solution.  Your original
reporting mechanism worked well for multilib'd libstdc++-v3 and it too
de-linked configuration complexity.  But having reviewed the
construction of multilibs with the special case of libgcc (Yikes! is
the only expression that comes to mind worth printing ;-), it looks
like it would be a lot of work to fix it "right" and in a general
manner under the way things are currently done without adding this new
macro.  Adding this macro allows for a "right" solution that also
happens to allow additional cleanup.



More information about the Libstdc++ mailing list