From d5499896947b8579868536fafa6cc704a6de7f4f Mon Sep 17 00:00:00 2001 From: "David E. O'Brien" Date: Thu, 16 Aug 2001 06:05:18 +0000 Subject: [PATCH] Add the `WANT_FORCE_OPTIMIZATION_DOWNGRADE' knob. If set to an integer value, it forces GCC to not optimize above this level. For intance, GCC made with "WANT_FORCE_OPTIMIZATION_DOWNGRADE=1" is a good setting for the Alpha platform when building ports. --- contrib/gcc/toplev.c | 19 ++++++++++++------- etc/defaults/make.conf | 6 ++++++ gnu/usr.bin/cc/Makefile.inc | 4 ++++ share/examples/etc/make.conf | 6 ++++++ share/man/man5/make.conf.5 | 9 ++++++++- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/contrib/gcc/toplev.c b/contrib/gcc/toplev.c index 95835bbf562e..e9d8886569b3 100644 --- a/contrib/gcc/toplev.c +++ b/contrib/gcc/toplev.c @@ -4851,17 +4851,22 @@ main (argc, argv) if (optimize_val != -1) { optimize = optimize_val; -#ifdef __alpha__ +#ifdef FORCE_OPTIMIZATION_DOWNGRADE +#warning FORCE_OPTIMIZATION_DOWNGRADE + if (optimize > FORCE_OPTIMIZATION_DOWNGRADE) + { + optimize = FORCE_OPTIMIZATION_DOWNGRADE; + warning ("\n***\n***\t-O%d converted to \"-O%d\" due to optimizer bugs on this platform\n***\n", + optimize_val, + FORCE_OPTIMIZATION_DOWNGRADE); + + } +#endif /*FORCE_OPTIMIZATION_DOWNGRADE*/ +#if defined(__alpha__) if (optimize > 1) { - #ifdef FORCE_OPTIMIZATION_DOWNGRADE - optimize = 1; - warning ("\n***\n***\t-O%d converted to \"-O1\" due to optimizer bugs on this platform\n***\n", - optimize_val); - #else warning ("\n***\n***\tThe -O%d flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM\n***\n", optimize_val); - #endif } #endif /*__alpha__*/ optimize_size = 0; diff --git a/etc/defaults/make.conf b/etc/defaults/make.conf index ca685877265f..683f28675830 100644 --- a/etc/defaults/make.conf +++ b/etc/defaults/make.conf @@ -65,6 +65,12 @@ BDECFLAGS= -W -Wall -ansi -pedantic -Wbad-function-cast -Wcast-align \ # #COPTFLAGS= -O -pipe # +# To build the system compiler such that it forces high optimization levels to +# a lower one. GCC -O2+ is known to trigger known optimizer bugs at various +# times -- this is worse on the Alpha platform. The value assigned here will +# be the highest optimization value used. +#WANT_FORCE_OPTIMIZATION_DOWNGRADE=1 +# # Compare before install #INSTALL=install -C # diff --git a/gnu/usr.bin/cc/Makefile.inc b/gnu/usr.bin/cc/Makefile.inc index 4fe0547adab6..7b6a2ec1efb8 100644 --- a/gnu/usr.bin/cc/Makefile.inc +++ b/gnu/usr.bin/cc/Makefile.inc @@ -39,6 +39,10 @@ CFLAGS+= -DHAIFA CFLAGS+= -DCROSS_COMPILE .endif +.if defined(WANT_FORCE_OPTIMIZATION_DOWNGRADE) +CFLAGS+= -DFORCE_OPTIMIZATION_DOWNGRADE=${WANT_FORCE_OPTIMIZATION_DOWNGRADE} +.endif + .if exists(${.OBJDIR}/../cc_tools) CFLAGS+= -I${.OBJDIR}/../cc_tools .endif diff --git a/share/examples/etc/make.conf b/share/examples/etc/make.conf index ca685877265f..683f28675830 100644 --- a/share/examples/etc/make.conf +++ b/share/examples/etc/make.conf @@ -65,6 +65,12 @@ BDECFLAGS= -W -Wall -ansi -pedantic -Wbad-function-cast -Wcast-align \ # #COPTFLAGS= -O -pipe # +# To build the system compiler such that it forces high optimization levels to +# a lower one. GCC -O2+ is known to trigger known optimizer bugs at various +# times -- this is worse on the Alpha platform. The value assigned here will +# be the highest optimization value used. +#WANT_FORCE_OPTIMIZATION_DOWNGRADE=1 +# # Compare before install #INSTALL=install -C # diff --git a/share/man/man5/make.conf.5 b/share/man/man5/make.conf.5 index f21660ece5da..538493ab96f9 100644 --- a/share/man/man5/make.conf.5 +++ b/share/man/man5/make.conf.5 @@ -249,7 +249,7 @@ Controls the compiler settings when building the kernel. Optimization levels above .Oo Fl O ( O2 , No ...\& ) Oc -are not supported. +are not guaranteed to work. .It Va KERNEL .Pq Vt str Controls which kernel configurations will be @@ -538,6 +538,13 @@ command when building .It Va SENDMAIL_DPADD .Pq Vt str This variable is undocumented. +.It Va WANT_FORCE_OPTIMIZATION_DOWNGRADE +.Pq Vt int +Causes the system compiler to be built such that it forces high optimization +levels to a lower one. +GCC -O2 and above is known to trigger known optimizer bugs at various +times -- this is worse on the Alpha platform. +The value assigned is the highest optimization value used. .El .Pp The following list provides a name and short description for variables