AlmaLinux 10.1: Cannot rebuild default kernel

Hello.

I am trying to build the kernel of AlmaLinux 10.1 x86-64_v2, simply with the default configuration and it fails building.

I simply did a default AlmaLinux 10.1 x86-64_v2 binary installation, and adding a big swap file of 40GB, and then simply typed this:

dnf group install "Development Tools" -y
cd /usr/src/kernels/$(uname -r)
make bzImage

But after about 2 hours of build, it provided this error:

make[2]: *** [Makefile:1234: prepare0] Error 2
make[1]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/Makefile:1234: prepare0] Error 2
make: *** [Makefile:242: __sub-make] Error 2

I also get the following warnings during the build about every second:

scripts/Makefile.build:395: warning: overriding recipe for target 'built-in.a'
Makefile:1201: warning: ignoring old recipe for target 'built-in.a'
scripts/Makefile.build:405: warning: overriding recipe for target 'modules.order'
Makefile:1921: warning: ignoring old recipe for target 'modules.order'

It is the same if I do a ā€œmake cleanā€ before ā€œmake bzImageā€, alghough it changes about 10 lines in the .config file for any reason.

The CPU is an Intel Core i5 760 with 4 cores (which is v2 CPU version), and 32GB RAM.

Shouldn’t these commands make the build work out of the box?

Thanks for any help.

You likely have insufficient build dependencies.
dnf group install ā€œDevelopment Toolsā€ alone is insufficient for building the RHEL/AlmaLinux kernel.

Please try the following:

sudo dnf -y builddep kernel

Then retry the build.
If it still fails, the root cause lies in the first error: line appearing above the prepare0: Error 2 in the log. Please share that line.

fedorać®ćƒ“ćƒ«ćƒ‰

Thank you. I installed the two new packages as per your description, and tried again to build with ā€œmake cleanā€ and ā€œmake bzImageā€.

The result is the following error after about 2 hours of build:

Makefile:1921: warning: ignoring old recipe for target 'modules.order'
scripts/Makefile.build:395: warning: overriding recipe for target 'built-in.a'
Makefile:1201: warning: ignoring old recipe for target 'built-in.a'
scripts/Makefile.build:405: warning: overriding recipe for target 'modules.order'
Makefile:1921: warning: ignoring old recipe for target 'modules.order'
make[4201]: /bin/sh: Argument list too long
scripts/Makefile.build:395: warning: overriding recipe for target 'built-in.a'
Makefile:1201: warning: ignoring old recipe for target 'built-in.a'
scripts/Makefile.build:405: warning: overriding recipe for target 'modules.order'
Makefile:1921: warning: ignoring old recipe for target 'modules.order'
make[4201]: mkdir: Argument list too long
make[4201]: make: Argument list too long
make[4201]: *** [arch/x86/Makefile:277: archheaders] Error 127
make[4200]: *** [Makefile:1234: prepare0] Error 2
...
make[6]: *** [Makefile:1234: prepare0] Error 2
make[5]: *** [Makefile:1234: prepare0] Error 2
make[4]: *** [Makefile:1234: prepare0] Error 2
make[3]: *** [Makefile:1234: prepare0] Error 2
make[2]: *** [Makefile:1234: prepare0] Error 2
make[1]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/Makefile:1234: prepare0] Error 2
make: *** [Makefile:242: __sub-make] Error 2

make[4201]: mkdir: Argument list too long
make[4201]: make: Argument list too long
make[4201]: /bin/sh: Argument list too long

This appears to be the cause of the error.
The command line exceeds the OS’s ARG_MAX limit due to variable expansion.

cd /usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2

ā– Delete configuration files
make mrproper

mkdir -p /tmp/kbuild

ā– Unset variables
unset CFLAGS CPPFLAGS LDFLAGS KCFLAGS HOSTCFLAGS HOSTLDFLAGS MAKEFLAGS

ā– Generate config
make O=/tmp/kbuild defconfig

ā– Build
make O=/tmp/kbuild -jā€œ$(nproc)ā€ bzImage

Please try this approach first.

Doing this, after the ā€œmake O=/tmp/kbuild defconfigā€ command, I get this error immediately (after some successful messages):

*** Default configuration is based on target 'x86_64_defconfig'
  GEN     Makefile
