Bug 51038 - [4.7 Regression]: 29_atomics/atomic_flag/clear/1.cc test_and_set/explicit.cc implicit.cc
Summary: [4.7 Regression]: 29_atomics/atomic_flag/clear/1.cc test_and_set/explicit.cc ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords: link-failure, wrong-code
Depends on:
Blocks:
 
Reported: 2011-11-08 19:48 UTC by Hans-Peter Nilsson
Modified: 2011-11-29 17:28 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: cris-axis-elf
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-11-10 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Peter Nilsson 2011-11-08 19:48:04 UTC
These tests previously passed, now they fail.
Apparently the "cxx-mem-model merge [6 of 9]" (formally a change in the range 181027:181034) exposed or caused these regressions.  Since then they fail as follows:

Running /tmp/hpautotest-gcc1/gcc/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp ...
...
FAIL: 29_atomics/atomic_flag/clear/1.cc (test for excess errors)
WARNING: 29_atomics/atomic_flag/clear/1.cc compilation failed to produce executable
FAIL: 29_atomics/atomic_flag/test_and_set/explicit.cc (test for excess errors)
WARNING: 29_atomics/atomic_flag/test_and_set/explicit.cc compilation failed to produce executable
FAIL: 29_atomics/atomic_flag/test_and_set/implicit.cc (test for excess errors)


The messages in libstdc++.log are similar, but have changed since the above. At r181162 they are as follows:

Executing on host: /tmp/hpautotest-gcc1/cris-elf/gccobj/./gcc/g++ -shared-libgcc -B/tmp/hpautotest-gcc1/cris-elf/gccobj/./gcc -nostdinc++ -L/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libstdc++-v3/src -L/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libstdc++-v3/src/.libs -nostdinc -B/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/newlib/ -isystem /tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/newlib/targ-include -isystem /tmp/hpautotest-gcc1/gcc/newlib/libc/include -B/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libgloss/cris -L/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libgloss/libnosys -L/tmp/hpautotest-gcc1/gcc/libgloss/cris -B/tmp/hpautotest-gcc1/cris-elf/pre/cris-elf/bin/ -B/tmp/hpautotest-gcc1/cris-elf/pre/cris-elf/lib/ -isystem /tmp/hpautotest-gcc1/cris-elf/pre/cris-elf/include -isystem /tmp/hpautotest-gcc1/cris-elf/pre/cris-elf/sys-include -B/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./libgloss/cris/ -L/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./libgloss/cris -L/tmp/hpautotest-gcc1/gcc/libgloss/cris -B/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./libstdc++-v3/src/.libs -g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0 -ffunction-sections -fdata-sections -g -O2 -g -O2 -DLOCALEDIR="." -nostdinc++ -I/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libstdc++-v3/include/cris-elf -I/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libstdc++-v3/include -I/tmp/hpautotest-gcc1/gcc/libstdc++-v3/libsupc++ -I/tmp/hpautotest-gcc1/gcc/libstdc++-v3/include/backward -I/tmp/hpautotest-gcc1/gcc/libstdc++-v3/testsuite/util /tmp/hpautotest-gcc1/gcc/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc   -std=gnu++0x ./libtestc++.a    -isystem /tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./newlib/targ-include -isystem /tmp/hpautotest-gcc1/gcc/newlib/libc/include -B/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./libgloss/cris/ -L/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./libgloss/cris -L/tmp/hpautotest-gcc1/gcc/libgloss/cris  -B/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./newlib/ -L/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./newlib -sim3  -lm   -o ./1.exe    (timeout = 600)
/tmp/ccX4JE6W.o: In function `ZNSt11atomic_flag5clearESt12memory_order':
/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libstdc++-v3/include/bits/atomic_base.h:311: undefined reference to `std::atomic_thread_fence(std::memory_order)'
/tmp/ccX4JE6W.o: In function `ZNSt11atomic_flag12test_and_setESt12memory_order':
/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libstdc++-v3/include/bits/atomic_base.h:274: undefined reference to `__sync_lock_test_and_set_1'
collect2: error: ld returned 1 exit status
compiler exited with status 1
output is:
/tmp/ccX4JE6W.o: In function `ZNSt11atomic_flag5clearESt12memory_order':
/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libstdc++-v3/include/bits/atomic_base.h:311: undefined reference to `std::atomic_thread_fence(std::memory_order)'
/tmp/ccX4JE6W.o: In function `ZNSt11atomic_flag12test_and_setESt12memory_order':
/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/libstdc++-v3/include/bits/atomic_base.h:274: undefined reference to `__sync_lock_test_and_set_1'
collect2: error: ld returned 1 exit status

with the 29_atomics/atomic_flag/test_and_set/explicit.cc test only having the last undefined reference.

Author of the suspect patches in the revision range CC:ed.

cris-elf does not have any back-end atomicity support patterns specified, there's just the libstdc++-v3/config/cpu/cris atomicity header files, apparently obsoleted by the cxx-mem-model merge.
Comment 1 Andrew Macleod 2011-11-10 16:21:44 UTC
The issue here is no atomic support whatsoever.  The standard now *requires* that atomic_flag be implementable in a lock free manner for compliance.

In order to support atomic_flag in a lock free manner on a target, we need at a minimum the legacy __sync_lock_test_and_set and __sync_lock_release to be implemented.

Previous to this release, if atomic_flag couldn't be implemented lock free, it was implemented with locks.  libstdc++-v3 no longer supports any locked implementations.
Comment 2 Andrew Macleod 2011-11-10 20:38:46 UTC
Author: amacleod
Date: Thu Nov 10 20:38:33 2011
New Revision: 181271

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181271
Log:
	PR middle-end/51038

	libstdc++-v3
	* include/bits/atomic_base.h (atomic_thread_fence): Call built-in.
	(atomic_signal_fence): Call built-in.
	(test_and_set, clear): Call new atomic built-ins.

	gcc
	* builtins.c (expand_builtin_atomic_clear): New.  Expand atomic_clear.
	(expand_builtin_atomic_test_and_set): New.  Expand atomic test_and_set.
	(expand_builtin): Add cases for test_and_set and clear.
	* sync-builtins.def (BUILT_IN_ATOMIC_TEST_AND_SET): New.
	(BUILT_IN_ATOMIC_CLEAR): New.

	testsuite
	* gcc.dg/atomic-invalid.c: Add test for invalid __atomic_clear models.
	* gcc.dg/atomic-flag.c: New.  Test __atomic_test_and_set and
	__atomic_clear.


Added:
    trunk/gcc/testsuite/gcc.dg/atomic-flag.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/sync-builtins.def
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/atomic-invalid.c
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/atomic_base.h
Comment 3 Jakub Jelinek 2011-11-29 15:38:46 UTC
Is this now fixed (and thus, can this bug be closed)?
Comment 4 Hans-Peter Nilsson 2011-11-29 17:28:48 UTC
(In reply to comment #3)
> Is this now fixed (and thus, can this bug be closed)?

Yes, done.  Thanks for the reminder.