From d421a7e22e0be3de32376970b8c38ec308f959da Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 11 Nov 2016 12:05:21 -0500 Subject: 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 --- aclocal.m4 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'aclocal.m4') 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 -- cgit v1.2.1