***
*** Can't find default configuration "arch/x86/configs/x86_64_defconfig"!
***
make[5]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/scripts/kconfig/Makefile:102: x86_64_defconfig] Error 1
make[4]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/Makefile:708: x86_64_defconfig] Error 2
make[3]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/scripts/kconfig/Makefile:98: defconfig] Error 2
make[2]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/Makefile:708: defconfig] Error 2
make[1]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/Makefile:242: __sub-make] Error 2
make[1]: Leaving directory '/tmp/kbuild'
make: *** [Makefile:242: __sub-make] Error 2

Sorry. It seems the build failed not because of too many arguments,
but because there was no default config.

If you want to build using the current distro kernel configuration, do this instead:

cd /usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2
mkdir -p /tmp/kbuild
cp -a /boot/config-6.12.0-124.21.1.el10_1.x86_64_v2 /tmp/kbuild/.config
make O=/tmp/kbuild olddefconfig
make O=/tmp/kbuild -j$(nproc) bzImage

If you specifically want to use defconfig, you need the full kernel source (e.g. from the kernel SRPM), not kernel-devel.

I typed your procedure, and after the ā€œmake O=/tmp/kbuild -j$(nproc) bzImageā€ line I got this error:

  CC      /tmp/kbuild/tools/objtool/libsubcmd/subcmd-config.o
  LD      /tmp/kbuild/tools/objtool/libsubcmd/libsubcmd-in.o
  AR      /tmp/kbuild/tools/objtool/libsubcmd/libsubcmd.a
make[4]: *** [Makefile:64: /tmp/kbuild/tools/objtool/objtool-in.o] Error 1
make[3]: *** [Makefile:72: objtool] Error 2
make[2]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/Makefile:1411: tools/objtool] Error 2
make[2]: *** Waiting for unfinished jobs....
  HOSTCC  scripts/dtc/treesource.o

Any idea ?

In fact the last error was due to the make command that was missing a space after the ā€˜-j’ option, or at least the -j option causes issues and stops the build immediately. Hence I built it without the -j option this way and it continues to build properly:

make O=/tmp/kbuild bzImage

Doing this even without -j option, and adding your ā€œmake O=/tmp/kbuild olddefconfigā€ procedure before, it builds further, but I still get this error after a long build time:

  GEN     Makefile
/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/scripts/Makefile.build:395: warning: overriding recipe for target 'built-in.a'
/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/./Makefile:1201: warning: ignoring old recipe for target 'built-in.a'
/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/scripts/Makefile.build:405: warning: overriding recipe for target 'modules.order'
/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/./Makefile:1921: warning: ignoring old recipe for target 'modules.order'
  GEN     Makefile
make[4202]: /bin/sh: Argument list too long
/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/scripts/Makefile.build:395: warning: overriding recipe for target 'built-in.a'
/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/./Makefile:1201: warning: ignoring old recipe for target 'built-in.a'
/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/scripts/Makefile.build:405: warning: overriding recipe for target 'modules.order'
/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/./Makefile:1921: warning: ignoring old recipe for target 'modules.order'
make[4202]: mkdir: Argument list too long
make[4202]: /bin/sh: Argument list too long
make[4202]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/./Makefile:660: outputmakefile] Error 127
make[4201]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/./Makefile:1234: prepare0] Error 2
make[4200]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/./Makefile:1234: prepare0] Error 2
make[4199]: *** [/usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2/./Makefile:1234: prepare0] Error 2

It seems to get stuck with the same argument list too big for the ARG_MAX limit error, but shown in a different error style.

This is not using the defconfig, only the olddefconfig with boot .config properly placed in a new /tmp/kbuild directory before, and running the build command above.

Oh, I see.

make 4202 is showing up.
I think it got stuck in a loop and reached either /bin/sh: Argument list too long or mkdir: Argument list too long.

Please look at the following:

sudo rm -rf /tmp/kbuild
mkdir -p /tmp/kbuild

unset O KBUILD_OUTPUT KBUILD_SRC MAKEFLAGS
cd /usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2

make -C . O=/tmp/kbuild olddefconfig
make -C . O=/tmp/kbuild bzImage

Hello. I followed your new steps, but the error is still exactly the same:

make[4202]: mkdir: Argument list too long
make[4202]: /bin/sh: Argument list too long

