Minimum gcc and clang supported to generate FreeBSD binaries

From: Warner Losh <imp_at_bsdimp.com>
Date: Thu, 20 Jun 2024 01:01:28 UTC
Greetings,

I've been having a go at cleaning up sys/cdefs.h for going on 5 years now.
One big problem is that it's chock-o-block of special cases and hacks going
back to the early 1990s (before some people on this list were even born).

I'd like to remove a lot of that, while still retaining useful versions of
gcc and clang to work (plus preserving what support that we have for pcc
and tcc (including fixing the latter). Note: this is "building binaries on
FreeBSD" not "building FreeBSD" which has much much tighter requirements
for compilers. This won't affect that at all.

To that end, I'd like to draw a line in the sand. If you are building
FreeBSD binaries for FreeBSD 15 and newer, you need to use gcc9 (or newer)
or llvm/clang 11 (or newer). Stable/12 has clang 13 at its tip. These
compilers are 5 years old or so. And are the oldest compilers in the ports
tree that we use to generate FreeBSD binaries (there's three older ones:
gcc 6 for ada, gcc 4.2 for TI calculators (but it doesn't use system
headers) and gcc 2.7.2 for hp48 calculators (same). So from a ports
perspective,

From a looking at changes perspective, there's about 30 instances of
GNU_PREREQU in the tree. The newest one is for gcc 5.1. So nominally
supporting just gcc9 and newer means assuming that these are all true
(which is true for gcc and clang) and removing specific support for them.
clang and gcc easily clears these bars.

Ah, but what do you say about tcc and pcc which are't gcc? Well, tcc lies,
and says it supports gcc (version 9 I think, but it's been a while since I
checked). tcc can't work today because we have qsort.h using versioned
symbols unconditionally, and it doesn't support versioned symbols.... And
patches to do that have been stalled for reasons unrelated to this desire.
pcc doesn't support gnuc symbols at all last I checked. But it has real
issues building some things in the tree, so I'll not gate things by it
unless somebody steps up to actually do the work to make it work. The pcc
upstream has been weird lately too.

ICC used to be supported, but unless someone turns up with patches for the
latest icc, it will remain supported only to the extent it pretends to be
gcc. I've had reports that it works, to this extent and nothing special is
needed to build FreeBSD binaries. There are a couple of touch ups required
to build FreeBSD itself with icc I'm told, but I've not seen patches and
have little desire to chase this windmill.

In practical sense, this will just be writing down what's the reality on
the ground today: old compiler versions haven't been tested and there's a
lot of known issues we've introduced since moving to clang that will
preclude even our old gcc 4.2 from working with system headers.

Of course, I'll do an exp run with all these changes. But I wanted to give
people a heads up that I'll be doing this before 15.0 is branched.

For the vast majority (all?) users, I expect you'll not notice.

Warner