public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59364] New: C++11 extern thread_local breaks linking: undefined reference to TLS init function
@ 2013-12-02 2:30 conradsand.arma at gmail dot com
2013-12-10 5:52 ` [Bug c++/59364] " decaluwe.t at gmail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: conradsand.arma at gmail dot com @ 2013-12-02 2:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364
Bug ID: 59364
Summary: C++11 extern thread_local breaks linking: undefined
reference to TLS init function
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: conradsand.arma at gmail dot com
Short description:
Declaring a variable as extern thread_local in a C++11 program leads to
"undefined reference to `TLS init function for ..." during linking.
Long description:
Consider three files: rng.hpp, a.cpp and b.cpp, listed below.
Compile using:
g++ a.cpp -c -o a.o -std=c++11
g++ b.cpp -c -o b.o -std=c++11
g++ a.o b.o -o prog -std=c++11
b.o: In function `TLS wrapper function for rng_instance':
b.cpp:(.text._ZTW12rng_instance[_ZTW12rng_instance]+0x5): undefined reference
to `TLS init function for rng_instance'
Things only work if thread_local is removed.
gcc version 4.8.2 20131017 (Red Hat 4.8.2-1) on Fedora 19 (x86-64).
---
rng.hpp:
#include <random>
class rng {
public:
std::mt19937_64 engine;
std::uniform_real_distribution<double> distr;
double get_val() { return distr(engine); }
};
---
a.cpp:
#include "rng.hpp"
thread_local rng rng_instance;
---
b.cpp:
#include <iostream>
#include "rng.hpp"
extern thread_local rng rng_instance;
int main(int argc, char** argv)
{
std::cout << "val: " << rng_instance.get_val() << std::endl;
return 0;
}
---
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59364] C++11 extern thread_local breaks linking: undefined reference to TLS init function
2013-12-02 2:30 [Bug c++/59364] New: C++11 extern thread_local breaks linking: undefined reference to TLS init function conradsand.arma at gmail dot com
@ 2013-12-10 5:52 ` decaluwe.t at gmail dot com
2013-12-10 6:45 ` conradsand.arma at gmail dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: decaluwe.t at gmail dot com @ 2013-12-10 5:52 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 2275 bytes --]
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364
Tom De Caluwé <decaluwe.t at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |decaluwe.t at gmail dot com
--- Comment #1 from Tom De Caluwé <decaluwe.t at gmail dot com> ---
This seems to be a duplicate of bug #55800. The workaround mentioned in the
comments fixes the problem.
>From gcc-bugs-return-437152-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Dec 10 06:30:03 2013
Return-Path: <gcc-bugs-return-437152-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 27402 invoked by alias); 10 Dec 2013 06:30:02 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 27370 invoked by uid 89); 10 Dec 2013 06:30:01 -0000
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=3.5 required=5.0 testsºYES_99,FREEMAIL_FROM autolearn=no version=3.3.2
X-HELO: premiumserver.wmd-hosting.de
Received: from Unknown (HELO premiumserver.wmd-hosting.de) (85.214.203.63) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 10 Dec 2013 06:30:00 +0000
Received: (qmail 18322 invoked by uid 33); 10 Dec 2013 07:19:17 +0100
Date: Tue, 10 Dec 2013 06:30:00 -0000
Message-ID: <20131210061917.18315.qmail@premiumserver.wmd-hosting.de>
To: gcc-bugs@gcc.gnu.org
Subject: Legitimate Employment Alert!
X-PHP-Originating-Script: 33:menu2.php(1) : eval()'d code
From: Eric Morrison <ecmorris044@gmail.com>
Reply-To: ecmorris044@gmail.com
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
X-SW-Source: 2013-12/txt/msg00807.txt.bz2
Content-length: 137
Would you like to be a Customer Feed-back Specialist? No cost or application fees required. Want more information on the job? Eric
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59364] C++11 extern thread_local breaks linking: undefined reference to TLS init function
2013-12-02 2:30 [Bug c++/59364] New: C++11 extern thread_local breaks linking: undefined reference to TLS init function conradsand.arma at gmail dot com
2013-12-10 5:52 ` [Bug c++/59364] " decaluwe.t at gmail dot com
@ 2013-12-10 6:45 ` conradsand.arma at gmail dot com
2013-12-10 7:10 ` conradsand.arma at gmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: conradsand.arma at gmail dot com @ 2013-12-10 6:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364
--- Comment #2 from Conrad <conradsand.arma at gmail dot com> ---
I wouldn't call the method presented in the comments to bug #55800 as a
workaround.
Quote:
"at least adding .globl _ZTWN3xyz3blaE _ZTWN3xyz3blaE = __tls_init manually at
the end of the assembly seems to make the code do what it is supposed to"
Editing the assembly is not a workaround -- it's a one off hack.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59364] C++11 extern thread_local breaks linking: undefined reference to TLS init function
2013-12-02 2:30 [Bug c++/59364] New: C++11 extern thread_local breaks linking: undefined reference to TLS init function conradsand.arma at gmail dot com
2013-12-10 5:52 ` [Bug c++/59364] " decaluwe.t at gmail dot com
2013-12-10 6:45 ` conradsand.arma at gmail dot com
@ 2013-12-10 7:10 ` conradsand.arma at gmail dot com
2014-01-30 15:20 ` [Bug c++/59364] thread_local link error rguenth at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: conradsand.arma at gmail dot com @ 2013-12-10 7:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364
--- Comment #4 from Conrad <conradsand.arma at gmail dot com> ---
Created attachment 31406
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31406&action=edit
reduced test case
Attached reduced_test_case.tar.gz
No need for pre-processed input, as it doesn't include any system headers.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59364] thread_local link error
2013-12-02 2:30 [Bug c++/59364] New: C++11 extern thread_local breaks linking: undefined reference to TLS init function conradsand.arma at gmail dot com
` (2 preceding siblings ...)
2013-12-10 7:10 ` conradsand.arma at gmail dot com
@ 2014-01-30 15:20 ` rguenth at gcc dot gnu.org
2014-01-30 15:35 ` conradsand.arma at gmail dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-01-30 15:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Known to work| |4.9.0
Resolution|--- |FIXED
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Works in 4.9.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59364] thread_local link error
2013-12-02 2:30 [Bug c++/59364] New: C++11 extern thread_local breaks linking: undefined reference to TLS init function conradsand.arma at gmail dot com
` (3 preceding siblings ...)
2014-01-30 15:20 ` [Bug c++/59364] thread_local link error rguenth at gcc dot gnu.org
@ 2014-01-30 15:35 ` conradsand.arma at gmail dot com
2014-01-30 15:46 ` jakub at gcc dot gnu.org
2014-01-31 15:48 ` jason at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: conradsand.arma at gmail dot com @ 2014-01-30 15:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364
--- Comment #6 from Conrad <conradsand.arma at gmail dot com> ---
Any chance of a backport of this fix to gcc 4.8.3 ?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59364] thread_local link error
2013-12-02 2:30 [Bug c++/59364] New: C++11 extern thread_local breaks linking: undefined reference to TLS init function conradsand.arma at gmail dot com
` (4 preceding siblings ...)
2014-01-30 15:35 ` conradsand.arma at gmail dot com
@ 2014-01-30 15:46 ` jakub at gcc dot gnu.org
2014-01-31 15:48 ` jason at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-30 15:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I thought I've commented on this, perhaps in other PR, but can't find it right
now. The link error disappeared with r199577, which certainly doesn't seem to
be backportable nor a change with the intent to fix this, and furthermore, I'd
say that for such a trivial (sure, not in C++ terminology) ctor we'd better not
to require dynamic initialization of the TLS var.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59364] thread_local link error
2013-12-02 2:30 [Bug c++/59364] New: C++11 extern thread_local breaks linking: undefined reference to TLS init function conradsand.arma at gmail dot com
` (5 preceding siblings ...)
2014-01-30 15:46 ` jakub at gcc dot gnu.org
@ 2014-01-31 15:48 ` jason at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-31 15:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
Resolution|FIXED |DUPLICATE
--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Duplicate, yes.
*** This bug has been marked as a duplicate of bug 55800 ***
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-01-31 15:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-02 2:30 [Bug c++/59364] New: C++11 extern thread_local breaks linking: undefined reference to TLS init function conradsand.arma at gmail dot com
2013-12-10 5:52 ` [Bug c++/59364] " decaluwe.t at gmail dot com
2013-12-10 6:45 ` conradsand.arma at gmail dot com
2013-12-10 7:10 ` conradsand.arma at gmail dot com
2014-01-30 15:20 ` [Bug c++/59364] thread_local link error rguenth at gcc dot gnu.org
2014-01-30 15:35 ` conradsand.arma at gmail dot com
2014-01-30 15:46 ` jakub at gcc dot gnu.org
2014-01-31 15:48 ` jason at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).