From owner-freebsd-stable@FreeBSD.ORG Wed Oct 24 11:00:46 2012 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6A90DE1D for ; Wed, 24 Oct 2012 11:00:46 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) by mx1.freebsd.org (Postfix) with ESMTP id ADD3D8FC08 for ; Wed, 24 Oct 2012 11:00:45 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:b489:24:8697:7e27] (unknown [IPv6:2001:7b8:3a7:0:b489:24:8697:7e27]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 8D11D5C59; Wed, 24 Oct 2012 13:00:44 +0200 (CEST) Message-ID: <5087CA5D.2090407@FreeBSD.org> Date: Wed, 24 Oct 2012 13:00:45 +0200 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Volodymyr Kostyrko Subject: Re: wine, gcc and clang with CPUTYPE References: <50879F62.2010004@gmail.com> <5087BD71.9090002@FreeBSD.org> <5087C428.2020908@gmail.com> In-Reply-To: <5087C428.2020908@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-stable@freebsd.org X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Oct 2012 11:00:46 -0000 On 2012-10-24 12:34, Volodymyr Kostyrko wrote: ... >> Can you attempt to figure out what the illegal instruction was, in that >> case? > How can I do that? I'm not very familiar with gdb. Try the following: $ gdb /path/to/crashed-program /path/to/crashed-program.core GNU gdb (GDB) 7.5 [GDB v7.5 for FreeBSD] Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i386-portbld-freebsd10.0". For bug reporting instructions, please see: ... Reading symbols from /path/to/crashed-program...(no debugging symbols found)...done. [New process 100137] Core was generated by `crashed-program'. Program terminated with signal 4, Illegal instruction. #0 0x08048632 in main () (gdb) disassemble Dump of assembler code for function main: 0x08048600 <+0>: push %ebp 0x08048601 <+1>: mov %esp,%ebp 0x08048603 <+3>: sub $0x18,%esp 0x08048606 <+6>: lea 0x80486b0,%eax 0x0804860c <+12>: movl $0x0,-0x4(%ebp) 0x08048613 <+19>: mov %eax,(%esp) 0x08048616 <+22>: call 0x8048390 0x0804861b <+27>: mov 0x8049868,%ecx 0x08048621 <+33>: mov %ecx,(%esp) 0x08048624 <+36>: mov %eax,-0x8(%ebp) 0x08048627 <+39>: call 0x80483c0 0x0804862c <+44>: lea 0x80486ce,%ecx => 0x08048632 <+50>: (bad) 0x08048633 <+51>: (bad) 0x08048634 <+52>: (bad) 0x08048635 <+53>: (bad) 0x08048636 <+54>: (bad) 0x08048637 <+55>: (bad) 0x08048638 <+56>: (bad) 0x08048639 <+57>: decl 0x4589240c(%ecx) 0x0804863f <+63>: hlt 0x08048640 <+64>: call 0x8048390 0x08048645 <+69>: mov 0x8049868,%ecx 0x0804864b <+75>: mov %ecx,(%esp) 0x0804864e <+78>: mov %eax,-0x10(%ebp) 0x08048651 <+81>: call 0x80483c0 0x08048656 <+86>: mov $0x0,%ecx 0x0804865b <+91>: mov %eax,-0x14(%ebp) 0x0804865e <+94>: mov %ecx,%eax 0x08048660 <+96>: add $0x18,%esp 0x08048663 <+99>: pop %ebp 0x08048664 <+100>: ret End of assembler dump. (gdb) info registers eax 0x0 0 ecx 0x80486ce 134514382 edx 0x2819a8d4 672770260 ebx 0xbfbfd650 -1077946800 esp 0xbfbfd5e0 0xbfbfd5e0 ebp 0xbfbfd5f8 0xbfbfd5f8 esi 0xbfbfd64c -1077946804 edi 0x0 0 eip 0x8048632 0x8048632 eflags 0x10286 [ PF SF IF RF ] cs 0x33 51 ss 0x3b 59 ds 0x3b 59 es 0x3b 59 fs 0x3b 59 gs 0x1b 27 It should highlight the illegal instruction with the => arrow. Just copy/paste the whole piece of assembly, and the registers info. ... >> On the problematic athlons, can you please post the exact CPUIDs from >> dmesg? If you have WITH_CLANG_EXTRAS enabled, please also post the >> output of "opt -version". > > Oct 24 01:47:20 limbo kernel: CPU: AMD Athlon(tm) XP 2500+ (1833.95-MHz > 686-class CPU) > Oct 24 01:47:20 limbo kernel: Origin = "AuthenticAMD" Id = 0x6a0 > Family = 0x6 Model = 0xa Stepping = 0 Ok, this CPU should be recognized by llvm as "athlon-xp". There is in fact no need to compile all the WITH_CLANG_EXTRAS programs, I just remembered. If you compile a sample program with -march=native -v, it should show you the detected CPU in the verbose command line output, e.g.: $ clang -v -march=native -c /home/dim/src/example.c FreeBSD clang version 3.2 (trunk 162107) 20120817 Target: i386-unknown-freebsd10.0 Thread model: posix "/usr/bin/clang" -cc1 -triple i386-unknown-freebsd10.0 -emit-obj -mrelax-all -disable-free -main-file-name example.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu core2 -momit-leaf-frame-pointer -v -coverage-file hw.o -resource-dir /usr/bin/../lib/clang/3.2 -fmodule-cache-path /home/dim/tmp/clang-module-cache -fdebug-compilation-dir /home/dim/src -ferror-limit 19 -fmessage-length 265 -mstackrealign -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o hw.o -x c /home/dim/src/example.c clang -cc1 version 3.2 based upon LLVM 3.2svn default target i386-unknown-freebsd10.0 ignoring nonexistent directory "/usr/bin/../lib/clang/3.2/include" #include "..." search starts here: #include <...> search starts here: /usr/include/clang/3.2 /usr/include End of search list. In my case, it uses "-target-cpu core2", as you can see.