Skip to content

Linking error occurs if the size of TLS exceeds 16MB(24bit) #39511

@mueno-fj

Description

@mueno-fj
mannequin
Bugzilla Link 40164
Version unspecified
OS Linux

Extended Description

Are you planning to support options like GCC's -mtls-size={12|24|32|48} option?

If the size of TLS exceeds 16MB(24bit), a linking error occurs on ARM machine
since it is limited to 16MB(24bit).
This problem was found in NPB(NAS Parallel Benchmarks).
In this case, it occurred in OpenMP's threadprivate, but it also occurs in C's __thread.

GCC has -mtls-size={12|24|32|48} option. And this option changes the bit size of the offset
used for thread-local storage to the specified value. GCC compiller resolve it by attaching this option.

Are you planning to support options equivalent to GCC's -mtls-size option?

The compiling logs of clang and gcc are shown below.

$ cat test.c
static char aaa[16777216];
static char bbb[16777216];
#pragma omp threadprivate(aaa,bbb)
int main() {
  aaa[0]=1;
  bbb[0]=1;
  return 0;
}

[ clang ]

$ clang test.c -fopenmp
/tmp/test-1ce537.o: In function `TLS wrapper function for bbb':
test.c:(.text+0x5c): relocation truncated to fit: R_AARCH64_TLSLE_ADD_TPREL_HI12 against `bbb'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

[ GCC ]

$ gcc-8.2.0 test.c -fopenmp
/tmp/ccAeNf3i.o: In function `main':
test.c:(.text+0x18): relocation truncated to fit: R_AARCH64_TLSLE_ADD_TPREL_HI12 against `bbb'
collect2: error: ld returned 1 exit status

$ gcc-8.2.0 test.c -fopenmp -mtls-size=48
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions