Date: Fri, 13 Aug 2010 16:44:57 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: Yuri <yuri@rawbw.com> Cc: freebsd-questions@freebsd.org Subject: Re: Documentation on how to build 32bit applications on amd64? Message-ID: <20100813214457.GF18896@dan.emsphone.com> In-Reply-To: <4C65852B.807@rawbw.com> References: <4C656E8F.8090105@rawbw.com> <20100813162429.GE18896@dan.emsphone.com> <4C65852B.807@rawbw.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Aug 13), Yuri said: > On 08/13/2010 09:24, Dan Nelson wrote: > > Try adding -B/usr/lib32 to your first gcc line. The specs file should > > be modified to add this automatically when you pass -m32, imho. > > Thank you Dan, this flag worked. > > But I found a strange discrepancy between 32bit and 64bit. > When I compile the program below in 64 bit, I get the correct result. > With 32 bit executable compiled on 64 bit system like you suggested > there is another (wrong) result. On 32 bit system result is also > correct, the same as with 64 executable. > > This is a very strange discrepancy. rm_eo field is zero in the match > result which is wrong. I can't think of any explanation for it. I think Anonymous is right, and that it's due to the /usr/include headers on amd64 not being 32-bit-mode aware. So you end up with some structure members being sized for 64-bit machines instead of 32-bit. I bet struct regex_t on your cross-compiled program is the same size as your native 64-bit program, where it should match your 32-bit program instead. I took that "-B /usr/lib32" flag from /usr/src/Makefile.inc1 , where it builds the lib32 compat libraries, and it looks like it also temporarily installs a full 32-bit include directory and compiles against that with "-iprefix ${LIB32TMP}/usr/" . You may have to install a full 32-bit tree somewhere and chroot to it to build, or look more closely at how buildworld compiles the lib32 stuff and mimic that, or submit patches to the base include files that make them 32 and 64-bit compatible depending on compiler flags. -- Dan Nelson dnelson@allantgroup.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100813214457.GF18896>