From owner-freebsd-toolchain@FreeBSD.ORG Wed Nov 9 13:59:16 2011 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id 000C41065672; Wed, 9 Nov 2011 13:59:15 +0000 (UTC) Date: Wed, 9 Nov 2011 13:59:15 +0000 From: Alexander Best To: Dimitry Andric Message-ID: <20111109135915.GA16834@freebsd.org> References: <20111108002556.GA91218@freebsd.org> <4EB8E07B.5070908@FreeBSD.org> <20111108153856.GA90966@freebsd.org> <20111108210420.GA37161@freebsd.org> <4EB9A7D1.9030800@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4EB9A7D1.9030800@FreeBSD.org> Cc: freebsd-toolchain@freebsd.org Subject: Re: CPUTYPE=native handling X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Nov 2011 13:59:16 -0000 On Tue Nov 8 11, Dimitry Andric wrote: > On 2011-11-08 22:04, Alexander Best wrote: > ... > > for me -march=native reports: > > > > otaku% gcc -march=native -E -v - > Using built-in specs. > > Target: amd64-undermydesk-freebsd > > Configured with: FreeBSD/amd64 system compiler > > Thread model: posix > > gcc version 4.2.2 20070831 prerelease [FreeBSD] > > /usr/libexec/cc1 -E -quiet -v -D_LONGLONG - -march=nocona -mtune=generic > > #include "..." search starts here: > > #include <...> search starts here: > > /usr/include/gcc/4.2 > > /usr/include > > End of search list. > > # 1 "" > > # 1 "" > > # 1 "" > > # 1 "" > > > > where instead of nocona, core2 would have been the better choice: > > > > [1.000000] CPU: Intel(R) Pentium(R) Dual CPU E2160 @ 1.80GHz (1800.00-MHz K8-class CPU) > > [1.000000] Origin = "GenuineIntel" Id = 0x6fd Family = 6 Model = f Stepping = 13 > > [1.000000] Features=0xbfebfbff > > [1.000000] Features2=0xe39d > > [1.000000] AMD Features=0x20100800 > > [1.000000] AMD Features2=0x1 > > [1.000000] TSC: P-state invariant, performance statistics > > That's weird, the logic in gcc goes: > > cpuid (1, eax, ebx, ecx, edx); > ... > has_ssse3 = !!(ecx & bit_SSSE3); > ... > if (arch) > { > if (has_ssse3) > cpu = "core2"; > else if (has_sse3) > { > if (has_longmode) > cpu = "nocona"; > else > cpu = "prescott"; > } > else if (has_sse2) > cpu = "pentium4"; > else if (has_cmov) > cpu = "pentiumpro"; > else if (has_mmx) > cpu = "pentium-mmx"; > else if (has_cmpxchg8b) > cpu = "pentium"; > else > cpu = "i386"; > } > else > cpu = "generic"; > goto done; > > E.g. it seems to conclude your cpu *doesn't* have SSSE3, but does have > long mode, and thus jumps to nocona. > > You might be able to debug this, by putting some printfs in this > function. :) same on ref9-amd64.freebsd.org: ref9-amd64% clang -march=native -### blabla.c FreeBSD clang version 3.0 (trunk 135360) 20110717 Target: x86_64-unknown-freebsd9.0 Thread model: posix "/usr/bin/clang" "-cc1" "-triple" "x86_64-unknown-freebsd9.0" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "tower.c" "-mrelocation-model" "static" "-mdisable-fp-elim" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "core2" "-momit-leaf-frame-pointer" "-resource-dir" "/usr/bin/../lib/clang/3.0" "-ferror-limit" "19" "-fmessage-length" "275" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "/tmp/cc-ImChyq.o" "-x" "c" "tower.c" "/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld-elf.so.1" "-o" "tower" "/usr/lib/crt1.o" "/usr/lib/crti.o" "/usr/lib/crtbegin.o" "-L/usr/lib" "/tmp/cc-ImChyq.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" BUT ref9-amd64% gcc -march=native -E -v - search starts here: /usr/include/gcc/4.2 /usr/include End of search list. # 1 "" # 1 "" # 1 "" # 1 "" cheers. alex