Freebsd-7.4 + std gcc 4.2.1 fails to honour -march=i586
Julian H. Stacey
jhs at berklix.com
Wed Jul 20 11:33:53 UTC 2011
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 <dlclose+432>, 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 <dlclose+432>, 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 <dlclose+432>, 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.
More information about the freebsd-hackers
mailing list