Bug 53895 - [4.7/4.8 Regression][lto] symbol 'std::__once_callable' used as both __thread and non-__thread
[4.7/4.8 Regression][lto] symbol 'std::__once_callable' used as both __thread...
Status: RESOLVED MOVED
Product: gcc
Classification: Unclassified
Component: lto
4.8.0
: P3 normal
: 4.7.3
Assigned To: Not yet assigned to anyone
: lto
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-09 04:59 UTC by vincenzo Innocente
Modified: 2013-01-01 05:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.7.1
Known to fail: 4.7.2
Last reconfirmed: 2012-07-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vincenzo Innocente 2012-07-09 04:59:24 UTC
I'm sure was working with 4.7.1
works with gcc version 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC) 

this is ok
c++ thread.cpp -pthread -std=gnu++0x -O2 
this is not
c++ thread.cpp -pthread -std=gnu++0x -O2 -flto
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: /afs/cern.ch/user/i/innocent/w3/gcc47slc5/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib64/libstdc++.so: symbol 'std::__once_call' used as both __thread and non-__thread
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: /tmp/innocent/ccd0XlxC.o: previous definition here
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: /afs/cern.ch/user/i/innocent/w3/gcc47slc5/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib64/libstdc++.so: symbol 'std::__once_callable' used as both __thread and non-__thread
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: /tmp/innocent/ccd0XlxC.o: previous definition here
collect2: error: ld returned 1 exit status

ld -v
GNU gold (GNU Binutils 2.22.52.20120515) 1.11
gcc version 4.7.2 20120629 (prerelease) [gcc-4_7-branch revision 189081] (GCC)
gcc version 4.8.0 20120623 (experimental) [trunk revision 188906] (GCC) 
gcc version 4.8.0 20120708 (experimental) [trunk revision 189362] (GCC) 


cat thread.cpp
include <iostream>
#include <sstream>
#include <vector>
#include <thread>
#include <mutex>
#include <future>
#include <atomic>
#include <functional>
#include <algorithm>

typedef std::thread Thread;
typedef std::vector<std::thread> ThreadGroup;
typedef std::mutex Mutex;
typedef std::unique_lock<std::mutex> Guard;
typedef std::condition_variable Condition;


long long threadId() {
  std::stringstream ss;
  ss << std::this_thread::get_id();
  long long id;
  ss >> id;
  return id; 
}


namespace global {
  // control cout....
  Mutex coutLock;
}


int main() {

  return 0;
}
Comment 1 H.J. Lu 2012-07-09 06:28:27 UTC
Does it work with BFD linker?
Comment 2 vincenzo Innocente 2012-07-09 12:20:41 UTC
yes it does
ld -v
GNU ld version 2.22.52.0.1-10.fc17 20120131
[innocent@pcphsftkepler bugs48]$ c++ thread.cpp -pthread -std=gnu++0x -O2 -flto -Wl,-v
collect2 version 4.8.0 20120623 (experimental) [trunk revision 188906]
/home/innocent/gccDir/bin/ld -plugin /home/innocent/gccDir/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/liblto_plugin.so -plugin-opt=/home/innocent/gccDir/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccm8JDgc.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /lib/../lib64/crt1.o /lib/../lib64/crti.o /home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/crtbegin.o -L/home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0 -L/home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../.. /tmp/ccUiBvi2.o -v -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/crtend.o /lib/../lib64/crtn.o
GNU ld version 2.22.52.0.1-10.fc17 20120131
[innocent@pcphsftkepler bugs48]$ mv  ~/gccDir/bin/ld.gold ~/gccDir/bin/ld     
[innocent@pcphsftkepler bugs48]$ c++ thread.cpp -pthread -std=gnu++0x -O2 -flto -Wl,-v
collect2 version 4.8.0 20120623 (experimental) [trunk revision 188906]
/home/innocent/gccDir/bin/ld -plugin /home/innocent/gccDir/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/liblto_plugin.so -plugin-opt=/home/innocent/gccDir/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccJLE7SG.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /lib/../lib64/crt1.o /lib/../lib64/crti.o /home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/crtbegin.o -L/home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0 -L/home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../.. /tmp/ccevajLa.o -v -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/crtend.o /lib/../lib64/crtn.o
GNU gold (version 2.22.52.0.1-10.fc17 20120131) 1.11
/home/innocent/gccDir/bin/ld: error: /home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../lib64/libstdc++.so: symbol 'std::__once_callable' used as both __thread and non-__thread
/home/innocent/gccDir/bin/ld: /tmp/ccevajLa.o: previous definition here
/home/innocent/gccDir/bin/ld: error: /home/innocent/gccDir/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../lib64/libstdc++.so: symbol 'std::__once_call' used as both __thread and non-__thread
/home/innocent/gccDir/bin/ld: /tmp/ccevajLa.o: previous definition here
collect2: error: ld returned 1 exit status


