While working to improve Solaris/x86 TLS support, Uros provided me with a testcase to excercise all 4 TLS access models. Since there were different issues affecting the different models, I've split the testcase into one per access model so one can easier see what's broken.
Tested with the appropriate runtest invocations in the whole range of Solaris configurations, as well as Tru64 UNIX: as, ld gas, ld gas, gld alpha-dec-osf5.1b PASS i386-pc-solaris2.8 PASS gd, ld FAIL PASS i386-pc-solaris2.9 PASS gd, ld FAIL PASS i386-pc-solaris2.10 gd, ld FAIL gd, ld FAIL PASS i386-pc-solaris2.11 PASS PASS PASS sparc-pc-solaris2.8 PASS PASS PASS sparc-pc-solaris2.9 PASS PASS PASS sparc-pc-solaris2.10 PASS PASS PASS sparc-pc-solaris2.11 PASS PASS PASS The Solaris 8 and 9 as, ld configurations are actually emutls, as is Tru64 UNIX, so we won't see failures on such targets. I do have a patch for the gd and ld failures on Solaris/x86. Those models weren't excercised anywhere in the testsuite before. The failures occur since the Solaris ABI requires slightly different code sequences here, and the patch accomodates this. In the very latest version of Solaris 11, the linker maintainers have added support for the GNU code sequences, too, so all is fine there. While testing the patch, the Solaris 8 and 9 gas, ld and gas, gld configurations were UNSUPPORTED initially, since the tls_runtime test itself failed: ld.so.1: tls_runtime4775.exe: fatal: tls_runtime4775.exe: object requires TLS, but TLS failed to initialize Adding the necessary TLS options fixes this and provides the results above. I'll install the patch in a day unless someone sees any problems. Rainer 2010-12-30 Uros Bizjak <ubiz...@gmail.com> Rainer Orth <r...@cebitec.uni-bielefeld.de> * gcc.dg/torture/tls/run-gd.c: New test. * gcc.dg/torture/tls/run-ie.c: New test. * gcc.dg/torture/tls/run-ld.c: New test. * gcc.dg/torture/tls/run-le.c: New test. * lib/target-supports.exp (check_effective_target_tls_runtime): Build testcase with TLS options. diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-gd.c b/gcc/testsuite/gcc.dg/torture/tls/run-gd.c new file mode 100644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/tls/run-gd.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_gd __attribute__((tls_model("global-dynamic"))) = 0; + +int get_gd (void) +{ + return tls_gd; +} + +int *get_gdp (void) +{ + return &tls_gd; +} + +int main (void) +{ + int val; + + val = get_gd (); + if (val != 0) + abort (); + + val = *get_gdp (); + if (val != 0) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-ie.c b/gcc/testsuite/gcc.dg/torture/tls/run-ie.c new file mode 100644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/tls/run-ie.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_ie __attribute__((tls_model("initial-exec"))) = 4; + +int get_ie (void) +{ + return tls_ie; +} + +int *get_iep (void) +{ + return &tls_ie; +} + +int main (void) +{ + int val; + + val = get_ie (); + if (val != 4) + abort (); + + val = *get_iep (); + if (val != 4) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-ld.c b/gcc/testsuite/gcc.dg/torture/tls/run-ld.c new file mode 100644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/tls/run-ld.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_ld __attribute__((tls_model("local-dynamic"))) = 1; +__thread int tls_ld2 __attribute__((tls_model("local-dynamic"))) = 2; + +int get_ld (void) +{ + return tls_ld + tls_ld2; +} + +int *get_ldp (void) +{ + return &tls_ld; +} + +int main (void) +{ + int val; + + val = get_ld (); + if (val != 1 + 2) + abort (); + + val = *get_ldp (); + if (val != 1) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-le.c b/gcc/testsuite/gcc.dg/torture/tls/run-le.c new file mode 100644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/tls/run-le.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_le __attribute__((tls_model("local-exec"))) = 3; + +int get_le (void) +{ + return tls_le; +} + +int *get_lep (void) +{ + return &tls_le; +} + +int main (void) +{ + int val; + + val = get_le (); + if (val != 3) + abort (); + + val = *get_lep (); + if (val != 3) + abort (); + + return 0; +} -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University