From owner-freebsd-amd64@FreeBSD.ORG Fri Aug 1 01:04:35 2008 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 103DD106566B for ; Fri, 1 Aug 2008 01:04:35 +0000 (UTC) (envelope-from chuckr@telenix.org) Received: from mail4.sea5.speakeasy.net (mail4.sea5.speakeasy.net [69.17.117.6]) by mx1.freebsd.org (Postfix) with ESMTP id DE1468FC0C for ; Fri, 1 Aug 2008 01:04:34 +0000 (UTC) (envelope-from chuckr@telenix.org) Received: (qmail 28607 invoked from network); 1 Aug 2008 01:04:34 -0000 Received: from april.chuckr.org (HELO april.telenix.org) (chuckr@[66.92.151.30]) (envelope-sender ) by mail4.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 1 Aug 2008 01:04:34 -0000 Message-ID: <48926106.4010305@telenix.org> Date: Thu, 31 Jul 2008 21:04:06 -0400 From: Chuck Robey User-Agent: Thunderbird 2.0.0.6 (X11/20071107) MIME-Version: 1.0 To: Nate Eldredge References: <4891F3F3.8090608@telenix.org> <20080731195527.GT1359@server.vk2pj.dyndns.org> <489243B0.80307@telenix.org> <20080731234107.GA99946@troutmask.apl.washington.edu> In-Reply-To: X-Enigmail-Version: 0.95.5 OpenPGP: id=F3DCA0E9; url=http://pgp.mit.edu Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-amd64@freebsd.org Subject: Re: app programming on freebsd amd64 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Aug 2008 01:04:35 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Nate Eldredge wrote: > On Thu, 31 Jul 2008, Steve Kargl wrote: > >>> He's telling you that -m32 doesn't work because the necessary >> run time support is missing. > > It's not really missing completely though. Just that gcc isn't set up > to look for it in the right place. > OK, the flags you nicely gave me are enough to let me do my own experimentation, so thanks. I'm quite used to things like -I, -L, -l, -g, like that, it's the arch and machine options that I'm not as used to. Should see me on ARM options, I am all over the road on that platform. Dangerous. >> >> troutmask:kargl[202] cat h.c >> #include >> int main(void) >> { >> printf("Hello world!\n"); >> return 0; >> } >> troutmask:kargl[203] cc -o z h.c >> troutmask:kargl[205] ldd z >> z: >> libc.so.7 => /lib/libc.so.7 (0x20063c000) >> troutmask:kargl[206] file z >> z: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), for FreeBSD >> 8.0 (800040), dynamically linked (uses shared libs), FreeBSD-style, >> not stripped >> troutmask:kargl[207] cc -o z -m32 h.c >> /usr/bin/ld: skipping incompatible /usr/lib/libgcc.a when searching >> for -lgcc >> /usr/bin/ld: skipping incompatible /usr/lib/libgcc.a when searching >> for -lgcc >> /usr/bin/ld: cannot find -lgcc > > nate@vulcan:/tmp$ gcc -c -m32 h.c > nate@vulcan:/tmp$ gcc -v -o h -m32 h.o > Using built-in specs. > Target: amd64-undermydesk-freebsd > Configured with: FreeBSD/amd64 system compiler > Thread model: posix > gcc version 4.2.1 20070719 [FreeBSD] > /usr/bin/ld --eh-frame-hdr -m elf_i386_fbsd -V -dynamic-linker > /libexec/ld-elf.so.1 -o h /usr/lib/crt1.o /usr/lib/crti.o > /usr/lib/crtbegin.o -L/usr/local/lib -L/usr/local/lib -L/usr/lib > -L/usr/lib h.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc > --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o > GNU ld version 2.15 [FreeBSD] 2004-05-23 > Supported emulations: > elf_i386_fbsd > elf_x86_64_fbsd > /usr/bin/ld: skipping incompatible /usr/lib/libgcc.a when searching for > -lgcc > /usr/bin/ld: skipping incompatible /usr/lib/libgcc.a when searching for > -lgcc > /usr/bin/ld: cannot find -lgcc > > So it's still looking for things in /usr/lib when it should use > /usr/lib32. We can call ld directly and give it the right things: > > nate@vulcan:/tmp$ /usr/bin/ld --eh-frame-hdr -m elf_i386_fbsd -V > -dynamic-linker /libexec/ld-elf32.so.1 -o h /usr/lib32/crt1.o > /usr/lib32/crti.o /usr/lib32/crtbegin.o -L/usr/lib32 h.o -lgcc > --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s > --no-as-needed /usr/lib32/crtend.o /usr/lib32/crtn.o > GNU ld version 2.15 [FreeBSD] 2004-05-23 > Supported emulations: > elf_i386_fbsd > elf_x86_64_fbsd > nate@vulcan:/tmp$ file ./h > ./h: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), for > FreeBSD 7.0 (700055), dynamically linked (uses shared libs), > FreeBSD-style, not stripped > nate@vulcan:/tmp$ ./h > Hello world! > > It might be that there is some set of options to gcc itself that would > make the right thing happen here without calling ld directly. More > likely someone would have to write a new specs file. But that's a > relatively minor issue; the guts are there. > > Now it may be that the 32-bit runtime has bugs that would appear if we > tried to do something more complicated. But it isn't totally absent. > -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkiSYQYACgkQz62J6PPcoOknDACeLbHXjrWRgVaJqQbsXsYcKPqZ XVYAn2Rne6f0JWkjljh9vAXIMyU7fNc0 =OwA/ -----END PGP SIGNATURE-----