Bug 19399 - [4.0 Regression] mutexes support broken
Summary: [4.0 Regression] mutexes support broken
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-12 14:40 UTC by Ralf Corsepius
Modified: 2005-01-13 17:04 UTC (History)
2 users (show)

See Also:
Host:
Target: *-rtems*
Build:
Known to work: 3.4.0
Known to fail: 4.0.0
Last reconfirmed: 2005-01-12 14:50:27


Attachments
patch to add recursive mutex to gthr-rtems.h (528 bytes, patch)
2005-01-12 15:24 UTC, Joel Sherrill
Details | Diff
2nd try (614 bytes, patch)
2005-01-12 17:12 UTC, Joel Sherrill
Details | Diff
RTEMS patch to match gthr-rtems.h try2 (446 bytes, patch)
2005-01-12 17:13 UTC, Joel Sherrill
Details | Diff
RTEMS patch to match gthr-rtems.h-try2 (554 bytes, patch)
2005-01-13 08:16 UTC, Ralf Corsepius
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Corsepius 2005-01-12 14:40:07 UTC
GCC 4.0 has broken rtems thread support for all targets:

# configure --enable-languages=c,c++ --enable-threads=rtems\
[more options]
...
# make
...
/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/build/gcc/xgcc
-shared-libgcc
-B/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/build/gcc/
-nostdinc++
-L/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/build/arm-rtems4.7/libstdc++-v3/src
-L/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/build/arm-rtems4.7/libstdc++-v3/src/.libs
-nostdinc
-B/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/build/arm-rtems4.7/newlib/
-isystem
/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/build/arm-rtems4.7/newlib/targ-include
-isystem
/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/gcc-4.0.0/newlib/libc/include
-B/opt/rtems-4.7/arm-rtems4.7/bin/ -B/opt/rtems-4.7/arm-rtems4.7/lib/ -isystem
/opt/rtems-4.7/arm-rtems4.7/include -isystem
/opt/rtems-4.7/arm-rtems4.7/sys-include
-I/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/gcc-4.0.0/libstdc++-v3/../gcc
-I/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/build/arm-rtems4.7/libstdc++-v3/include/arm-rtems4.7
-I/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/build/arm-rtems4.7/libstdc++-v3/include
-I/users/rtems/src/rpms/BUILD/rtems-4.7-arm-rtems4.7-gcc-newlib-gcc4.0.0newlib1.13.0/gcc-4.0.0/libstdc++-v3/libsupc++
-O2 -g -O2 -g -O2 -fno-implicit-templates -Wall -Wextra -Wwrite-strings
-Wcast-qual -fdiagnostics-show-location=once -c
../../../../gcc-4.0.0/libstdc++-v3/libsupc++/guard.cc -o guard.o
../../../../gcc-4.0.0/libstdc++-v3/libsupc++/guard.cc:51: error:
'__gthread_recursive_mutex_t' does not name a type
../../../../gcc-4.0.0/libstdc++-v3/libsupc++/guard.cc:62: error:
'__gthread_recursive_mutex_t' does not name a type
../../../../gcc-4.0.0/libstdc++-v3/libsupc++/guard.cc: In static member function
'static void<unnamed>::static_mutex::lock()':
../../../../gcc-4.0.0/libstdc++-v3/libsupc++/guard.cc:81: error: 'mutex' was not
declared in this scope
../../../../gcc-4.0.0/libstdc++-v3/libsupc++/guard.cc:81: error:
'__gthread_recursive_mutex_lock' was not declared in this scope
../../../../gcc-4.0.0/libstdc++-v3/libsupc++/guard.cc: In static member function
'static void<unnamed>::static_mutex::unlock()':
../../../../gcc-4.0.0/libstdc++-v3/libsupc++/guard.cc:86: error: 'mutex' was not
declared in this scope
../../../../gcc-4.0.0/libstdc++-v3/libsupc++/guard.cc:86: error:
'__gthread_recursive_mutex_unlock' was not declared in this scope

Without having looked into details, something in GCC seems to have changed which
silently breaks gthr-rtems.h.
Comment 1 Eric Botcazou 2005-01-12 14:50:26 UTC
> Without having looked into details, something in GCC seems to have changed
> which silently breaks gthr-rtems.h.

Indeed, things rarely break without reason. :-)


It's

