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
```
  • [Bug c++/100641] New: Link erro... mfarazma.ext at gmail dot com via Gcc-bugs

Reply via email to