[LLVMbugs] [Bug 9788] New: support for the four TLS models

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Apr 23 18:38:19 PDT 2011


           Summary: support for the four TLS models
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nobled at dreamwidth.org
                CC: llvmbugs at cs.uiuc.edu

test case:
$ cat tls.c
extern __thread int tls

$ clang -v -ftls-model=init-exec tls.c -c -o /dev/null
clang version 3.0 (trunk 128412)
Target: i386-pc-linux-gnu
Thread model: posix
clang: warning: argument unused during compilation: '-ftls-model=local-exec'
 "/usr/local/bin/clang" -cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all
-disable-free -main-file-name tls.c -mrelocation-model static -mdisable-fp-elim
-masm-verbose -mconstructor-aliases -target-cpu pentium4 -target-linker-version
2.20.51 -momit-leaf-frame-pointer -v -resource-dir
/usr/local/bin/../lib/clang/3.0 -ferror-limit 19 -fmessage-length 80
-fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /dev/null -x c
clang -cc1 version 3.0 based upon llvm 3.0svn hosted on i386-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
End of search list.
tls.c:2:20: warning: unknown attribute '__tls_model__' ignored
1 warning generated.

>From the gcc docs:

>The tls_model attribute sets thread-local storage model (see Thread-Local[1])
>of a particular __thread variable, overriding -ftls-model= command-line
>switch on a per-variable basis. The tls_model argument should be one of
>global-dynamic, local-dynamic, initial-exec or local-exec.

[1] http://gcc.gnu.org/onlinedocs/gcc/Thread_002dLocal.html
>See ELF Handling For Thread-Local Storage[2] for a detailed explanation
>of the four thread-local storage addressing models, and how the run-time
>is expected to function. 
[2] http://www.akkadia.org/drepper/tls.pdf

It looks like "global-dynamic" is the default TLS model if no attribute or -f
option is specified, so clang seems to support that already at least. Even if
it doesn't support the others yet though, t would be nice if clang at least
recognized the attribute and errored out if it's asking for a TLS model it
doesn't support.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list