Would it be possible that you install the AlmaLinux 10.1 x86-64_v2 binary ISO on a dev computer and try those steps? Probably it should also install on a v3 CPU.

It looks like the build is hitting a recursive make loop , which can lead to Argument list too long.

Also, some build dependencies for tools/objtool may be missing.

Please try the following steps

sudo rm -rf /tmp/kbuild
mkdir -p /tmp/kbuild

unset O KBUILD_OUTPUT KBUILD_SRC MAKEFLAGS

sudo dnf -y install elfutils-libelf-devel openssl-devel zlib-devel

cd /usr/src/kernels/6.12.0-124.21.1.el10_1.x86_64_v2

make -C . O=/tmp/kbuild olddefconfig
make -C . O=/tmp/kbuild bzImage

I understand. However I followed your new steps, and installing the new packages showed they were already installed. I still did your procedure but it failed as usual, with the ā€œmkdir: Argument list is too longā€ again after 2 hours of build.

So it seems to be a real too long path to create that it is not able to create. Maybe just the ā€œ_v2ā€ of ā€œx86-64_v2ā€ in the path makes it just 2 characters too long and this makes it fail, compared to the ā€œx86-64ā€ build ?

I understand your reasoning, but this is not a path length issue caused by the _v2 suffix.

The key evidence is make[4201] in the log. Such a high make nesting level strongly suggests a recursive make loop, and that loop can eventually hit the OS ARG_MAX limit, resulting in ā€œArgument list too longā€.

Also, building a full kernel image from /usr/src/kernels/<uname -r> is not the recommended workflow on RHEL/AlmaLinux (that tree comes from kernel-devel and is primarily meant for building external modules). For rebuilding the distro kernel, the reliable approach is to use the kernel SRPM and rpmbuild/mock.

Example (SRPM workflow):
dnf -y builddep kernel
dnf -y download --source kernel
rpm -ivh kernel-*.src.rpm
rpmbuild -bp ~/rpmbuild/SPECS/kernel.spec

Thank you for this very useful explanation on the difference between kernel-devel tree build, and the kernel SRPM build approaches. I could build the kernel properly now from kernel SRPM thanks to your 4 lines procedure to do it, with ā€œrpmbuild -baā€ taking about 8 hours for example.

To come back to the kernel-devel way to build, I still think that it should be building properly that way, and as you say even for compiling modules. Did you try the build, and does it work at least with the AlmaLinux 10.1 x86-64 ISO, and is it sure that this ā€œArgument list too longā€ error is only related to the x86-64_v2 ISO installation?

Also, is it planned to solve the issue on AlmaLinux, if that works in RHEL 10.1 ?

Maybe it is possible to enable more logs to the make process so we can see what makes it fail ? I have seen that there are some warnings at the top of my post, which might be the root cause of this issue.

Great to hear the SRPM build works.

Note that /usr/src/kernels/<uname -r> (kernel-devel) is mainly for building external modules (modules_prepare), not for rebuilding a full kernel image (bzImage). So bzImage failing there is not necessarily a distro bug.

However, make[4201] is clearly abnormal and suggests a recursive make loop, which can eventually hit ARG_MAX and result in ā€œArgument list too longā€.

Thanks for the information.

So do you know if there is a plan to solve this ā€œArgument list too longā€, and did you try to reproduce it on an x86-64 ISO install of AlmaLinux 10.1 ? Maybe trying the original RHEL 10.1 installs might be helpful, could someone try this ?

I tried to do a ā€œmake modules_prepareā€, but even this failed with still the same error ā€œmkdir: Argument list too longā€ after 2h of build, so even for external modules it is not possible to build this way.

Could you reproduce this with the ā€œx86-64_v2ā€ target or even ā€œx86-64ā€ target, or with original RHEL 10.1, and will this be investigated ?

I tried the same commands but in the ā€œX86-64ā€ target ISO installation on a v4 Intel CPU, and the result is exactly the same with ā€œArgument list too longā€ error, failing at the same stage after about 2h of build.

Hence it is not related to the ā€œX86-64_v2ā€ specific target unlike I believed, this is a common issue to AlmaLinux 10.1 base installation.
I tried also on an LVM with xfs filesystem instead of ext4 on the root partition, and the result is exactly the same.

Could someone try with a RHEL 10.1 and see if this error occurs too, and if yes to report a bug in RHEL support ?