diff mbox

libstdc++/70503 Ensure std::thread helpers have internal linkage

Message ID 20160405172341.GI5814@redhat.com
State New
Headers show

Commit Message

Jonathan Wakely April 5, 2016, 5:23 p.m. UTC
On 05/04/16 14:37 +0100, Jonathan Wakely wrote:
>    Ensure std::thread helpers have internal linkage
>    
>    	PR libstdc++/70503
>    	* src/c++11/thread.cc (execute_native_thread_routine,
>    	execute_native_thread_routine_compat): Give internal linkage.
>    	* testsuite/30_threads/thread/70503.cc: New test.

This small tweak to the new test checks that -static works before
trying to run it.

Tested x86_64-linux, with and without static glibc installed.

Committed to trunk.

Comments

Tom de Vries April 7, 2016, 1:27 p.m. UTC | #1
Hi,

FYI, this testcase fails for me as follows:
...
/usr/bin/ld: Dwarf Error: found dwarf version '4', this reader only 
handles version 2 and 3 information.^M
/tmp/ccMBMHB5.o: In function `main':^M
70503.cc:(.text.startup.main+0x5): undefined reference to 
`execute_native_thread_routine'^M
/usr/bin/ld: Dwarf Error: found dwarf version '0', this reader only 
handles version 2 and 3 information.^M
70503.cc:(.text.startup.main+0xa): undefined reference to 
`execute_native_thread_routine_compat'^M
collect2: error: ld returned 1 exit status^M
compiler exited with status 1
output is:
/usr/bin/ld: Dwarf Error: found dwarf version '4', this reader only 
handles version 2 and 3 information.^M
/tmp/ccMBMHB5.o: In function `main':^M
70503.cc:(.text.startup.main+0x5): undefined reference to 
`execute_native_thread_routine'^M
/usr/bin/ld: Dwarf Error: found dwarf version '0', this reader only 
handles version 2 and 3 information.^M
70503.cc:(.text.startup.main+0xa): undefined reference to 
`execute_native_thread_routine_compat'^M
collect2: error: ld returned 1 exit status^M

FAIL: 30_threads/thread/70503.cc  (test for errors, line 31)
FAIL: 30_threads/thread/70503.cc  (test for errors, line 32)
FAIL: 30_threads/thread/70503.cc (test for excess errors)
...

$ /usr/bin/ld -v
GNU ld (GNU Binutils for Ubuntu) 2.20.1-system.20100303

$ cat /etc/issue
Ubuntu 10.04.4 LTS \n \l

Thanks,
- Tom

