summaryrefslogtreecommitdiff
path: root/aclocal.m4
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-11-11 12:05:21 -0500
committerBen Gamari <ben@smart-cactus.org>2016-11-11 12:05:40 -0500
commitd421a7e22e0be3de32376970b8c38ec308f959da (patch)
tree80e298beed878f74532e46d2249c78ab0a8e3630 /aclocal.m4
parentec0bf8117d1aefd20711a6152ebbca63f3bd0774 (diff)
downloadhaskell-d421a7e22e0be3de32376970b8c38ec308f959da.tar.gz
Pass -no-pie to GCC
Certain distributions (e.g. Debian and Ubuntu) have enabled PIE be default in their GCC packaging. This breaks our abuse of GCC as a linker which requires that we pass -Wl,-r, which is incompatible with PIE (since the former implies that we are generating a relocatable object file and the latter an executable). This is a second attempt at D2691. This attempt constrasts with D2691 in that it preserves the "does gcc support -no-pie" flag in settings, allowing this to be reconfigured by `configure` during installation of a binary distribution. Thanks for @rwbarton for drawing attention to this issue. Test Plan: Validate Reviewers: austin, hvr, erikd Reviewed By: erikd Subscribers: thomie, rwbarton, erikd Differential Revision: https://phabricator.haskell.org/D2693 GHC Trac Issues: #12759
Diffstat (limited to 'aclocal.m4')
-rw-r--r--aclocal.m421
1 files changed, 21 insertions, 0 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index df9d42028d..aea85f4908 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -509,12 +509,14 @@ AC_DEFUN([FP_SETTINGS],
SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
+ SettingsCCompilerSupportsNoPie="$CONF_GCC_SUPPORTS_NO_PIE"
SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
AC_SUBST(SettingsCCompilerCommand)
AC_SUBST(SettingsHaskellCPPCommand)
AC_SUBST(SettingsHaskellCPPFlags)
AC_SUBST(SettingsCCompilerFlags)
AC_SUBST(SettingsCCompilerLinkFlags)
+ AC_SUBST(SettingsCCompilerSupportsNoPie)
AC_SUBST(SettingsLdCommand)
AC_SUBST(SettingsLdFlags)
AC_SUBST(SettingsArCommand)
@@ -1322,6 +1324,25 @@ AC_SUBST(GccIsClang)
rm -f conftest.txt
])
+# FP_GCC_SUPPORTS_NO_PIE
+# ----------------------
+# Does gcc support the -no-pie option? If so we should pass it to gcc when
+# joining objects since -pie may be enabled by default.
+AC_DEFUN([FP_GCC_SUPPORTS_NO_PIE],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_MSG_CHECKING([whether GCC supports -no-pie])
+ echo 'int main() { return 0; }' > conftest.c
+ if ${CC-cc} -o conftest -no-pie conftest.c > /dev/null 2>&1; then
+ CONF_GCC_SUPPORTS_NO_PIE=YES
+ AC_MSG_RESULT([yes])
+ else
+ CONF_GCC_SUPPORTS_NO_PIE=NO
+ AC_MSG_RESULT([no])
+ fi
+ rm -f conftest.c conftest.o conftest
+])
+
dnl Small feature test for perl version. Assumes PerlCmd
dnl contains path to perl binary.
dnl