2004-08-27  Jason Merrill  <jason@redhat.com>

	PR c++/13684
	* gimplify.c (gimplify_cleanup_point_expr): Handle CLEANUP_EH_ONLY.
	(gimple_push_cleanup): Add eh_only parm.
	(gimplify_target_expr): Pass it.
	* c.opt (-fno-threadsafe-statics): New option.
	* c-opts.c (c_common_handle_option): Handle it.
	* c-common.h (flag_threadsafe_statics): Declare it.
	* c-common.c (flag_threadsafe_statics): Record it.
	* doc/invoke.texi: Document it.
	* tsystem.h (_GNU_SOURCE): Define.
	* gthr-posix.h (__gthread_recursive_mutex_t): New typedef.
	(__GTHREAD_RECURSIVE_MUTEX_INIT): New macro.
	(__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION): New macro.
	(__gthread_recursive_mutex_init_function): New fn.
	(__gthread_recursive_mutex_lock): New fn.
	(__gthread_recursive_mutex_trylock): New fn.
	(__gthread_recursive_mutex_unlock): New fn.
	* gthr-solaris.h, gthr-single.h, gthr-dce.h: Likewise.
	* gthr-win32.h, gthr-vxworks.h: Likewise.
	* gthr.h: Document.

See gthr-win32.h or gthr-posix95.h or gthr-solaris.h for an example of
implementation of recursive mutexes.
Comment 2 Joel Sherrill 2005-01-12 15:24:45 UTC
Created attachment 7937 [details]
patch to add recursive mutex to gthr-rtems.h

Does the attached patch look OK?  It compiles for all the *-rtems targets
that actually compile right now.  Is it OK to commit?

2005-01-12  Joel Sherrill <joel@oarcorp.com>

	PR target 19399
	* gthr-rtems.h: Add support for recursive mutex.
Comment 3 Ralf Corsepius 2005-01-12 15:54:28 UTC
(In reply to comment #2)
> Created an attachment (id=7937)
> patch to add recursive mutex to gthr-rtems.h
> 
> Does the attached patch look OK?

The lower part of the patch seems OK to me, but when looking into the
implementation of rtems_gxx_* in RTEMS sources, the *init_mutex related parts
don't seem right to me. AFAIU, current rtems_gxx_mutex_init must not be called
multiple times.

I think the most flexible and simple solution would be to add a 
rtems_gxx_recursive_mutex_init to RTEMS.

Also, I'd prefer to use this definition
typedef void * __gthread_recursive_mutex_t;
Comment 4 Joel Sherrill 2005-01-12 17:12:38 UTC
Created attachment 7938 [details]
2nd try

I think this patch matches the intent of the original discussions 
about recursive at http://gcc.gnu.org/ml/gcc-patches/2004-09/msg00631.html.
It should also address Ralf's concerns.
Comment 5 Joel Sherrill 2005-01-12 17:13:44 UTC
Created attachment 7939 [details]
RTEMS patch to match gthr-rtems.h try2

This is a patch to the RTEMS gxx_wrappers.c which provides the mutex
functionality for gcc.
Comment 6 Joel Sherrill 2005-01-12 17:15:40 UTC
(In reply to comment #3)

> I think the most flexible and simple solution would be to add a 
> rtems_gxx_recursive_mutex_init to RTEMS.
> 
> Also, I'd prefer to use this definition
> typedef void * __gthread_recursive_mutex_t;

Grrr.. looking back through the old mail and mail lists, that was indeed the 
intent when this was first mentioned.  I just added a new GCC patch and the
corresponding RTEMS patch (for reference).  What do you think of them?
Comment 7 Ralf Corsepius 2005-01-12 23:57:32 UTC
(In reply to comment #6)
> (In reply to comment #3)

> What do you think of them?

pr19399-try2.diff looks good to me. I've just launched local test-builds,
nevertheless, OK to commit, IMO.

I haven't looked into rtems-gxx_wrappers.diff, yet.
Comment 8 Ralf Corsepius 2005-01-13 08:16:52 UTC
Created attachment 7947 [details]
RTEMS patch to match gthr-rtems.h-try2

Patch 7939 (rtems-gxx_wrappers.c) doesn't work.

It uses gthread_mutex_*lock() which is private to GCC and not available inside
of RTEMS. I am replacing it with a version using rtems_gxx_mutex*lock() inside
of RTEMS CVS (CVS-head and 4.6-branch).
Comment 9 GCC Commits 2005-01-13 15:50:54 UTC
Subject: Bug 19399

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	corsepiu@gcc.gnu.org	2005-01-13 15:50:13

Modified files:
	gcc            : ChangeLog gthr-rtems.h 

Log message:
	2005-01-13  Ralf Corsepius  <ralf.corsepius@rtems.org>
	Joel Sherrill  <joel@oarcorp.com>
	
	PR target/19399
	* gthr-rtems.h (__gthread_recursive_mutex_t): New type.
	(__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION): Define to
	rtems_gxx_recursive_mutex_init.
	(__gthread_recursive_mutex_lock): New function.
	(__gthread_recursive_mutex_trylock): Likewise.
	(__gthread_recursive_mutex_unlock): Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7108&r2=2.7109
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gthr-rtems.h.diff?cvsroot=gcc&r1=1.10&r2=1.11

Comment 10 Ralf Corsepius 2005-01-13 17:04:06 UTC
Patches applied to trunk.