summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-10-07 12:48:07 -0400
committerBen Gamari <ben@smart-cactus.org>2021-10-07 12:48:07 -0400
commita2712a1872dbb3a23c4ebdf5f7bcba3c2f0de83a (patch)
tree2787d77c5f58fcbe1777a220faadf88c8c718cfa
parenta4889f2e32dbd1a055700907c36ebb5dbc36ee5b (diff)
downloadhaskell-wip/T17508.tar.gz
configure: Add test for binutils#23856wip/T17508
As noted in #17508, currently ld.gold's treatment of non-PIC code is broken in ways that break linking of musl. Make sure we don't use it in cases where this will certainly result in broken compilation.
-rw-r--r--m4/fp_cc_linker_flag_try.m422
1 files changed, 19 insertions, 3 deletions
diff --git a/m4/fp_cc_linker_flag_try.m4 b/m4/fp_cc_linker_flag_try.m4
index 69af387d5d..ff2b21d420 100644
--- a/m4/fp_cc_linker_flag_try.m4
+++ b/m4/fp_cc_linker_flag_try.m4
@@ -7,14 +7,30 @@
# $2 = the variable to set with the appropriate GHC flag if the linker is
# found to be usable
AC_DEFUN([FP_CC_LINKER_FLAG_TRY], [
+ AC_REQUIRE([FP_GCC_SUPPORTS_NO_PIE])
AC_MSG_CHECKING([whether C compiler supports -fuse-ld=$1])
+ args=""
echo 'int main(void) {return 0;}' > conftest.c
- if $CC -o conftest.o -fuse-ld=$1 conftest.c > /dev/null 2>&1
+ if $CC -o conftest.o $args -fuse-ld=$1 conftest.c > /dev/null 2>&1
then
- $2="-fuse-ld=$1"
AC_MSG_RESULT([yes])
+
+ # ld.gold's treatment of position independent code is broken in ways
+ # that miscompile musl. See GHC #17508 and binutils issue #23856.
+ AC_MSG_CHECKING([whether $1 linker is affected by binutils issue 23856])
+ if [ "$CONF_GCC_SUPPORTS_NO_PIE" = "YES" ]; then
+ args="$args -no-pie"
+ fi
+ echo '#include <stdio.h>' > conftest.c
+ echo 'int main(void) {printf("hello world\n"); return 0;}' >> conftest.c
+ if $CC -o conftest $args -fuse-ld=$1 conftest.c > /dev/null 2>&1 && ./conftest; then
+ AC_MSG_RESULT([not affected])
+ $2="-fuse-ld=$1"
+ else
+ AC_MSG_RESULT([affected])
+ fi
else
AC_MSG_RESULT([no])
fi
- rm -f conftest.c conftest.o
+ rm -f conftest.c conftest conftest.o
])