From 6ca62d092985393c96c35c6b8d01c5162711aaa0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Brucker Date: Wed, 14 Aug 2024 12:02:02 +0100 Subject: [PATCH] configs: buildroot: Reduce fd limit to accelerate build When the limit of open fd is very high, fakeroot used by buildroot takes forever to start: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=920913 For example my default docker configuration has a file limit of 1073741816, which is unnecessary and causes the build to hang for 4 minutes. Drop the file limit before making buildroot. Signed-off-by: Jean-Philippe Brucker --- config/buildroot.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/buildroot.yaml b/config/buildroot.yaml index 555c2d2..1e681c0 100644 --- a/config/buildroot.yaml +++ b/config/buildroot.yaml @@ -30,8 +30,21 @@ build: # Finalize the config. - make BR2_JLEVEL=${param:jobs} O=${param:builddir} olddefconfig + # Fakeroot takes a while to start when the file descriptor limit is high. + # Reduce it to significantly accelerate the build. + # - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=920913 + # - https://github.com/moby/moby/issues/45436 + - saved_limit=$$(ulimit -S -n) + - new_limit=4096 + - if [ "$$new_limit" -lt "$$saved_limit" ]; then + - ulimit -S -n "$$new_limit" + - fi + # Build. - make BR2_JLEVEL=${param:jobs} O=${param:builddir} + # Restore the previous file limit + - ulimit -S -n "$$saved_limit" + artifacts: BUILDROOT: ${param:builddir}/images/rootfs.ext2 -- GitLab