[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


http://llvm.org/bugs/show_bug.cgi?id=9788

           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
    __attribute__((__tls_model__("global-dynamic")));

$ 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
tls.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:
 /usr/local/include
 /usr/local/bin/../lib/clang/3.0/include
 /usr/include
End of search list.
tls.c:2:20: warning: unknown attribute '__tls_model__' ignored
      [-Wunknown-attributes]
    __attribute__((__tls_model__("initial-exec")));
                   ^
1 warning generated.
----

>From the gcc docs:

http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#index-g_t_0040code_007btls_005fmodel_007d-attribute-2551
>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