From: Ivo Raisr Date: Fri, 28 Jul 2017 20:49:20 +0000 (+0000) Subject: Check whether it is ok to use compiler flag '-pie'. X-Git-Tag: VALGRIND_3_14_0~308 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=184fc7a804a6ea5e35902ff08fc788905fcb4641;p=thirdparty%2Fvalgrind.git Check whether it is ok to use compiler flag '-pie'. Some compilers actually do not support -pie and report its usage as an error. We need to check if it is safe to use it first. n-i-bz git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16463 --- diff --git a/configure.ac b/configure.ac index b1ca652eaa..40123f4c39 100644 --- a/configure.ac +++ b/configure.ac @@ -2177,6 +2177,27 @@ AC_MSG_RESULT([no]) AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes]) +# Does this compiler and linker support -pie? +# Some compilers actually do not support -pie and report its usage +# as an error. We need to check if it is safe to use it first. + +AC_MSG_CHECKING([if gcc accepts -pie]) + +safe_CFLAGS=$CFLAGS +CFLAGS="-pie" + +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[ + return 0; +]])], [ +AC_SUBST([FLAG_PIE], ["-pie"]) +AC_MSG_RESULT([yes]) +], [ +AC_SUBST([FLAG_PIE], [""]) +AC_MSG_RESULT([no]) +]) +CFLAGS=$safe_CFLAGS + + # Does this compiler support -no-pie? # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by # default. However this gets in the way with some tests, we use -no-pie diff --git a/gdbserver_tests/Makefile.am b/gdbserver_tests/Makefile.am index bdf0c5b84b..1a5c51356a 100644 --- a/gdbserver_tests/Makefile.am +++ b/gdbserver_tests/Makefile.am @@ -167,5 +167,5 @@ AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) LDADD = -lpthread -main_pic_LDFLAGS = -pie +main_pic_LDFLAGS = @FLAG_PIE@ main_pic_CFLAGS = $(AM_CFLAGS) -fPIC