Linux – Why is ‘bc’ required to build the Linux kernel

bclinux-kernel

The Linux kernel minimal building requirements specifies that the calculator bc is required to build kernel v4.10, the minimal version of the tool being 1.06.95.

What use is made of bc in this context, and why isn't the C language directly used instead of bc for these operations?

Best Answer

bc is used during the kernel build to generate time constants in header files. You can see it invoked in Kbuild, where it processes kernel/time/timeconst.bc to generate timeconst.h.

This could be implemented as a C program which is built and run during the build, but it’s easier to use bc (which is small and common; in fact it’s part of the set of tools which are mandatory on a POSIX systems — the kernel does expect GNU bc though).

bc is used here instead of Perl. The commit message suggests that bc was used previously, but I can’t find a trace of that; Perl has been used since 2008 (much to some people’s chagrin, although that patch set was never merged).

Related Question