[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH] build: Fix "Argument list too long" problem



For libraries with lots of object files, such as musl, `make clean` was
failing with "make: execvp: /bin/sh: Argument list too long" on some
machines (depending on default maximum command-line length).

The user could not solve this problem by changing his shell limits,
because GNU make resets those to system defaults.

This patch removes the direct call to `rm`, and replace it with a call
to `xargs rm`, using an intermediate file generated by `make`. The
intermediate file is kept after `clean` so that the user can inspect
which files have been removed.

Signed-off-by: Cyril Soldani <cyril.soldani@xxxxxxxxx>
---
 Makefile                     | 1 +
 support/build/Makefile.rules | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index be8fa8ce..e2b41457 100644
--- a/Makefile
+++ b/Makefile
@@ -262,6 +262,7 @@ MV    := mv -f
 CP    := cp -f
 MKDIR := mkdir
 TOUCH := touch
+XARGS := xargs
 
 # kconfig uses CONFIG_SHELL
 CONFIG_SHELL := $(SHELL)
diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index 8c096fa5..fbdbc2c5 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -779,8 +779,13 @@ endef
 # cleanrule_lib $libname
 define cleanrule_lib =
 clean-$(1):
-       $(call verbose_cmd,CLEAN,$(1),$(RM) \
-       $($(call vprefix_lib,$(1),CLEAN-y)) $($(call vprefix_lib,$(1),CLEAN)))
+       $(file >$(BUILD_DIR)/$(1)/uk_clean_list) \
+            $(foreach O,$($(call vprefix_lib,$(1),CLEAN-y)),\
+                $(file >>$(BUILD_DIR)/$(1)/uk_clean_list,$O)) \
+            $(foreach O,$($(call vprefix_lib,$(1),CLEAN)),\
+                $(file >>$(BUILD_DIR)/$(1)/uk_clean_list,$O))
+       $(call verbose_cmd,CLEAN,$(1),\
+            $(XARGS) $(RM) <$(BUILD_DIR)/$(1)/uk_clean_list)
 
 .PHONY: clean-$(1)
 endef
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.