From owner-freebsd-hackers@FreeBSD.ORG Wed Jul 20 11:33:53 2011 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83C6F1065670 for ; Wed, 20 Jul 2011 11:33:53 +0000 (UTC) (envelope-from jhs@berklix.com) Received: from tower.berklix.org (tower.berklix.org [83.236.223.114]) by mx1.freebsd.org (Postfix) with ESMTP id E22588FC08 for ; Wed, 20 Jul 2011 11:33:52 +0000 (UTC) Received: from park.js.berklix.net (p5DCBEA02.dip.t-dialin.net [93.203.234.2]) (authenticated bits=0) by tower.berklix.org (8.14.2/8.14.2) with ESMTP id p6KBXeMh076085; Wed, 20 Jul 2011 11:33:41 GMT (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (fire.js.berklix.net [192.168.91.41]) by park.js.berklix.net (8.13.8/8.13.8) with ESMTP id p6KBXgA4027653; Wed, 20 Jul 2011 13:33:42 +0200 (CEST) (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (localhost [127.0.0.1]) by fire.js.berklix.net (8.14.4/8.14.4) with ESMTP id p6KBXQTr006861; Wed, 20 Jul 2011 11:33:31 GMT (envelope-from jhs@fire.js.berklix.net) Message-Id: <201107201133.p6KBXQTr006861@fire.js.berklix.net> To: Dan Nelson From: "Julian H. Stacey" Organization: http://www.berklix.com BSD Unix Linux Consultancy, Munich Germany User-agent: EXMH on FreeBSD http://www.berklix.com/free/ X-URL: http://www.berklix.com In-reply-to: Your message "Sat, 16 Jul 2011 21:02:21 CDT." <20110717020220.GM6611@dan.emsphone.com> Date: Wed, 20 Jul 2011 13:33:26 +0200 Sender: jhs@berklix.com Cc: "Julian H. Stacey" , hackers@freebsd.org Subject: Re: Freebsd-7.4 + std gcc 4.2.1 fails to honour -march=i586 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2011 11:33:53 -0000 Hi Dan cc list Dan Nelson wrote: > In the last episode (Jul 17), Julian H. Stacey said: > > Hi all, > > ENVIRONMENT: > > Standard > > gcc version 4.2.1 20070719 [FreeBSD] > > that comes with > > FreeBSD 7.4-RELEASE > > on my 686 host with > > CFLAGS += -march=i586 > > in > > /etc/make.conf > > used with > > cd /usr/src/bin/who ; make clean ; make cleandir ; make clean ; make > > reports > > Warning: Object directory not changed from original /usr/src/usr.bin/who > > cc -O2 -fno-strict-aliasing -march=i586 -c /usr/src/usr.bin/who/who.c > > cc -O2 -fno-strict-aliasing -march=i586 -o who who.o > > looking with > > file who > > reports > > who: ELF 32-bit LSB executable, Intel 80386, version 1 > > (FreeBSD), for FreeBSD 7.4, dynamically linked (uses shared > > libs), FreeBSD-style, not stripped > > > > Problem: > > Use it from a 586 7.4-RELEASE host (AMD+NFS) > > file /host/sony/usr/src/usr.bin/who/who > > /host/sony/usr/src/usr.bin/who/who: ELF 32-bit LSB executable, > > Intel 80386, version 1 (FreeBSD), for FreeBSD 7.4, dynamically > > linked (uses shared libs), FreeBSD-style, not stripped > > /host/sony/usr/src/usr.bin/who/who > > fails with > > Illegal instruction > > Were the crt*.o files on your fast machine also compiled with -march=i586 ? No. I hadn't thought of that, Thanks. Trying below. > If you run gdb on the core file, can you determine what function the bad > instruction is in? host=686: cc -O2 -fno-strict-aliasing -march=i586 -g -c who.c cc -O2 -fno-strict-aliasing -march=i586 -g -o who who.o mv who /host/lapn/tmp/who 586: /tmp/who Illegal instruction gdb /tmp/who run Starting program: /tmp/who Program received signal SIGILL, Illegal instruction. 0x08048a5a in _start1 () (gdb) backtrace #0 0x08048a5a in _start1 () #1 0x08048a18 in _start () #2 0x2804f960 in dlclose () from /libexec/ld-elf.so.1 #3 0x00000001 in ?? () 686: change make.conf to CFLAGS += -march=i586 -g Search for crt in Makefile: contrib/gccMakefile.in make clean not supported gnu/lib/csu/Makefile lib/csu/i386-elf/Makefile cd /usr/src ; make clean cd lib/csu/i386-elf ; make install install -o root -g wheel -m 444 crti.o crtn.o gcrt1.o \ crt1.o Scrt1.o /usr/lib cd /usr/lib ; ls -l crti.o crtn.o gcrt1.o crt1.o Scrt1.o -r--r--r-- 1 root wheel 5032 Jul 20 11:42 Scrt1.o -r--r--r-- 1 root wheel 4900 Jul 20 11:42 crt1.o -r--r--r-- 1 root wheel 1680 Jul 20 11:42 crti.o -r--r--r-- 1 root wheel 1636 Jul 20 11:42 crtn.o -r--r--r-- 1 root wheel 5117 Jul 20 11:42 gcrt1.o cd /usr/src/usr.bin/who ; make mv who /host/lapn/tmp/who2 586 /tmp/who2 # Runs OK 686 make.conf CFLAGS += -march=i686 -g cd /usr/src/lib/csu/i386-elf make clean ; make ; make install make.conf CFLAGS += -march=i586 -g cd /usr/src/usr.bin/who ; make clean ; make ; mv who /host/lapn/tmp/who3 586 /tmp/who3 gdb /tmp/who3 (gdb) run Starting program: /tmp/who3 Program received signal SIGILL, Illegal instruction. 0x08048a5a in _start1 (cleanup=0x2804f960 , argc=1, argv=0xbfbfe37c) at /usr/src/lib/csu/i386-elf/crt1_c.c:75 75 __progname = s + 1; (gdb) bt #0 0x08048a5a in _start1 (cleanup=0x2804f960 , argc=1, argv=0xbfbfe37c) at /usr/src/lib/csu/i386-elf/crt1_c.c:75 #1 0x08048a18 in _start () at /usr/src/lib/csu/i386-elf/crt1_s.S:42 #2 0x2804f960 in dlclose () from /libexec/ld-elf.so.1 #3 0x00000001 in ?? () 686 make.conf CFLAGS += -march=i686 -g cd /usr/src/gnu/lib/csu ; make clean ; make ; make install cd /usr/src/usr.bin/who ; make clean ; make mv who /host/lapn/tmp/who4 586 /tmp/who4 Illegal instruction gdb /tmp/who4 run Starting program: /tmp/who4 Program received signal SIGILL, Illegal instruction. 0x08048a5a in _start1 (cleanup=0x2804f960 , argc=1, argv=0xbfbfe37c) at /usr/src/lib/csu/i386-elf/crt1_c.c:75 75 __progname = s + 1; 686 cc -O2 -fno-strict-aliasing -march=i686 -g -v -o who who.o Using built-in specs. Target: i386-undermydesk-freebsd Configured with: FreeBSD/i386 system compiler Thread model: posix gcc version 4.2.1 20070719 [FreeBSD] /usr/bin/ld --eh-frame-hdr -V -dynamic-linker \ /libexec/ld-elf.so.1 -o who /usr/lib/crt1.o /usr/lib/crti.o \ /usr/lib/crtbegin.o -L/usr/lib -L/usr/lib who.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 What should FreeBSD do ? Add a comment to man gcc ... that -march=i586 is not enough, & feed the comment back to gcc project & see how they want to handle it ? Have seperate FreeBSD subdirs for 3,4,5,6 /usr/lib/crt1.o ? Question: with more complex programs than who, might there be sensitivity to other libs too ? PS I recall there's a FreeBSD tool chain group ? I can't see a list name in http://lists.freebsd.org/mailman/listinfo There is freebsd-i386@ Cheers, Julian -- Julian Stacey, BSD Unix Linux C Sys Eng Consultants Munich http://berklix.com Reply below, not above; Indent with "> "; Cumulative like a play script. Format: Plain text. Not HTML, multipart/alternative, base64, quoted-printable.