Re: [PATCH RFC] kbuild: Prevent compiler mismatch with external modules

From: Josh Poimboeuf
Date: Thu Jan 28 2021 - 16:35:46 EST


On Thu, Jan 28, 2021 at 01:23:11PM -0800, Linus Torvalds wrote:
> On Thu, Jan 28, 2021 at 1:03 PM Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > I really think the whole compiler version check is purely voodoo programming.
>
> .. but there are obviously potentially things we - in the kernel - do
> that may make certain compiler versions incompatible. We long long ago
> used to have things like "you can't have an empty struct because gcc
> version x.y.z doesn't support it", so even a UP spinlock would be
>
> typedef struct { int gcc_is_buggy; } raw_spinlock_t;
>
> but only if you compiled it with a version of gcc older than 3.0. So
> compiling one file with one compiler, and another with a newer one,
> would result in the data structures simply not having the same layout.
>
> That's not because of compiler versions per se, it's because of our
> version checks.

Right, this is what I'm trying to say. We have features based on
compiler version checks. Peterz pointed out asm goto as a previous
example.

> THAT workaround is long gone, but I didn't check what other ones we
> might have now. But the gcc version checks we _do_ have are not
> necessarily about major versions at all (ie I trivially found checks
> for 4.9, 4.9.2, 5.1, 7.2 and 9.1).

Then maybe the check should be same major.minor?

And convert it to a strongly worded warning/disclaimer?

--
Josh