[PATCH] fake pre-processor macros when building on non-FreeBSD system

Robert Millan rmh at debian.org
Wed Jul 13 07:00:41 UTC 2011


2011/7/13 Nathan Whitehorn <nwhitehorn at freebsd.org>:
> The one I meant was the third one. Linux and FreeBSD happen, though not
> entirely by chance, to use almost exactly the same ABI on most platforms
> (but not all!). Assuming, and requiring, interchangeability of ABIs here
> thus seems like a poor choice. Once you've decided you might have a
> different ABI, you need a cross-compiler, and that would simultaneously take
> care of defining various platform-specific macros.
>
> The "isn't actually that different" comment, which wasn't a particularly
> useful thing to say, was that you could conceivably claim, under very broad
> definitions of what ABI means, that having __FreeBSD__ defined is in fact a
> part of the system ABI, just like the calling conventions or the stack frame
> layout. In either case, you would be expected to use a cross-compiler.

I understand the problem you describe, but I don't see how this is
related to the presence of those macros.

C ABI is selected with compiler flags such as -mabi=n32 or
-mregparm=3.  There's no technical requirement for your kernel ABI to
match your userland ABI.  If it does, it is an arbitrary choice (or
coincidence).

In either case, when you tell me that there's something special with
regard to C ABI when GCC has been compiled for FreeBSD userland, I
can't make any sense of this.  In first place, because none of
gcc/config/i386/freebsd.h implies it.  In second place, because other
projects (like GRUB) also have specific ABI requirements, and never
had this kind of problem.

However, there's clear evidence that none of this is intended in the
source code.  If existing practice in the FreeBSD tree supported your
claim, you'd see things like:

#ifndef __FreeBSD__
#error "we can't garantee that this compiler implements the desired C ABI"
#endif

but none of this happens.  Instead, __FreeBSD__ is used to check for tautology:

#ifdef __FreeBSD__
// working code here
#elif __NetBSD__
// include headers that aren't present anywhere in the kernel tree
#endif

I understand the purpose of this, but please don't tell me it has
anything to do with C ABI.

-- 
Robert Millan


More information about the freebsd-hackers mailing list