Skip to contentSkip to conversation

configure: tighten pie toolchain support test for tls variables

PATCH Applied Avi Kivity 3 participants 3 messages Nov 23, 2011 – Nov 28, 2011

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH v3 1/1 configure: tighten pie toolchain support test for tls variables

Some toolchains don't support pie properly when tls variables are in use. Disallow pie when such toolchains are detected.

---

v3: only check __thread on Linux, where we require it, and where the
toolchain fails

v2: give tls_var a type; avoids invisible warning

 configure |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
configure +11 -1
index 75e1f10..1a2c55f 100755
@@ -1120,7 +1120,17 @@ fi
 
 if test "$pie" != "no" ; then
   cat > $TMPC << EOF
-int main(void) { return 0; }
+
+#ifdef __linux__
+#  define THREAD __thread
+#else
+#  define THREAD
+#endif
+
+static THREAD int tls_var;
+
+int main(void) { return tls_var; }
+
 EOF
   if compile_prog "-fPIE -DPIE" "-pie"; then
     QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
Signature · 1 line
1.7.7.1
#1 lore raw
Quoted 4 lines · Avi Kivity

Some toolchains don't support pie properly when tls variables are in use. Disallow pie when such toolchains are detected.

Thanks. Works as expected now.

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#2 lore raw
In reply to Avi Kivity
Quoted 4 lines · Avi Kivity

Some toolchains don't support pie properly when tls variables are in use. Disallow pie when such toolchains are detected.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 33 lines

---

v3: only check __thread on Linux, where we require it, and where the
toolchain fails

v2: give tls_var a type; avoids invisible warning

  configure |   12 +++++++++++-
  1 files changed, 11 insertions(+), 1 deletions(-)
configure +11 -1
index 75e1f10..1a2c55f 100755
@@ -1120,7 +1120,17 @@ fi
 
  if test "$pie" != "no" ; then
    cat>  $TMPC<<  EOF
-int main(void) { return 0; }
+
+#ifdef __linux__
+#  define THREAD __thread
+#else
+#  define THREAD
+#endif
+
+static THREAD int tls_var;
+
+int main(void) { return tls_var; }
+
  EOF
    if compile_prog "-fPIE -DPIE" "-pie"; then
      QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"