[project @ 2005-01-10 11:45:19 by simonmar]
authorsimonmar <unknown>
Mon, 10 Jan 2005 11:45:24 +0000 (11:45 +0000)
committersimonmar <unknown>
Mon, 10 Jan 2005 11:45:24 +0000 (11:45 +0000)
Work around problems caused by limit on the length of the command line
in ld, which shows up when building OpenGL on Windows with SplitObjs=YES.

We now pass the names of the input files to ld via a linker script.
This is (probably) only supported by GNU ld, so we now have to detect
GNU ld in the configure script (yawn) and back off to the old method
if we don't have it.

aclocal.m4
configure.ac
mk/config.mk.in
mk/target.mk

index a615c55..34542f2 100644 (file)
@@ -353,6 +353,26 @@ fi
 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
 # ----------
index e2d7536..44353a1 100644 (file)
@@ -1257,6 +1257,7 @@ case $HostOS_CPP in
 esac
 AC_SUBST(LdCmd)
 FPTOOLS_LD_X
+FPTOOLS_GNU_LD
 
 AC_CONFIG_FILES([mk/config.mk])
 AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp > mk/stamp-h])
index b9033be..27dc20a 100644 (file)
@@ -812,12 +812,17 @@ RM                        = rm -f
 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
index 6dead33..62d3355 100644 (file)
@@ -324,7 +324,23 @@ HC_SPLIT_PRE = \
     $(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