On 04/27/2014 03:01 PM, Sebastian Huber wrote:
Hallo,
I would like to add a test case to the libstdc++ tests to test for
C/C++ compatibility of the atomic operations. A straight forward
approach like in the attached patch doesn't work since the
"dg-additional-sources" is not supported:
ERROR: 29_atomics/atomic/pr60932-c++.cc: unknown dg option:
dg-additional-sources 3 pr60932-c.c for " dg-additional-sources 3
"pr60932-c.c" "
UNRESOLVED: 29_atomics/atomic/pr60932-c++.cc: unknown dg option:
dg-additional-sources 3 pr60932-c.c for " dg-additional-sources 3
"pr60932-c.c" "
Since I am not an expert in the GCC test suite scripts, is it possible
to add such a test case at all with a moderate amount of work?
Since this patch
2014-05-20 Sebastian Huber <sebastian.hu...@embedded-brains.de>
* testsuite/lib/libstdc++.exp (load_gcc_lib): Register loaded libs.
I am one step further. The dg-additional-sources is recognized in the
attached test case, but it seems to have no effect:
Executing on host: /home/sh/git-build/b-gcc-devel-linux/./gcc/xg++
-shared-libgcc -B/home/sh/git-build/b-gcc-devel-linux/./gcc -nostdinc++
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs
-B/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/bin/
-B/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/lib/ -isystem
/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/include -isystem
/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/sys-include
-B/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/./libstdc++-v3/src/.libs
-fdiagnostics-color=never -D_GLIBCXX_ASSERT -fmessage-length=0
-ffunction-sections -fdata-sections -g -O2 -DLOCALEDIR="." -nostdinc++
-I/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
-I/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include
-I/home/sh/archive/gcc-devel/libstdc++-v3/libsupc++
-I/home/sh/archive/gcc-devel/libstdc++-v3/include/backward
-I/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/util
/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc
-std=c++11 ./libtestc++.a -Wl,--gc-sections -lm -o
./pr60932-c++.exe (timeout = 600)
spawn /home/sh/git-build/b-gcc-devel-linux/./gcc/xg++ -shared-libgcc
-B/home/sh/git-build/b-gcc-devel-linux/./gcc -nostdinc++
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs
-B/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/bin/
-B/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/lib/ -isystem
/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/include -isystem
/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/sys-include
-B/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/./libstdc++-v3/src/.libs
-fdiagnostics-color=never -D_GLIBCXX_ASSERT -fmessage-length=0
-ffunction-sections -fdata-sections -g -O2 -DLOCALEDIR="." -nostdinc++
-I/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
-I/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include
-I/home/sh/archive/gcc-devel/libstdc++-v3/libsupc++
-I/home/sh/archive/gcc-devel/libstdc++-v3/include/backward
-I/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/util
/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc
-std=c++11 ./libtestc++.a -Wl,--gc-sections -lm -o ./pr60932-c++.exe
/tmp/ccN0vuIk.o: In function `main':
/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc:12:
undefined reference to `i'
collect2: error: ld returned 1 exit status
compiler exited with status 1
output is:
/tmp/ccN0vuIk.o: In function `main':
/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc:12:
undefined reference to `i'
collect2: error: ld returned 1 exit status
FAIL: 29_atomics/atomic/pr60932-c++.cc (test for excess errors)
Excess errors:
/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc:12:
undefined reference to `i'
collect2: error: ld returned 1 exit status
extra_tool_flags are:
-x c -std=c11
compiling and executing as C, not C++
Executing on host: /home/sh/git-build/b-gcc-devel-linux/./gcc/xgcc
-B/home/sh/git-build/b-gcc-devel-linux/./gcc/
-B/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/bin/
-B/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/lib/ -isystem
/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/include -isystem
/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/sys-include
-B/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/./libstdc++-v3/src/.libs
-fdiagnostics-color=never -D_GLIBCXX_ASSERT -fmessage-length=0
-ffunction-sections -fdata-sections -g -O2 -DLOCALEDIR="."
-I/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
-I/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include
-I/home/sh/archive/gcc-devel/libstdc++-v3/libsupc++
-I/home/sh/archive/gcc-devel/libstdc++-v3/include/backward
-I/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/util
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/./libstdc++-v3/libsupc++/.libs
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/./libstdc++-v3/src/.libs
/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c.c
-std=c11 -S -o pr60932-c.s (timeout = 600)
spawn /home/sh/git-build/b-gcc-devel-linux/./gcc/xgcc
-B/home/sh/git-build/b-gcc-devel-linux/./gcc/
-B/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/bin/
-B/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/lib/ -isystem
/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/include -isystem
/scratch/install-gcc-devel/x86_64-unknown-linux-gnu/sys-include
-B/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/./libstdc++-v3/src/.libs
-fdiagnostics-color=never -D_GLIBCXX_ASSERT -fmessage-length=0
-ffunction-sections -fdata-sections -g -O2 -DLOCALEDIR="."
-I/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
-I/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include
-I/home/sh/archive/gcc-devel/libstdc++-v3/libsupc++
-I/home/sh/archive/gcc-devel/libstdc++-v3/include/backward
-I/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/util
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/./libstdc++-v3/libsupc++/.libs
-L/home/sh/git-build/b-gcc-devel-linux/x86_64-unknown-linux-gnu/./libstdc++-v3/src/.libs
/home/sh/archive/gcc-devel/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c.c
-std=c11 -S -o pr60932-c.s
PASS: 29_atomics/atomic/pr60932-c.c (test for excess errors)
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>From 098a104446996061ac19c9707fbd400a885cb900 Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.hu...@embedded-brains.de>
Date: Sun, 27 Apr 2014 14:08:19 +0200
Subject: [PATCH] PR60932 test case
---
libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc | 12 ++++++++++++
libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c.c | 6 ++++++
libstdc++-v3/testsuite/29_atomics/atomic/pr60932.h | 6 ++++++
libstdc++-v3/testsuite/lib/libstdc++.exp | 1 +
4 files changed, 25 insertions(+)
create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc
create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c.c
create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/pr60932.h
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc b/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc
new file mode 100644
index 0000000..516c09b
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c++.cc
@@ -0,0 +1,12 @@
+// { dg-do link }
+// { dg-options "-std=c++11" }
+// { dg-additional-sources "pr60932-c.c" }
+
+#include "pr60932.h"
+
+extern "C" int i;
+
+int main()
+{
+ return i;
+}
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c.c b/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c.c
new file mode 100644
index 0000000..28a7f82
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/pr60932-c.c
@@ -0,0 +1,6 @@
+// { dg-do compile }
+// { dg-options "-x c -std=c11" }
+
+#include "pr60932.h"
+
+int i;
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/pr60932.h b/libstdc++-v3/testsuite/29_atomics/atomic/pr60932.h
new file mode 100644
index 0000000..c92cbd8
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/pr60932.h
@@ -0,0 +1,6 @@
+#ifdef __cplusplus
+#include <atomic>
+using namespace std;
+#else
+#include <stdatomic.h>
+#endif
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index d91bed6..adf4f97 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -57,6 +57,7 @@ load_gcc_lib target-libpath.exp
load_gcc_lib timeout.exp
load_gcc_lib timeout-dg.exp
load_gcc_lib wrapper.exp
+load_gcc_lib gcc-defs.exp
# Useful for debugging. Pass the name of a variable and the verbosity
# threshold (number of -v's on the command line).
--
1.8.1.4