public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100641] New: Link error when using extern thread_local variables on AIX
@ 2021-05-17 19:19 mfarazma.ext at gmail dot com
  2021-05-17 19:21 ` [Bug c++/100641] " mfarazma.ext at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mfarazma.ext at gmail dot com @ 2021-05-17 19:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100641

            Bug ID: 100641
           Summary: Link error when using extern thread_local variables on
                    AIX
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mfarazma.ext at gmail dot com
  Target Milestone: ---

Declaring a variable as "extern thread_local" in a C++ program leads to:

"ERROR: Undefined symbol: TLS init function for ..." during linking.

To reproduce:

file `0.cc`:
```
extern thread_local int foo;

int main(){
 return foo;
}
```

file `1.cc`:
```
thread_local int foo = 1; 
```

Then compile with `g++ 0.cc 1.cc` which produces this error:
```
ld: 0711-317 ERROR: Undefined symbol: TLS init function for foo
ld: 0711-317 ERROR: Undefined symbol: .TLS init function for foo
ld: 0711-317 ERROR: Undefined symbol: __get_tpointer
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
```

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/100641] Link error when using extern thread_local variables on AIX
  2021-05-17 19:19 [Bug c++/100641] New: Link error when using extern thread_local variables on AIX mfarazma.ext at gmail dot com
@ 2021-05-17 19:21 ` mfarazma.ext at gmail dot com
  2022-03-20 21:59 ` [Bug target/100641] " hstong at ca dot ibm.com
  2024-04-06  5:39 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mfarazma.ext at gmail dot com @ 2021-05-17 19:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100641

--- Comment #1 from m farazma <mfarazma.ext at gmail dot com> ---
Issue seems to be similar to this older gcc bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/100641] Link error when using extern thread_local variables on AIX
  2021-05-17 19:19 [Bug c++/100641] New: Link error when using extern thread_local variables on AIX mfarazma.ext at gmail dot com
  2021-05-17 19:21 ` [Bug c++/100641] " mfarazma.ext at gmail dot com
@ 2022-03-20 21:59 ` hstong at ca dot ibm.com
  2024-04-06  5:39 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: hstong at ca dot ibm.com @ 2022-03-20 21:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100641

Hubert Tong <hstong at ca dot ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hstong at ca dot ibm.com

--- Comment #2 from Hubert Tong <hstong at ca dot ibm.com> ---
This was addressed in Clang last year. The AIX linker does not have the same
weak reference semantics as some other linkers. The means that the TLS init
function needs to be defined by the object file containing the definition of
the `thread_local` variable if the language semantics does not make it so that
all potential references occur in contexts where it is known that the
initialization/finalization is constant.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/100641] Link error when using extern thread_local variables on AIX
  2021-05-17 19:19 [Bug c++/100641] New: Link error when using extern thread_local variables on AIX mfarazma.ext at gmail dot com
  2021-05-17 19:21 ` [Bug c++/100641] " mfarazma.ext at gmail dot com
  2022-03-20 21:59 ` [Bug target/100641] " hstong at ca dot ibm.com
@ 2024-04-06  5:39 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-06  5:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100641

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup.

*** This bug has been marked as a duplicate of bug 93146 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-06  5:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 19:19 [Bug c++/100641] New: Link error when using extern thread_local variables on AIX mfarazma.ext at gmail dot com
2021-05-17 19:21 ` [Bug c++/100641] " mfarazma.ext at gmail dot com
2022-03-20 21:59 ` [Bug target/100641] " hstong at ca dot ibm.com
2024-04-06  5:39 ` pinskia 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).