diff --git a/configure b/configure index 761cd5e431..11471698b6 100755 --- a/configure +++ b/configure @@ -1333,6 +1333,13 @@ EOF # Meson currently only handles pie as a boolean for now so if we have # explicitly disabled PIE we need to extend our cflags because it wont. + +if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1; then + NO_PIE_LDFLAG="" +else + NO_PIE_LDFLAG="-no-pie" +fi + if test "$static" = "yes"; then if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" @@ -1341,13 +1348,13 @@ if test "$static" = "yes"; then error_exit "-static-pie not available due to missing toolchain support" else pie="no" - QEMU_CFLAGS="-fno-pie -no-pie $QEMU_CFLAGS" + QEMU_CFLAGS="-fno-pie $NO_PIE_LDFLAG $QEMU_CFLAGS" fi elif test "$pie" = "no"; then - if compile_prog "-Werror -fno-pie" "-no-pie"; then + if compile_prog "-Werror -fno-pie" $NO_PIE_LDFLAG; then CONFIGURE_CFLAGS="-fno-pie $CONFIGURE_CFLAGS" - CONFIGURE_LDFLAGS="-no-pie $CONFIGURE_LDFLAGS" - QEMU_CFLAGS="-fno-pie -no-pie $QEMU_CFLAGS" + CONFIGURE_LDFLAGS="$NO_PIE_LDFLAG $CONFIGURE_LDFLAGS" + QEMU_CFLAGS="-fno-pie $NO_PIE_LDFLAG $QEMU_CFLAGS" fi elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"