diff mbox series

[7/7] configure: Support -static-pie if requested

Message ID 20191218031920.6414-8-richard.henderson@linaro.org
State New
Headers show
Series configure: Improve PIE and other linkage | expand

Commit Message

Richard Henderson Dec. 18, 2019, 3:19 a.m. UTC
Recent toolchains support static and pie at the same time.

As with normal dynamic builds, allow --static to default to PIE
if supported by the toolchain.  Allow --enable/--disable-pie to
override the default.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 configure | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

-- 
2.20.1

Comments

Thomas Huth Dec. 18, 2019, 8:15 a.m. UTC | #1
On 18/12/2019 04.19, Richard Henderson wrote:
> Recent toolchains support static and pie at the same time.

> 

> As with normal dynamic builds, allow --static to default to PIE

> if supported by the toolchain.  Allow --enable/--disable-pie to

> override the default.

> 

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  configure | 17 +++++++++++------

>  1 file changed, 11 insertions(+), 6 deletions(-)


Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/configure b/configure
index 1645a58b3a..c03491018a 100755
--- a/configure
+++ b/configure
@@ -1023,7 +1023,6 @@  for opt do
   ;;
   --static)
     static="yes"
-    LDFLAGS="-static $LDFLAGS"
     QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
   ;;
   --mandir=*) mandir="$optarg"
@@ -1994,11 +1993,6 @@  if test "$static" = "yes" ; then
   if test "$modules" = "yes" ; then
     error_exit "static and modules are mutually incompatible"
   fi
-  if test "$pie" = "yes" ; then
-    error_exit "static and pie are mutually incompatible"
-  else
-    pie="no"
-  fi
 fi
 
 # Unconditional check for compiler __thread support
@@ -2032,6 +2026,17 @@  fi
 if test "$pie" = "no"; then
   QEMU_CFLAGS="$CFLAGS_NOPIE $QEMU_CFLAGS"
   LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
+elif test "$static" = "yes"; then
+  if compile_prog "-fPIE -DPIE" "-static-pie"; then
+    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
+    LDFLAGS="-static-pie $LDFLAGS"
+    pie="yes"
+  elif test "$pie" = "yes"; then
+    error_exit "-static-pie not available due to missing toolchain support"
+  else
+    LDFLAGS="-static $LDFLAGS"
+    pie="no"
+  fi
 elif compile_prog "-fPIE -DPIE" "-pie"; then
   QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
   LDFLAGS="-pie $LDFLAGS"