5

The Linux kernel now requires gcc v13 in order to compile, but Ubuntu 22.04 is stuck on gcc v11. I found instructions to install the latest native gcc-13 via a PPA (https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/ppa), but I don't see any way to install the v13 aarch64 (aka ARM64) cross-compiler. The PPA says that it contains "gcc-13-cross", but that does not appear to be a package that I can install.

Artur Meinild
  • 26,018

1 Answers1

4

The recommended way

Ubuntu 23.04 has both the packages you seem to need and in the versions that you require i.e. gcc-13 and gcc-13-aarch64-linux-gnu in the [security] [universe] repository and Ubuntu 23.10 has them in the [main] repository ... So, my advice would, naturally, be to upgrade your system to Ubuntu 23.04 or even 23.10 and then install your desired packages like so:

sudo apt update && sudo apt install gcc-13 gcc-13-aarch64-linux-gnu

That is the recommended and safest way.

The hacky way

Otherwise, it's the on your own risk way ... e.g. adding a PPA such as you did ... Yep, you have already chosen the "on your own risk way" ... Read this (emphasis is mine):

Adding this PPA to your system

You can update your system with unsupported packages from this untrusted PPA by adding ppa:ubuntu... to your system's Software Sources.

... that text is quoted from the Launchpad link you included in your question and it's not limited to that specific PPA (which might be of good reputation), but it is what it is.

That PPA enables for installing the package gcc-13 on Ubuntu 22.04 by essentially including that package with its dependencies that can not be satisfied from the Ubuntu 22.04 official repositories and of course some other work might be involved like modifying post-install and/or pre-install scripts and ensuring none of the added package or its dependencies will conflict with existing essential system packages and so forth.

In the case of gcc-13 and gcc-13-aarch64-linux-gnu, which are also made available in Ubuntu 23.04/23.10 official repositories, one might ponder the possibility of installing them from 23.04/23.10 repositories on an Ubuntu 22.04 system? ... Well, yeah surely possible (for these two) and it should make the "on your own risk" zone a bit more appealing as those repositories are official and trusted, but the unsupported part will still apply.

Anyway, I have quickly traced those two packages and their dependencies and then installed both from the official repositories of Ubuntu 23.10 on an Ubuntu 22.04 system successfully without any noticeable drawbacks AFAIK ... After all the GNU C compiler is not essential to the functionality of Ubuntu and is offered as an optional package for manual install.

However, there is probably most likely certainly an extremely big problem awaiting if you're not careful enough i.e. you must make sure no other packages from that repository get installed by any means including automatic-updates so turn all those off and fully update your system first, then follow all instructions precisely (still on your own risk of course) ... If other packages got installed, they might break your system so dangerously badly and possible beyond any applicable repair and of course this is as unsupported as your PPA installed packages ... So, we will not provide any support for either.

Needless to say that I don't prefer it or like it this way, but you seem to need it so I wrote it.

The idea is, basically, to add the official Ubuntu repository containing those two packages, refresh the local cached sources list, install those two packages and promptly delete the added repository from you system like so:

First, add the repository:

echo "deb http://cz.archive.ubuntu.com/ubuntu mantic main" |
sudo tee /etc/apt/sources.list.d/temporary-repository.list

Second, update package lists:

sudo apt update

Third, only install gcc-13 and gcc-13-aarch64-linux-gnu:

sudo apt install gcc-13 gcc-13-aarch64-linux-gnu

Fourth, delete that temporary repository:

sudo rm /etc/apt/sources.list.d/temporary-repository.list

Finally, update your cached packages lists:

sudo apt update

Notice

  • You might need to first remove the gcc-13 package you have already installed from that PPA and the PPA itself to avoid possible dependency version mismatch.

  • You'll need to run those by version number i.e. gcc-13 -v and aarch64-linux-gnu-gcc-13 -v and not just gcc or you can use the Ubuntu alternatives system to choose the default version.

Raffa
  • 32,237
  • 1
    Is it typical that updating your gcc version requires you to update your Ubuntu version as well? – dshin Mar 11 '24 at 18:07
  • @dshin Technically yes ... But, actually, it's the other way around i.e. a new release brings with it newer versions of packages ... That's formally speaking, but an experienced user like you sure knows their way around that but you'll be on your own then with no support from us :) ... I am sure you understand all that ... However, even for an advanced user, to save time and ensure the rest of the system's dependencies are kept in place and functional for their specific release, they should stick with what their release offers or upgrade to the next one but avoid mixing dependencies. – Raffa Mar 12 '24 at 18:29