Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Mar 2005 17:27:44 -0500
From:      John Baldwin <jhb@FreeBSD.org>
To:        freebsd-amd64@FreeBSD.org
Cc:        "Carlos F. A. Paniago" <pan@cnpm.embrapa.br>
Subject:   Re: fstatfs break in amd64 ia32 emulation
Message-ID:  <200503311727.44841.jhb@FreeBSD.org>
In-Reply-To: <424C3C98.30602@cnpm.embrapa.br>
References:  <424C3C98.30602@cnpm.embrapa.br>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 31 March 2005 01:08 pm, Carlos F. A. Paniago wrote:
> hi:
> I'm tring to compile in an amd64 and running in an i386.. I read in the
> list that is not possible, but some things work if we compile using:
> gcc -Di386 -D__i386__ -Uamd64 -U__amd64__ -m32 -B/lib32 -B/usr/lib32 -g
> -o test-i386.amd test-i386.c
> some simple program could be compiled in an amd64 machine and run in a
> i386 machine.
> but this program don't work:
> --
> #include <stdio.h>
> #include <sys/param.h>
> #include <sys/mount.h>
> #include <sys/errno.h>
>
> int main(int argc, char** argv)
> {
>         struct statfs buf;
>
>         if (fstatfs(0, &buf) < 0) {
>                 perror("fstatfs");
>         }
>
>         printf("%d %d\n", sizeof(buf), sizeof(&buf));
>         return 0;
> }
> --
> the result is:
> ---
> ipe# ./test-i386
> 472 4
> ipe# ./test-i386.amd
> 384 4
> Segmentation fault (core dumped)
> ipe#
> ---
> this ipe machine is an i386 machine... the ./test-i386 is compiled in
> this machine as
> gcc -g -o test-i386 test-i386.c
> and the ./test-i386.amd is compiled in an amd64 using: gcc -Di386
> -D__i386__ -Uamd64 -U__amd64__ -m32 -B/lib32 -B/usr/lib32 -g -o
> test-i386.amd test-i386.c
> The strange thing is the size of struct statfs that changes... If I
> compile this in an amd64 machine (oliveira is an amd64 machine)
> ---
> oliveira: {248} gcc -g -o test-i386.amd test-i386.c
> oliveira: {249} ./test-i386.amd
> 472 8
> oliveira: {250}
> ---
> strange the size of the struct is the same as in i386 and the size of
> the pointer is 8 (instead of 4), but in the compilation using the -m32
> the sizeof is strange... Someone know how to solve this problem???

You need to be using a different /usr/include, specifically a 
different /usr/include/machine (one from an i386 machine) when trying to 
compile -m32.

-- 
John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org



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