5

I don't use Ubuntu very much, being a platforms and builds engineer in an organisation that's primarily Red Hat Enterprise and its work-alikes.

The problem with just building and using an up-to-date GCC is the language run-time libraries. I would either have to distribute them, complicating shipments and making the lawyers nervous about GPL, or require my customers to build and install the same GCC.

I produce closed-source commercial software, mostly mathematical modelling, compiled from C and C++ source and shipped as shared libraries. This means I'm extremely interested in achieving cross-distribution binary compatibility. This is practical because everything my libraries need is available from glibc and the GCC language run-times (libgcc_s.so.1 and libstdc++.so.6). Both those sets of libraries have very strong forwards compatibility, due to all their symbols being versioned, and new versions being created every time there's a behaviour change.

At present, I do my builds on RHEL 8.x. This has fairly old GCC (8.x) and glibc (2.28), so if I built my libraries using it naively, I'd have forwards compatibility to Linuxes with equal or later versions of those libraries. However, that old GCC doesn't handle the C++20 language standard, which the developers very much want to use, still less the new C++23 standard. RHEL provides a solution for this, but I haven't found anything similar for Ubuntu.

The Red Hat solution is a "GCC Toolset". There are a range of these, but they all work the same way. They provide a later version of GCC, built to run on RHEL 8.x's run-times, the standard headers, and some special scripts for GNU ld. Those scripts tell the linker to use the system libraries for the GCC language run-times where possible, and for functions that aren't in the system libraries, statically link the required code into the shared library (or executable) being linked. This sounds scary, but works extremely well. This is probably because Red Hat are major contributors to GCC and make sure it stays working.

Does Ubuntu have anything similar? I would like to have an alternative to Red Hat, in case their exploitation of GPL loopholes succeeds in stamping out the work-alikes for their OS, which is too expensive to run on every single test machine.

My current knowledge of Ubuntu compiling and run-times is explained in my answer to a related question here.

For the C++20 case, moving to Ubuntu LTS 22.04 would fill the need. However, C++23 is starting to appear. We can expect Ubuntu LTS 24.04 quite soon, but it will likely be too early for the C++23 support in GCC 14, due to be released in April or May 2024. I'm making the assumption that "Enterprise" Ubuntu customers will only install LTS versions on their main servers, rather than the intermediate versions.

If Ubuntu doesn't do this, that's OK. Given it's an Enterprise Linux, I thought I might be missing something.

2 Answers2

5

I'm not aware of something similar in Ubuntu to the 'shim libraries' you describe - and which admittedly are an elegant solution to a problem. However, I think the problem isn't quite as prominent in Ubuntu.

Ubuntu releases generally include (and are built with, see the toolchain PPA and related Wiki Page) the latest upstream GCC release.

E.g. 22.04 LTS had GCC 11.2, which was the latest FSF release at the time, and Ubuntu 23.10 has GCC 13.2, the current release by FSF (July '23). With Ubuntu releases coming out every six months, in practice you'll always be on the latest GCC.

(There is even the gcc-snapsnot package with the latest upstream development version of GCC, but that's not intended for distributable builds.)

The problem would then only exist for developers working with, say, 20.04 LTS (the oldest supported Ubuntu release), who need a compiler newer than GCC 9.3. I can't think of a simpler solution for that problem than just upgrade to 22.04 LTS or 23.10, and get the latest GCC for free with it.

Also, if they need features from the latest GCC (and are targeting Ubuntu), then this would almost certainly be to build software for the next release. Why would they do that from 20.04 LTS?

Whereas if this is for maintenance of software on a supported release (currently 20.04, 22.04 and 23.10), then it would be unlikely that that necessitates a GCC major upgrade. This could be more of a problem though for Canonical, with the extended maintenance (ESM) programme.

zwets
  • 12,354
3

Yes. Go to https://gnu.org, download the GCC source and build environment, install the build-essential package. Read all the README* files and other documents that come with it. Read man hier to see where to put it (probably the /usr/local tree) and specify it when you run ./configure

waltinator
  • 36,399