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.
Asked
Active
Viewed 7.7k times
1 Answers
19
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.
Terrance
- 43,712