Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Nov 2010 07:48:22 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        Warner Losh <imp@bsdimp.com>
Cc:        Garrett Cooper <gcooper@freebsd.org>, Warner Losh <imp@freebsd.org>, Tijl Coosemans <tijl@coosemans.org>, Dimitry Andric <dim@freebsd.org>, freebsd-arch@freebsd.org
Subject:   Re: Support for cc -m32
Message-ID:  <201011180748.23094.jhb@freebsd.org>
In-Reply-To: <4CE46602.9000303@bsdimp.com>
References:  <201007291718.12687.tijl@coosemans.org> <201011171718.37798.jhb@freebsd.org> <4CE46602.9000303@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, November 17, 2010 6:32:18 pm Warner Losh wrote:
> On 11/17/2010 15:18, John Baldwin wrote:
> > On Wednesday, November 17, 2010 2:57:51 pm Tijl Coosemans wrote:
> >> cc-m32-3.diff:
> >>      Modify amd64 headers to include i386 headers when compiling 32 bit code.
> >>
> >>      All amd64 headers follow the following format:
> >>
> >>      #ifndef _AMD64_HEADER_H_
> >>      #define _AMD64_HEADER_H_
> >>
> >>      #ifdef __i386__
> >>      #include<i386/header.h>
> >>      #else
> >>
> >>      /* Amd64 declarations go here. */
> >>
> >>      #endif /* __i386__ */
> >>      #endif /* !_AMD64_HEADER_H_ */
> > I find this to be really ugly, and error prone (since it is a manual process).
> > I'd prefer something that autogenerated headers in /usr/include/machine that
> > #include the appropriate version similar to what Warner suggested.
> >
> > However, one issue with that approach (and this one) are headers that only
> > exist for one platform.  The end result would be that that header would now
> > exist for both platforms (in that if you do 'if [ -r
> > /usr/include/machine/foo.h ]' it will be true).  We can make it #error or
> > otherwise fail (by including a non-existing file for example), but if there
> > was some way to have cc -m32 "magically" substitute "i386/" for "machine",
> > that is what I would most prefer.  (This has problems too in that #include
> > <machine/foo.h>  would work with -m32 even though /usr/include/machine/foo.h
> > doesn't exist, but /usr/include/i386/foo.h does.
> "magically" converting machine -> i386 requires cpp hacking.
> 
> However, the if [] test is beyond the scope of the API that we support.  
> Scripts that use -m32 will have to cope with other issues.

My worry is a ./configure-like script for the native API (e.g. amd64) that
will find an i386-only header in /usr/include/machine and fail to compile as
a result.  However, as I pointed out above, there really isn't an easy
solution to this problem that covers all of the cases (even rewriting "machine"
to "i386" doesn't cover many cases).  I'm not really sure that 'if []' can
even be solved, but it is one of the non-obvious considerations.

> I contend that the least bad solution is to auto generate the machine 
> directory from the sys/{i386,amd64}/include.  If we do that, we could 
> implement -m64 on i386 too, but that needs a lot more infrastructure.

I would prefer that to manually patching amd64 headers, certainly.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201011180748.23094.jhb>