]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Check whether it is ok to use compiler flag '-pie'.
authorIvo Raisr <ivosh@ivosh.net>
Fri, 28 Jul 2017 20:49:20 +0000 (20:49 +0000)
committerIvo Raisr <ivosh@ivosh.net>
Fri, 28 Jul 2017 20:49:20 +0000 (20:49 +0000)
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

configure.ac
gdbserver_tests/Makefile.am

index b1ca652eaaccf7472b96267acfed961a5def0b4a..40123f4c395e7767a58368c4769199f74a9366c3 100644 (file)
@@ -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
index bdf0c5b84b52ed64e572623bacacb5011837ec09..1a5c51356a07c6b83f49f32bf6689c41f37d6d9c 100644 (file)
@@ -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