diff options
author | abs <abs@pkgsrc.org> | 2003-05-29 11:45:50 +0000 |
---|---|---|
committer | abs <abs@pkgsrc.org> | 2003-05-29 11:45:50 +0000 |
commit | 248b94602f6ee2e113f0cd20b2de43b0945947c3 (patch) | |
tree | be23a7cba8d4b24b506ed7edddd7c6d02b13b7fe /devel | |
parent | 72de6a586b508b5a7639e2f50bd5fd804e6c8653 (diff) | |
download | pkgsrc-248b94602f6ee2e113f0cd20b2de43b0945947c3.tar.gz |
Update cpuflags to 0.42:
- Add some additional x86 flags for gcc 3.x
- Allow the path to cc to be specified as an argument to cpuflags
- Use both the previous to handle the gcc3 package
- Add an 'unsupported' optimize_gcc.mk which... to quote its comments:
"This file is 'experimental' - which is doublespeak for unspeakably
ugly, and probably quite broken by design.
The intention is to pass additional flags to gcc to further optimise
generated code. It _will_ make it impossible to debug, may fail to
compile some code, and even generate curdled binaries. It is completely
unsupported. Any questions should be directed to <abs@netbsd.org>.
Diffstat (limited to 'devel')
-rw-r--r-- | devel/cpuflags/Makefile | 5 | ||||
-rw-r--r-- | devel/cpuflags/PLIST | 3 | ||||
-rw-r--r-- | devel/cpuflags/files/cpuflags.1 | 39 | ||||
-rwxr-xr-x | devel/cpuflags/files/cpuflags.NetBSD | 23 | ||||
-rw-r--r-- | devel/cpuflags/files/cpuflags.mk | 4 | ||||
-rw-r--r-- | devel/cpuflags/files/optimize_gcc.mk | 59 |
6 files changed, 121 insertions, 12 deletions
diff --git a/devel/cpuflags/Makefile b/devel/cpuflags/Makefile index eeca399bdd0..865e84ccbeb 100644 --- a/devel/cpuflags/Makefile +++ b/devel/cpuflags/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.43 2003/05/12 11:05:48 abs Exp $ +# $NetBSD: Makefile,v 1.44 2003/05/29 11:45:50 abs Exp $ # -DISTNAME= cpuflags-0.41 +DISTNAME= cpuflags-0.42 WRKSRC= ${WRKDIR} CATEGORIES= sysutils MASTER_SITES= # empty @@ -20,6 +20,7 @@ NO_BUILD= yes do-install: ${INSTALL_SCRIPT} ${FILESDIR}/cpuflags.${OPSYS} ${PREFIX}/bin/cpuflags ${INSTALL_DATA} ${FILESDIR}/cpuflags.mk ${PREFIX}/share/mk/cpuflags.mk + ${INSTALL_DATA} ${FILESDIR}/optimize_gcc.mk ${PREFIX}/share/mk/optimize_gcc.mk ${INSTALL_MAN} ${FILESDIR}/cpuflags.1 ${PREFIX}/man/man1/cpuflags.1 .include "../../mk/bsd.pkg.mk" diff --git a/devel/cpuflags/PLIST b/devel/cpuflags/PLIST index 3051c5a1160..0a1254f8cc4 100644 --- a/devel/cpuflags/PLIST +++ b/devel/cpuflags/PLIST @@ -1,4 +1,5 @@ -@comment $NetBSD: PLIST,v 1.1 2001/11/01 01:22:50 zuntum Exp $ +@comment $NetBSD: PLIST,v 1.2 2003/05/29 11:45:50 abs Exp $ bin/cpuflags man/man1/cpuflags.1 share/mk/cpuflags.mk +share/mk/optimize_gcc.mk diff --git a/devel/cpuflags/files/cpuflags.1 b/devel/cpuflags/files/cpuflags.1 index 2ac359c45a2..fd78b015798 100644 --- a/devel/cpuflags/files/cpuflags.1 +++ b/devel/cpuflags/files/cpuflags.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: cpuflags.1,v 1.11 2003/05/22 15:36:40 abs Exp $ +.\" $NetBSD: cpuflags.1,v 1.12 2003/05/29 11:45:50 abs Exp $ .Dd May 31, 2001 .Dt CPUFLAGS 1 .Os @@ -7,6 +7,7 @@ .Nd determine compiler flags to best target current cpu .Sh SYNOPSIS .Nm +.Op cc_pathname .Sh DESCRIPTION .Nm queries the current cpu type and gcc version, then outputs appropriate @@ -15,6 +16,11 @@ to target the current cpu then nothing is output. .Pp In the event of the cpu not being recognised, a warning is sent to stderr. .Pp +If +.Pa cc_pathname +is not specified it defaults to the first +.Pa cc +found in the path. .Sh ENVIRONMENT The makefile fragment .Pa /usr/pkg/share/mk/cpuflags.mk @@ -33,26 +39,51 @@ Has CPU_FLAGS appended Has CPU_FLAGS appended .El .Sh FILES -.Bl -tag -width /usr/pkg/share/mk/cpuflags.mk -compact +.Bl -tag -width /usr/pkg/share/mk/optimize_gcc.mk -compact .It /usr/pkg/share/mk/cpuflags.mk -for inclusion by /etc/mk.conf +Set appropriate compiler flags based on the output from +.Nm . +Suitable for inclusion in /etc/mk.conf +.It /usr/pkg/share/mk/optimize_gcc.mk +Attempt to set additional -mXXX gcc flags based on gcc version and packages +being compiled. Note: This is experimental and not supported. .El .Sh EXAMPLES .Nm can be used to set default flags for building entries from pkgsrc and recompiling the .Nx -kernel or userland by adding the following to /etc/mk.conf. +kernel or userland by adding the following to +.Pa /etc/mk.conf : .Bd -literal -offset indent .sinclude "/usr/pkg/share/mk/cpuflags.mk" .Ed .Pp +Those desiring further optimisation can install the lang/gcc3 package, and +add the following to +.Pa /etc/mk.conf +instead: +.Bd -literal -offset indent + .sinclude "/usr/pkg/share/examples/gcc/mk.conf" + .sinclude "/usr/pkg/share/mk/cpuflags.mk" +.Ed +.Pp +To experiment with optimisations that can break generated code there is +optimize_gcc.mk. This is unsupported, but for full effect add the following to +.Pa /etc/mk.conf : +.Bd -literal -offset indent + .sinclude "/usr/pkg/share/examples/gcc/mk.conf" + .sinclude "/usr/pkg/share/mk/cpuflags.mk" + .sinclude "/usr/pkg/share/mk/optimize_gcc.mk" +.Ed +.Pp On all except low memory machines compliation can be speeded up by adding the following to /etc/mk.conf. (Note this will not affect the binaries produced) .Bd -literal -offset indent COPTS+=-pipe CFLAGS+=-pipe .Ed +.Pp .Sh BUGS .Nm still needs to learn about more cpu types - updates welcomed diff --git a/devel/cpuflags/files/cpuflags.NetBSD b/devel/cpuflags/files/cpuflags.NetBSD index 2aff319922b..ff14801426d 100755 --- a/devel/cpuflags/files/cpuflags.NetBSD +++ b/devel/cpuflags/files/cpuflags.NetBSD @@ -1,5 +1,5 @@ #!/bin/sh -# $NetBSD: cpuflags.NetBSD,v 1.34 2003/04/22 08:01:37 abs Exp $ +# $NetBSD: cpuflags.NetBSD,v 1.35 2003/05/29 11:45:50 abs Exp $ if [ -x /sbin/sysctl ] ;then SYSCTL=/sbin/sysctl @@ -17,6 +17,12 @@ if [ -n "$MACHINE" -a $hw_machine != "$MACHINE" ]; then exit fi +if [ -n "$1" ]; then + CC=$1 +else + CC=gcc +fi + case $hw_machine_arch in alpha) @@ -53,9 +59,15 @@ case $hw_machine_arch in esac ;; i386) case $hw_model in + *Intel\ Pentium\ II\ *) FLAGS='-march=pentium2' ;; + *Intel\ Pentium\ III\ *) FLAGS='-march=pentium3' ;; + *Intel\ Pentium\ 4\ *) FLAGS='-march=pentium4' ;; + *AMD\ K6-III*) FLAGS='-march=k6-3' ;; + *AMD\ K6-2*) FLAGS='-march=k6-2' ;; + *AMD\ K6*) FLAGS='-march=k6' ;; + *AMD\ K7*) FLAGS='-march=athlon' ;; *386-class*) FLAGS='-march=i386' ;; *486-class*) FLAGS='-march=i486' ;; - *AMD\ K6*) FLAGS='-march=k6' ;; *586-class*) FLAGS='-march=pentium' ;; *686-class*) FLAGS='-march=pentiumpro' ;; esac ;; @@ -133,7 +145,7 @@ fi # Fixup flags for old gcc if [ -n "$FLAGS" ]; then - gcc_ver=`gcc -v 2>&1 | awk '/gcc version/ {sub("egcs-","");print $3}'` + gcc_ver=`${CC} -v 2>&1 | awk '/gcc version/ {sub("egcs-","");print $3}'` FLAGS=`awk -v "flags=$FLAGS" -v "gcc_ver=$gcc_ver" ' {if (gcc_ver < $1){map[$2] = ""$3}} END{if (flags in map) {print map[flags]}else {print flags}} @@ -151,6 +163,11 @@ if [ -n "$FLAGS" ]; then 2.90 -mcpu=strongarm110 -m6 2.90 -mcpu=arm710 -m6 2.95 -march=k6 -march=pentium +3.2 -march=k6-2 -march=k6 +3.2 -march=k6-3 -march=k6 +3.2 -march=pentium2 -march=pentiumpro +3.2 -march=pentium3 -march=pentiumpro +3.2 -march=pentium4 -march=pentiumpro EOD ` fi diff --git a/devel/cpuflags/files/cpuflags.mk b/devel/cpuflags/files/cpuflags.mk index 495e2459afd..41963cbbd1c 100644 --- a/devel/cpuflags/files/cpuflags.mk +++ b/devel/cpuflags/files/cpuflags.mk @@ -1,4 +1,4 @@ -# $Id: cpuflags.mk,v 1.7 2002/08/05 13:17:11 abs Exp $ +# $Id: cpuflags.mk,v 1.8 2003/05/29 11:45:50 abs Exp $ # Makefile include fragment to simplify use of cpuflags in pkgsrc # abs@netbsd.org - freely distributable, no warrenties, stick no bills. @@ -14,7 +14,7 @@ .ifndef CPU_FLAGS -CPU_FLAGS!=/usr/pkg/bin/cpuflags +CPU_FLAGS!=/usr/pkg/bin/cpuflags ${CC} CPU_DIR!=echo ${CPU_FLAGS} | sed 's/ //' MAKEFLAGS+=CPU_FLAGS=${CPU_FLAGS} CPU_DIR="${CPU_DIR}" # For sub makes diff --git a/devel/cpuflags/files/optimize_gcc.mk b/devel/cpuflags/files/optimize_gcc.mk new file mode 100644 index 00000000000..572e86ce76f --- /dev/null +++ b/devel/cpuflags/files/optimize_gcc.mk @@ -0,0 +1,59 @@ +# $Id: optimize_gcc.mk,v 1.1 2003/05/29 11:45:50 abs Exp $ + +# This file is 'experimental' - which is doublespeak for unspeakably +# ugly, and probably quite broken by design. +# +# The intention is to pass additional flags to gcc to further optimise +# generated code. It _will_ make it impossible to debug, may fail to +# compile some code, and even generate curdled binaries. It is completely +# unsupported. Any questions should be directed to <abs@netbsd.org>. + +.if (${MACHINE} == sparc64) +COPT_FLAGS= +.elif defined(USE_GCC3) +# With at least -march=k6-2, gcc 3.3 breaks with -frename-registers (in -O3) +COPT_FLAGS=-O2 -finline-functions +.else +COPT_FLAGS=-O3 +.endif + +.ifdef BSD_PKG_MK # Try to catch various package opts + +# This is a horrible mess, but how else to adjust per package? + +.if !defined(PKGBASE) +PKGBASE=${PKGNAME:C/-[^-]*$//} +.if ${PKGBASE} == "" +PKGBASE=${.CURDIR:C:.*/::} +.endif +.endif + +COPT_FLAGS+=-ffast-math + +PKG_EXCLUDE_OMIT_FRAME_POINTER=lua4 +.if defined(USE_GCC3) +PKG_EXCLUDE_OMIT_FRAME_POINTER+=mozilla phoenix qt3-libs kdeedu3 +.endif + +.if empty(PKG_EXCLUDE_OMIT_FRAME_POINTER:M${PKGBASE}) +COPT_FLAGS+=-fomit-frame-pointer +.endif + +CFLAGS+=${COPT_FLAGS} +CXXFLAGS+=${COPT_FLAGS} +MAKE_FLAGS+=CCOPTIONS="${COPT_FLAGS}" # Override CCOPTIONS for imake + +.else # Assume in base system, only COPTS + +COPT_FLAGS+=-fomit-frame-pointer +# Include ${DEFCOPTS} and set ?= to allow overriding in kernel builds +.if !defined(COPTS) +COPTS=${DEFCOPTS} ${COPT_FLAGS} +.else +COPTS+=${COPT_FLAGS} +.endif +.if defined(USE_GCC3) +DEFWARNINGS=no +.endif + +.endif |