AC_SUBST(LdXFlag)
])
+dnl
+dnl Check for GNU ld
+dnl
+AC_DEFUN(FPTOOLS_GNU_LD,
+[AC_CACHE_CHECK([whether ld is GNU ld], fptools_cv_gnu_ld,
+[
+if ${LdCmd} -v | grep GNU 2>&1 >/dev/null; then
+ fptools_cv_gnu_ld=yes
+else
+ fptools_cv_gnu_ld=no
+fi
+])
+if test "$fptools_cv_gnu_ld" = yes; then
+ LdIsGNULd=YES
+else
+ LdIsGNULd=NO
+fi
+AC_SUBST(LdIsGNULd)
+])
+
# FP_PROG_AR
# ----------
SED = @SedCmd@
SHELL = /bin/sh
+LD = @LdCmd@
+
# Some ld's support the -x flag and some don't, so the configure
# script detects which we have and sets LdXFlag to "-x" or ""
# respectively.
-LD = @LdCmd@
LD_X = @LdXFlag@
+# GNU ld supports input via a linker script, which is useful to avoid
+# overflowing command-line length limits.
+LdIsGNULd = @LdIsGNULd@
+
#
# In emergency situations, REAL_SHELL is used to perform shell commands
# from within the ghc driver script, by scribbling the command line to
$(RM) $@; if [ ! -d $(basename $@)_split ]; then mkdir $(basename $@)_split; else \
$(FIND) $(basename $@)_split -name '*.$(way_)o' -print | xargs $(RM) __rm_food; fi
ifeq "$(GhcWithInterpreter)" "YES"
-HC_SPLIT_POST = (cd $(basename $@)_split && $(LD) -r $(LD_X) -o ../$(notdir $@) *.$(way_)o)
+ifeq "$(LdIsGNULd)" "YES"
+# If ld is GNU ld, we can use a linker script to pass the names of the
+# input files. This avoids problems with limits on the length of the
+# ld command line, which we run into for large Haskell modules.
+HC_SPLIT_POST = \
+ ( cd $(basename $@)_split; \
+ $(RM) ld.script; \
+ touch ld.script; \
+ echo "INPUT(" *.$(way_)o ")" >>ld.script; \
+ $(LD) -r $(LD_X) -o ../$(notdir $@) ld.script; \
+ )
+else
+HC_SPLIT_POST = \
+ ( cd $(basename $@)_split; \
+ $(LD) -r $(LD_X) -o ../$(notdir $@) *.$(way_)o; \
+ )
+endif # LdIsGNULd == YES
else
HC_SPLIT_POST = touch $@
endif # GhcWithInterpreter == YES