This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] libstdc++/70503 Ensure std::thread helpers have internal linkage
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Tom de Vries <Tom_deVries at mentor dot com>, libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 7 Apr 2016 15:27:01 +0100
- Subject: Re: [patch] libstdc++/70503 Ensure std::thread helpers have internal linkage
- Authentication-results: sourceware.org; auth=none
- References: <20160405133701 dot GH5814 at redhat dot com> <20160405172341 dot GI5814 at redhat dot com> <5706604E dot 7050306 at mentor dot com> <20160407133451 dot GT5814 at redhat dot com> <20160407134203 dot GH19207 at tucnak dot redhat dot com>
On 07/04/16 15:42 +0200, Jakub Jelinek wrote:
Or perhaps instead change the test, so that instead of testing for
undefined symbols it provides some definition of those 2 symbols
and makes sure libstdc++.a(thread.o) is linked in too (such as
using std::thread::detach or similar somewhere).
Then in the buggy libstdc++ case, because those old definitions
were strong rather than weak, it should fail to link, while with
fixed libstdc++ succeed.
That'll work. Tested x86_64-linux, committed to trunk.
commit 0f47894e015b05f43391a353777a2ad5b74c05fa
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Apr 7 15:25:47 2016 +0100
* testsuite/30_threads/thread/70503.cc: Adjust from xfail to pass.
diff --git a/libstdc++-v3/testsuite/30_threads/thread/70503.cc b/libstdc++-v3/testsuite/30_threads/thread/70503.cc
index 950d754..3b64ef8 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/70503.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/70503.cc
@@ -16,19 +16,23 @@
// <http://www.gnu.org/licenses/>.
// { dg-do link }
-// { dg-options " -std=gnu++11 -static" { target *-*-*gnu* } }
+// { dg-options "-std=gnu++11 -static" { target *-*-*gnu* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// { dg-require-effective-target static }
+#include <thread>
+
extern "C" {
- void execute_native_thread_routine(void);
- void execute_native_thread_routine_compat(void);
+ // Should not get multiple definition errors from libstdc++.a(thread.o)
+ void execute_native_thread_routine(void) { }
+ void execute_native_thread_routine_compat(void) { }
}
int main()
{
- execute_native_thread_routine(); // { dg-error "undefined reference" }
- execute_native_thread_routine_compat(); // { dg-error "undefined reference" }
+ execute_native_thread_routine();
+ execute_native_thread_routine_compat();
+
+ std::thread{}.detach(); // ensure libstdc++.a(thread.o) is linked in
}
-// { dg-prune-output "collect2: error: ld returned" }