On 9 Jul, 2012, at 4:28 PM, hjl.tools at gmail dot com wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53895
> 
> H.J. Lu <hjl.tools at gmail dot com> changed:
> 
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>             Status|UNCONFIRMED                 |WAITING
>   Last reconfirmed|                            |2012-07-09
>     Ever Confirmed|0                           |1
> 
> --- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2012-07-09 06:28:27 UTC ---
> Does it work with BFD linker?
> 
> -- 
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.

--
Il est bon de suivre sa pente, pourvu que ce soit en montant. 
A.G.
http://www.flickr.com/photos/vin60/1320965757/
Comment 3 H.J. Lu 2012-07-09 13:15:34 UTC
(In reply to comment #2)
> yes it does
> ld -v
> GNU ld version 2.22.52.0.1-10.fc17 20120131
> [innocent@pcphsftkepler bugs48]$ c++ thread.cpp -pthread -std=gnu++0x -O2 -flto
> -Wl,-v

It sounds like a gold bug.
Comment 4 Marc Dietrich 2012-07-16 11:12:42 UTC
also triggered when compiling mesa with -ftlo:


g++ -O2 -Wall -std=c99 -Werror=implicit-function-declaration -Werror=missing-prototypes -fno-strict-aliasing -fno-builtin-memcmp -O2 -flto=jobserver -fPIC  -D_GNU_SOURCE -DPTHREADS -DTEXTURE_FLOAT_ENABLED -DUSE_X86_64_ASM -DHAVE_POSIX_MEMALIGN -DIN_DRI_DRIVER -DUSE_XCB -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DGLX_USE_TLS -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER -DHAVE_ALIAS -DHAVE_MINCORE -DHAVE_LIBUDEV -DHAVE_LLVM=0x0301 -fvisibility=hidden -o r600_dri.so.test ../../../../src/mesa/drivers/dri/common/dri_test.o r600_dri.so.tmp  ../../../../lib64/libdricore8.1.0.so  -ldrm   -lexpat -lm -lpthread -ldl -ldrm_radeon -march=barcelona -Ofast -flto=jobserver -L/usr/lib  -lpthread -ldl -lm ;
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: error: r600_dri.so.tmp: symbol '_glapi_tls_Context' used as both __thread and non-__thread
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: ../../../../src/mesa/drivers/dri/common/dri_test.o: previous definition here
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: error: r600_dri.so.tmp: symbol '_glapi_tls_Dispatch' used as both __thread and non-__thread
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: ../../../../src/mesa/drivers/dri/common/dri_test.o: previous definition here
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: error: ../../../../lib64/libdricore8.1.0.so: symbol '_glapi_tls_Context' used as both __thread and non-__thread
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: ../../../../src/mesa/drivers/dri/common/dri_test.o: previous definition here
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: error: ../../../../lib64/libdricore8.1.0.so: symbol '_glapi_tls_Dispatch' used as both __thread and non-__thread
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: ../../../../src/mesa/drivers/dri/common/dri_test.o: previous definition here

on openSUSE 12.2 (factory):
ld --version -> GNU gold (GNU Binutils; openSUSE Factory 2.22) 1.11
gcc --version -> gcc (SUSE Linux) 4.7.1 20120615 [gcc-4_7-branch revision 188649]
Comment 5 vincenzo Innocente 2012-08-15 06:58:49 UTC
btw I opened a gold bug
http://sourceware.org/bugzilla/show_bug.cgi?id=14342
which did not get any attention yet
Comment 6 Jakub Jelinek 2012-09-20 10:17:55 UTC
GCC 4.7.2 has been released.
Comment 7 Andrew Pinski 2013-01-01 05:27:49 UTC
Since a gold bug has been opened, closing this as moved.