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

Alexander Kabaev kabaev at gmail.com
Tue Jul 12 23:39:44 UTC 2011


On Tue, 12 Jul 2011 23:59:05 +0200
Robert Millan <rmh at debian.org> wrote:

> 2011/7/12 Alexander Kabaev <kabaev at gmail.com>:
> > The fact that Linux compiler with manually undefined and re-defined
> > platform macros can compile is a coincidence and is not guaranteed
> > to work and certainly is not a goal of FreeBSD project so this can
> > be broken at any moment.
> 
> There must be some missunderstanding, I never asked the FreeBSD
> project to garantee this works, or that it won't break in the future.
> I'm not holding anyone responsible in case it breaks, or anything
> similar to that.
> 
> Once it works, however, it is not a coincidence: We've been working to
> archieve this (most of my other patches sent to this list go in this
> direction).
> 

But it is the coincidence. See the other email by Nathan, I could not
have said it better. Just defining __FreeBSD__ in Linux compiler does
not magically turn it into compiler for FreeBSD.

> That aside, it seems there's some interest in FreeBSD community about
> building the kernel on GNU/Linux.  In particular, MIPS porters have it
> in their TODO list:
> http://wiki.freebsd.org/FreeBSD/mips/todo
> 

Not sure what they mean there. There is a general desire for FreeBSD to
be able to build the first set of bootstrap tools on other OSes (Linux,
MAC OS X) that has come up several times in recent years. Host tools
were to be used to build cross-toolchain only in all discussions I've
been part of so far.

> > putting hacks into
> > FreeBSD sources to legitimize the practice is not the move I would
> > support as well. Traditionally, IMHO.
> 
> I try to take a neutral stance and merely follow on what the source
> tree expects.  If the source tree does things like:
> 
> #ifdef __FreeBSD__
> // code that expects to be built as part of the FreeBSD kernel tree
> // (this chunk of code is invariably what we want, no matter the
> compiler we're using)
> #endif
> 
> #ifdef __linux__
> // code that expects to be built as part of the Linux tree
> // (this chunk of code depends on out-of-tree headers and will never
> build, no matter the compiler we're using)
> #endif
> 
> I naively read this as "when building kernel code, we assume these
> macros refer to *what* we're building rather than to what are we
> building it *for*".
> 

See Nathan's email again. __FreeBSD__ also means that code can expect
certain ABI or some other detail to match established FreeBSD practice,
which are not necessarily adhered to by the Linux compiler. Take your
own example and imagine using the same assumption with Mac OS X
toolchain. *what* and *for* both apply here, if I understand your
dilemma correctly.

> My naive mind can't tell if this assumption is correct or not, it
> merely tries to adapt to existing practice. If the assumption is not
> correct, then I would propose a different kind of solution to the
> problem.
> 
> So before we proceed, could you clarify whether the assumption is
> correct or not?
> 


-- 
Alexander Kabaev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20110712/36b0e874/signature.pgp


More information about the freebsd-hackers mailing list