Subject: Convenient sysctl/uname option for cpu/arch level?
To: None <tech-toolchain@netbsd.org>
From: David Brownlee <abs@netbsd.org>
List: tech-toolchain
Date: 03/14/2001 21:45:08
I've been playing with having pkgsrc pick the appropriate
'best' optimisation level when compiling anything on various
boxes around here, and I'm having a little fun determining the
appropriate compiler flags for each CPU.
I knocked together a quick script for some i486 and sparc boxes,
(below) and in the process noted there does not seem to be an
obvious method of finding the appropriate compiler flags.
I wonder if it might make sense to have a sysctl or uname option
to output the appropriate 'supersparc' or 'pentiumpro' value based
on the current CPU?
#!/bin/sh
hw_model=`sysctl -n hw.model`
case $hw_model in
# i386
*386-class*) FLAGS='-march=i386' ;;
*486-class*) FLAGS='-march=i486' ;;
*586-class*) FLAGS='-march=pentium' ;;
*686-class*) FLAGS='-march=pentiumpro' ;;
# sparc
MB86904*) FLAGS="-mcpu=supersparc" ;; # ss5
TMS390Z50*) FLAGS="-mcpu=supersparc" ;; # ss10/ss20
MB86930* | MB86934*) FLAGS="-mcpu=sparclite" ;; # from gcc
MB86900/1A*) FLAGS="-mcpu=cypress" ;; # ss1+
*) echo "Unknown hw.model '$hw_model'" >&2
esac
echo $FLAGS
exit 0
David/absolute -- www.netbsd.org: No hype required --