The possibility of this happening came up in the discussion here: #31158 (comment), and it turned that we already had a case of it in our code.
tl;dr: Certain symbols when defined in headers may end up existing in both the shared lib and the application using it, leading to subtle bugs. More info can be found here.
The solution is generally to avoid defining static/inline vars in headers if they aren’t meant to be shared with downstream kernel users.
Clang has recently added a warning for this (see link above), so this PR enables that too. It adds a new place to specify warnings which only apply to the kernel. In this case, it’s warnings that only apply to shared libs. But I can also imagine wanting to enable more aggressive warnings for the kernel than the rest of the code.
The warning is only enabled by clang 21 (which is not yet released), and only useful when our kernel symbol visibility hack is disabled, which we can’t do yet. So it’s mostly a placeholder for the future. In the meantime it can be used manually by building clang from git and disabling our hack, which I’ve done, and can confirm that after this change there are no more warnings.