8

On Ubuntu 22.04, the default GNU C compiler version is gcc-11. However, it appears that the latest default kernel version (6.5.0-14-generic as of writing this question) is built using gcc-12. Why is this the case? It feels like it's likely to result in issues related to mixing compilers and has already caused me headaches with kernel modules and dkms.

3 Answers 3

8

NOTE: The 6.5 Kernel reports being built as x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) and this should be OK. This is because the kernel is not built on your system during install. See https://askubuntu.com/a/1171939/231142 for more info. During any builds it might give you a warning about not matching the installed version since they are not named the same. Installed version reports as gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04)


gcc-12 should already be installed, but if it isn't, you can install it or reinstall it by running:

sudo apt install --reinstall gcc-12

Then all you should have to do is update the link for gcc to go to the gcc-12 binary:

sudo ln -s -f /usr/bin/gcc-12 /usr/bin/gcc

You can set it back to 11 as well by doing the following:

sudo ln -s -f /usr/bin/gcc-11 /usr/bin/gcc

You can check it by running gcc --version.

terrance@terrance-ubuntu:~$ gcc --version
gcc (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8
  • 1
    I appreciate the information in this answer. The note at the top particularly answers another question I had. However, this answer doesn't exactly answer the question. My question is: why is there a mismatch between the default GCC version and the one used to build the kernel and is this scenario not a potential problem? Shouldn't this mismatch be avoided? Commented Jan 15 at 19:42
  • @AdamSperry It is up to Canonical when they build the Kernel with whatever GCC version they may be using before it is pushed to the system. The versions technically are the same, just the name of the compiler itself is different.
    – Terrance
    Commented Jan 15 at 19:52
  • @AdamSperry it's just warnings anyways so it shouldn't be causing any issues. However, if you feel that it should match so it doesn't cause the warnings you are more than welcome to file a bug against the Kernel.
    – Terrance
    Commented Jan 15 at 20:08
  • But the versions are not the same. The default gcc version on Ubuntu 22.04 is gcc-11. The default kernel (6.5.0-14-generic as of today) is built with gcc-12. Are you saying gcc-11 is technically the same as gcc-12? Commented Jan 15 at 21:03
  • @AdamSperry No. I was saying that gcc-12 should already be installed. It is just that the link to the /usr/bin/gcc is not updated to point to gcc-12. They should both be in the path and if you type in gcc-12 --version it should return to you the installed version. The same goes with gcc-11 --version should return the version. If you run ls -al /usr/bin/gcc it should return similar to lrwxrwxrwx 1 root root 15 Jan 13 10:42 /usr/bin/gcc -> /usr/bin/gcc-11
    – Terrance
    Commented Jan 15 at 21:06
0

There are a lot of mismatches in Ubuntu 22.05 GNU compiler versions and the copmpiler used to build the kernel.

ls -l /usr/bin/gcc* ... ls -l /usr/bin/g++* ...

0

I have started Ubuntu bug report.

You must log in to answer this question.

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