On 05/04/16 19:23, Jonathan Wakely wrote:
> On 05/04/16 14:37 +0100, Jonathan Wakely wrote:
>>    Ensure std::thread helpers have internal linkage
>>        PR libstdc++/70503
>>        * src/c++11/thread.cc (execute_native_thread_routine,
>>        execute_native_thread_routine_compat): Give internal linkage.
>>        * testsuite/30_threads/thread/70503.cc: New test.
>
> This small tweak to the new test checks that -static works before
> trying to run it.
>
> Tested x86_64-linux, with and without static glibc installed.
>
> Committed to trunk.
>
> patch.txt
>
>
> commit 1fdc9bbe912281ba6d573fc28c53817402656e57
> Author: Jonathan Wakely <jwakely@redhat.com>
> Date:   Tue Apr 5 18:18:36 2016 +0100
>
>      	* testsuite/30_threads/thread/70503.cc: Require -static to work.
>
> diff --git a/libstdc++-v3/testsuite/30_threads/thread/70503.cc b/libstdc++-v3/testsuite/30_threads/thread/70503.cc
> index 1763ac2..950d754 100644
> --- a/libstdc++-v3/testsuite/30_threads/thread/70503.cc
> +++ b/libstdc++-v3/testsuite/30_threads/thread/70503.cc
> @@ -19,6 +19,7 @@
>   // { dg-options " -std=gnu++11 -static" { target *-*-*gnu* } }
>   // { dg-require-cstdint "" }
>   // { dg-require-gthreads "" }
> +// { dg-require-effective-target static }
>
>   extern "C" {
>     void execute_native_thread_routine(void);
>
Jonathan Wakely April 7, 2016, 1:34 p.m. UTC | #2
On 07/04/16 15:27 +0200, Tom de Vries wrote:
>Hi,
>
>FYI, this testcase fails for me as follows:
>...
>/usr/bin/ld: Dwarf Error: found dwarf version '4', this reader only 
>handles version 2 and 3 information.^M
>/tmp/ccMBMHB5.o: In function `main':^M
>70503.cc:(.text.startup.main+0x5): undefined reference to 
>`execute_native_thread_routine'^M
>/usr/bin/ld: Dwarf Error: found dwarf version '0', this reader only 
>handles version 2 and 3 information.^M
>70503.cc:(.text.startup.main+0xa): undefined reference to 
>`execute_native_thread_routine_compat'^M
>collect2: error: ld returned 1 exit status^M
>compiler exited with status 1
>output is:
>/usr/bin/ld: Dwarf Error: found dwarf version '4', this reader only 
>handles version 2 and 3 information.^M
>/tmp/ccMBMHB5.o: In function `main':^M
>70503.cc:(.text.startup.main+0x5): undefined reference to 
>`execute_native_thread_routine'^M
>/usr/bin/ld: Dwarf Error: found dwarf version '0', this reader only 
>handles version 2 and 3 information.^M
>70503.cc:(.text.startup.main+0xa): undefined reference to 
>`execute_native_thread_routine_compat'^M
>collect2: error: ld returned 1 exit status^M
>
>FAIL: 30_threads/thread/70503.cc  (test for errors, line 31)
>FAIL: 30_threads/thread/70503.cc  (test for errors, line 32)
>FAIL: 30_threads/thread/70503.cc (test for excess errors)

Hmm, I'm not sure whether it's better to use -gdwarf-2 or add
{ dg-prune-output "dwarf version" }
Jakub Jelinek April 7, 2016, 1:42 p.m. UTC | #3
On Thu, Apr 07, 2016 at 02:34:51PM +0100, Jonathan Wakely wrote:
> On 07/04/16 15:27 +0200, Tom de Vries wrote:
> >FYI, this testcase fails for me as follows:
> >...
> >/usr/bin/ld: Dwarf Error: found dwarf version '4', this reader only
> >handles version 2 and 3 information.^M
> >/tmp/ccMBMHB5.o: In function `main':^M
> >70503.cc:(.text.startup.main+0x5): undefined reference to
> >`execute_native_thread_routine'^M
> >/usr/bin/ld: Dwarf Error: found dwarf version '0', this reader only
> >handles version 2 and 3 information.^M
> >70503.cc:(.text.startup.main+0xa): undefined reference to
> >`execute_native_thread_routine_compat'^M
> >collect2: error: ld returned 1 exit status^M
> >compiler exited with status 1
> >output is:
> >/usr/bin/ld: Dwarf Error: found dwarf version '4', this reader only
> >handles version 2 and 3 information.^M
> >/tmp/ccMBMHB5.o: In function `main':^M
> >70503.cc:(.text.startup.main+0x5): undefined reference to
> >`execute_native_thread_routine'^M
> >/usr/bin/ld: Dwarf Error: found dwarf version '0', this reader only
> >handles version 2 and 3 information.^M
> >70503.cc:(.text.startup.main+0xa): undefined reference to
> >`execute_native_thread_routine_compat'^M
> >collect2: error: ld returned 1 exit status^M
> >
> >FAIL: 30_threads/thread/70503.cc  (test for errors, line 31)
> >FAIL: 30_threads/thread/70503.cc  (test for errors, line 32)
> >FAIL: 30_threads/thread/70503.cc (test for excess errors)
> 
> Hmm, I'm not sure whether it's better to use -gdwarf-2 or add
> { dg-prune-output "dwarf version" }

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.

	Jakub
diff mbox

Patch

commit 1fdc9bbe912281ba6d573fc28c53817402656e57
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Apr 5 18:18:36 2016 +0100

    	* testsuite/30_threads/thread/70503.cc: Require -static to work.

diff --git a/libstdc++-v3/testsuite/30_threads/thread/70503.cc b/libstdc++-v3/testsuite/30_threads/thread/70503.cc
index 1763ac2..950d754 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/70503.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/70503.cc
@@ -19,6 +19,7 @@ 
 // { dg-options " -std=gnu++11 -static" { target *-*-*gnu* } }
 // { dg-require-cstdint "" }
 // { dg-require-gthreads "" }
+// { dg-require-effective-target static }
 
 extern "C" {
   void execute_native_thread_routine(void);