https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61538
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This is the patch which I used for glibc to fix some libstdc++ issues: >From 2788414e4e6a548766aa7e732fc096f9f572302e Mon Sep 17 00:00:00 2001 From: Andrew Pinski <apin...@cavium.com> Date: Thu, 1 Nov 2012 23:07:22 -0700 Subject: [PATCH] 2012-11-01 Andrew Pinski <apin...@cavium.com> Bug #5086 * ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c (__pthread_once): Add release barrier before setting once_control to say initialisation is done. (clear_once_control): Add release barrier. --- ChangeLog.CAVIUM | 8 ++++++++ .../unix/sysv/linux/mips/nptl/pthread_once.c | 2 ++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/ChangeLog.CAVIUM b/ChangeLog.CAVIUM index 8ed42ea..5975430 100644 --- a/ChangeLog.CAVIUM +++ b/ChangeLog.CAVIUM @@ -1,3 +1,11 @@ +2012-11-01 Andrew Pinski <apin...@cavium.com> + + Bug #5086 + * ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c (__pthread_once): + Add release barrier before setting once_control to say + initialisation is done. + (clear_once_control): Add release barrier. + 2012-10-28 Andrew Pinski <apin...@cavium.com> Bug #5059 diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c b/ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c index 308da8b..c2ef264 100644 --- a/ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c +++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c @@ -28,6 +28,7 @@ clear_once_control (void *arg) { pthread_once_t *once_control = (pthread_once_t *) arg; + atomic_full_barrier (); *once_control = 0; lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE); } @@ -80,6 +81,7 @@ __pthread_once (once_control, init_routine) /* Add one to *once_control. */ + atomic_full_barrier (); atomic_increment (once_control); /* Wake up all other threads. */ -- 1.7.4.1