FreeBSD is defined by the compiler derived from the triple. When
building FreeBSD 11 on a FreeBSD 12 with a CROSS_TOOLCHAIN=llvm10,
FreeBSD was set to 12 when building lib32 (for some reason no triple
is being passed which seems to mean that we're taking default values
from the build system). This in turn meant we end up with a double
decleration of union semun which is a build error.
Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
This could also be fixed by consistently setting the -target flag when building sources. For instance, on stable/12 the default (x86_64-unknown-freebsd12.2 in my case) gives:
% clang -dM -E -x c /dev/null|grep __FreeBSD__ #define __FreeBSD__ 12
But if you use a lower version in the target, clang uses its (major) version instead:
% clang -target x86_64-unknown-freebsd11.4 -dM -E -x c /dev/null|grep __FreeBSD__ #define __FreeBSD__ 11
The check is also just plain wrong. The question isn't "what version of FreeBSD is the compiler targeting?" It's "what version of FreeBSD is providing the headers?" Obviously they should match, but checking the right thing means I don't have to dig into libcompat build bits on 11.
Yes, I agree. __FreeBSD__ is mostly to be used for "am I on FreeBSD at all" checks, that it has a major version in it is maybe a little misleading. The only disadvantage of __FreeBSD_version is that you have to include <osreldate.h> at least.
Technically speaking this code is broken on FreeBSD <2 (see the code right above this), but I can't bring myself to do the reshuffling to fix that...
I've added the fix upstream using the following diff (slightly different than your diff):