Fix #3201: "ar: Bad file number" build error with MSYS and SplitObjs=YES
authorSimon Marlow <marlowsd@gmail.com>
Thu, 21 May 2009 10:31:31 +0000 (10:31 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 21 May 2009 10:31:31 +0000 (10:31 +0000)
mk/config.mk.in
rts/ghc.mk
rules/build-package-way.mk

index 40e5e91..4fac281 100644 (file)
@@ -777,6 +777,16 @@ LD_X                       = @LdXFlag@
 # overflowing command-line length limits.
 LdIsGNULd              = @LdIsGNULd@
 
+# On MSYS, building with SplitObjs=YES fails with 
+#   ar: Bad file number
+# see #3201.  We need to specify a smaller max command-line size
+# to work around it.  32767 doesn't work; 30000 does.
+ifeq "$(Windows)" "YES"
+XARGS = xargs -s 30000
+else
+XARGS = xargs
+endif
+
 #
 # In emergency situations, REAL_SHELL is used to perform shell commands
 # from within the ghc driver script, by scribbling the command line to
index fba236b..a88ea93 100644 (file)
@@ -160,7 +160,7 @@ $$(rts_$1_LIB) : $$(rts_$1_OBJS) rts/libs.depend
 else
 $$(rts_$1_LIB) : $$(rts_$1_OBJS)
        $$(RM) $$@
-       echo $$(rts_$1_OBJS) | xargs $$(AR) $$(EXTRA_AR_ARGS) $$@
+       echo $$(rts_$1_OBJS) | $$(XARGS) $$(AR) $$(EXTRA_AR_ARGS) $$@
 endif
 
 endef
index 0485a20..b8df37d 100644 (file)
@@ -52,11 +52,11 @@ else
 ifeq "$$($1_$2_SplitObjs)" "YES"
 $$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS)
        $$(RM) $$@
-       (echo $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)`; find $$(patsubst %.$$($3_osuf),%_split,$$($1_$2_$3_HS_OBJS)) -name '*.$$($3_osuf)' -print) | xargs $$(AR) $$(EXTRA_AR_ARGS) $$@
+       (echo $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)`; find $$(patsubst %.$$($3_osuf),%_split,$$($1_$2_$3_HS_OBJS)) -name '*.$$($3_osuf)' -print) | $$(XARGS) $$(AR) $$(EXTRA_AR_ARGS) $$@ || $(RM) $$@
 else
 $$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS)
        $$(RM) $$@
-       echo $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_$3_HS_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` | xargs $$(AR) $$(EXTRA_AR_ARGS) $$@
+       echo $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_$3_HS_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` | $$(XARGS) $$(AR) $$(EXTRA_AR_ARGS) $$@ || $(RM) $$@
 endif
 endif