65

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?

  • 10
    What do you mean by using C directly? I don't think that using C as a "scripting language" during build is direct or handy. – cubuspl42 Apr 23 '18 at 19:10
  • 4
    @cubuspl42 you could just write the operations in the source, and let the compiler compute it into constants. In reality, what it's used for is a bit too complicated for that. – OrangeDog Apr 23 '18 at 22:03
83

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).

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.