diff mbox series

build: de-duplicate _DIRS before calling mkdir

Message ID 20240404130327.80024-1-nbd@nbd.name
State Accepted
Headers show
Series build: de-duplicate _DIRS before calling mkdir | expand

Commit Message

Felix Fietkau April 4, 2024, 1:03 p.m. UTC
If the build path is long, the contents of the _DIRS variable can be very long,
since it repeats the same directories very often.
In some cases, this has triggered an "Argument list too long" build error.

Reported-by: Robert Marko <robimarko@gmail.com>
Suggested-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 src/build.rules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jouni Malinen April 15, 2024, 8:39 p.m. UTC | #1
On Thu, Apr 04, 2024 at 03:03:27PM +0200, Felix Fietkau wrote:
> If the build path is long, the contents of the _DIRS variable can be very long,
> since it repeats the same directories very often.
> In some cases, this has triggered an "Argument list too long" build error.

Thanks, applied.
diff mbox series

Patch

diff --git a/src/build.rules b/src/build.rules
index acda8847284d..c756ccb84e8c 100644
--- a/src/build.rules
+++ b/src/build.rules
@@ -80,7 +80,7 @@  endif
 _DIRS := $(BUILDDIR)/$(PROJ)
 .PHONY: _make_dirs
 _make_dirs:
-	@mkdir -p $(_DIRS)
+	@mkdir -p $(sort $(_DIRS))
 
 $(BUILDDIR)/$(PROJ)/src/%.o: $(ROOTDIR)src/%.c $(CONFIG_FILE) | _make_dirs
 	$(Q)$(CC) -c -o $@ $(CFLAGS) $<