Lets say my userspace (packages) are compiled with gcc 4.7 and libc6 2.13 (Debian Wheezy)

Can I compile linux kernel under different dev environment, such as gcc 6.3 and libc6 2.24 (ie, under Debian Stretch) ?

I know that unlike packages, kernel is not linked with any dynamic libraries. So theoretically, it should make no difference which gcc and libc it was compiled under.

Is this true ? Could I run into trouble when I do this ? Could there perhaps be some incompatibilities caused by different gcc versions?

On the other hand, newer gcc has some interesting features, better security. So perhaps, kernel should be compiled with newest gcc ?

2 Answers 2


As you point out, the C library being used has no impact on the kernel, the kernel doesn’t use the C library. (There’s an indirect impact, since it’s used to build tools the kernel uses during its build process, but that’s extremely unlikely to affect the end result.)

The kernel can be built with a variety of different compiler versions; according to its documentation, it only needs GCC 3.2 or later. You’ll also find that it can take a while for the kernel to officially support the latest versions of GCC, and longer still for a distribution kernel to use it. For example, the Debian Linux kernel package uses GCC 6, and even has dedicated packages to provide the correct compiler version (linux-compiler-gcc-6-x86 on amd64 and i386). There is no connection between the compiler used for the kernel and the compiler used for userspace (nor is there necessarily any need to use the same compiler for all of userspace — old programs built with GCC 3 or even 2 still work on modern systems).

Newer compiler versions do provide more security features, but GCC 6 is good enough for most if not all the security features used in the kernel.


Can you compile kernel with a different toolchain than user space packages? Yes.

One of the core principles of kernel is separation of user space and kernel. There is a well-defined interface between the two - the system call interface. As long as user-space programs respect that, it doesn't matter whether they are compiled using same toolchain as the kernel. Ineed, many programs are not even written in C or assembly and use totally different compilers and runtime environments, e.g. Java programs running on JVM.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .