[project @ 2005-01-10 11:45:19 by simonmar]
[ghc-hetmet.git] / mk / target.mk
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