[PATCH/RFA]: New configure option disabling target optimization

View: New views
5 Messages — Rating Filter:   Alert me  

[PATCH/RFA]: New configure option disabling target optimization

by Corinna Vinschen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,


when building newlib, there's a statement in configure.host which always
adds some sort of optimization to NEWLIB_CFLAGS.  Maybe I'm just dense,
but I haven't found a way to disable the generation of the optimization
flags using configure or make, without having to enter a new
NEWLIB_CFLAGS value, which in turn requires to enter the full rat tail
of target specific options.  For Cygwin, this means for instance:

  make NEWLIB_CFLAGS='-DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED -fno-builtin'

That's pretty cumbersome.  I'm constantly building the Cygwin/newlib
source tree for debuggging using `CFLAGS=-g', and for debugging any
optimization is just in the way.

Therefore I'd like to propose a patch to add a configure option to
disable this automatic optimization option in configure.host.  Would
something like this be ok to apply, or is there already some easier way
to accomplish the same which I just didn't notice?


Thanks,
Corinna


        * acinclude.m4: Add --disable-target-optimization option.
        * configure.host: Skip target optimization setting if
        --disable-target-optimization has been specified.


Index: acinclude.m4
===================================================================
RCS file: /cvs/src/src/newlib/acinclude.m4,v
retrieving revision 1.29
diff -u -p -r1.29 acinclude.m4
--- acinclude.m4 22 Dec 2008 19:45:40 -0000 1.29
+++ acinclude.m4 20 Oct 2009 10:05:02 -0000
@@ -20,6 +20,17 @@ AC_ARG_ENABLE(multilib,
   *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
  esac], [multilib=yes])dnl
 
+dnl Support --disable-target-optimization
+AC_ARG_ENABLE(target-optimization,
+[  --disable-target-optimization disable automatic optimization support],
+[if test "${target_optimization+set}" != set; then
+  case "${enableval}" in
+    yes) target_optimization=yes ;;
+    no)  target_optimization=no ;;
+    *)   AC_MSG_ERROR(bad value ${enableval} for target-optimization option) ;;
+  esac
+ fi], [target_optimization=${target_optimization}])dnl
+
 dnl Support --enable-target-optspace
 AC_ARG_ENABLE(target-optspace,
 [  --enable-target-optspace  optimize for space],
Index: configure.host
===================================================================
RCS file: /cvs/src/src/newlib/configure.host,v
retrieving revision 1.110
diff -u -p -r1.110 configure.host
--- configure.host 8 Oct 2009 16:44:09 -0000 1.110
+++ configure.host 20 Oct 2009 10:05:02 -0000
@@ -72,17 +72,20 @@ aext=a
 oext=o
 lpfx="lib_a-"
 
-case "${target_optspace}:${host}" in
-  yes:*)
-    newlib_cflags="${newlib_cflags} -Os"
-    ;;
-  :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* )
-    newlib_cflags="${newlib_cflags} -Os"
-    ;;
-  no:* | :*)
-    newlib_cflags="${newlib_cflags} -O2"
-    ;;
-esac
+if [ "${target_optimization}" != "no" ]
+then
+  case "${target_optspace}:${host}" in
+    yes:*)
+      newlib_cflags="${newlib_cflags} -Os"
+      ;;
+    :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* )
+      newlib_cflags="${newlib_cflags} -Os"
+      ;;
+    no:* | :*)
+      newlib_cflags="${newlib_cflags} -O2"
+      ;;
+  esac
+fi
 
 # Get the source directories to use for the CPU type.
 # machine_dir should supply CPU dependent routines, such as setjmp.

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

Re: [PATCH/RFA]: New configure option disabling target optimization

by Jeff Johnston :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think there is a simpler answer.  Just remove the setting of the -O2
flag in configure.host.  The optimization flag gets set by default in
the top-level so there is no need to duplicate it.  That way you could
just use CFLAG settings to accomplish what you want.

Try the attached patch.

-- Jeff J.

On 20/10/09 06:28 AM, Corinna Vinschen wrote:

> Hi,
>
>
> when building newlib, there's a statement in configure.host which always
> adds some sort of optimization to NEWLIB_CFLAGS.  Maybe I'm just dense,
> but I haven't found a way to disable the generation of the optimization
> flags using configure or make, without having to enter a new
> NEWLIB_CFLAGS value, which in turn requires to enter the full rat tail
> of target specific options.  For Cygwin, this means for instance:
>
>    make NEWLIB_CFLAGS='-DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED -fno-builtin'
>
> That's pretty cumbersome.  I'm constantly building the Cygwin/newlib
> source tree for debuggging using `CFLAGS=-g', and for debugging any
> optimization is just in the way.
>
> Therefore I'd like to propose a patch to add a configure option to
> disable this automatic optimization option in configure.host.  Would
> something like this be ok to apply, or is there already some easier way
> to accomplish the same which I just didn't notice?
>
>
> Thanks,
> Corinna
>
>
> * acinclude.m4: Add --disable-target-optimization option.
> * configure.host: Skip target optimization setting if
> --disable-target-optimization has been specified.
>
>
> Index: acinclude.m4
> ===================================================================
> RCS file: /cvs/src/src/newlib/acinclude.m4,v
> retrieving revision 1.29
> diff -u -p -r1.29 acinclude.m4
> --- acinclude.m4 22 Dec 2008 19:45:40 -0000 1.29
> +++ acinclude.m4 20 Oct 2009 10:05:02 -0000
> @@ -20,6 +20,17 @@ AC_ARG_ENABLE(multilib,
>     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
>    esac], [multilib=yes])dnl
>
> +dnl Support --disable-target-optimization
> +AC_ARG_ENABLE(target-optimization,
> +[  --disable-target-optimization disable automatic optimization support],
> +[if test "${target_optimization+set}" != set; then
> +  case "${enableval}" in
> +    yes) target_optimization=yes ;;
> +    no)  target_optimization=no ;;
> +    *)   AC_MSG_ERROR(bad value ${enableval} for target-optimization option) ;;
> +  esac
> + fi], [target_optimization=${target_optimization}])dnl
> +
>   dnl Support --enable-target-optspace
>   AC_ARG_ENABLE(target-optspace,
>   [  --enable-target-optspace  optimize for space],
> Index: configure.host
> ===================================================================
> RCS file: /cvs/src/src/newlib/configure.host,v
> retrieving revision 1.110
> diff -u -p -r1.110 configure.host
> --- configure.host 8 Oct 2009 16:44:09 -0000 1.110
> +++ configure.host 20 Oct 2009 10:05:02 -0000
> @@ -72,17 +72,20 @@ aext=a
>   oext=o
>   lpfx="lib_a-"
>
> -case "${target_optspace}:${host}" in
> -  yes:*)
> -    newlib_cflags="${newlib_cflags} -Os"
> -    ;;
> -  :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* )
> -    newlib_cflags="${newlib_cflags} -Os"
> -    ;;
> -  no:* | :*)
> -    newlib_cflags="${newlib_cflags} -O2"
> -    ;;
> -esac
> +if [ "${target_optimization}" != "no" ]
> +then
> +  case "${target_optspace}:${host}" in
> +    yes:*)
> +      newlib_cflags="${newlib_cflags} -Os"
> +      ;;
> +    :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* )
> +      newlib_cflags="${newlib_cflags} -Os"
> +      ;;
> +    no:* | :*)
> +      newlib_cflags="${newlib_cflags} -O2"
> +      ;;
> +  esac
> +fi
>
>   # Get the source directories to use for the CPU type.
>   # machine_dir should supply CPU dependent routines, such as setjmp.
>

[configure.host.patch]

Index: configure.host
===================================================================
RCS file: /cvs/src/src/newlib/configure.host,v
retrieving revision 1.110
diff -u -p -r1.110 configure.host
--- configure.host 8 Oct 2009 16:44:09 -0000 1.110
+++ configure.host 20 Oct 2009 16:44:40 -0000
@@ -80,7 +80,6 @@ case "${target_optspace}:${host}" in
     newlib_cflags="${newlib_cflags} -Os"
     ;;
   no:* | :*)
-    newlib_cflags="${newlib_cflags} -O2"
     ;;
 esac
 


Re: [PATCH/RFA]: New configure option disabling target optimization

by Corinna Vinschen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct 20 12:46, Jeff Johnston wrote:
> I think there is a simpler answer.  Just remove the setting of the -O2 flag
> in configure.host.  The optimization flag gets set by default in the
> top-level so there is no need to duplicate it.  That way you could just use
> CFLAG settings to accomplish what you want.
>
> Try the attached patch.

That looks good as long as one build from the top level.  If I build
newlib later on in it's own build directory because I just want to
test a single change, CFLAGS is not correct, since CFLAGS is always
empty for some reason.

Assuming I configure from the toplevel and build with `make CFLAGS=-g
CFLAGS_FOR_TARGET=-g'.  When the build is finished, newlib's CFLAGS
setting is empty:

 CFLAGS =

In other directories the setting of CFLAGS reflects what I had set
in the make run, for instance libiberty/Makefile:

 CFLAGS = -g

or Cygwin's Makefile:

 CFLAGS=-g

Why is that so?


Corinna

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

Re: [PATCH/RFA]: New configure option disabling target optimization

by Jeff Johnston :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 20/10/09 03:07 PM, Corinna Vinschen wrote:

> On Oct 20 12:46, Jeff Johnston wrote:
>> I think there is a simpler answer.  Just remove the setting of the -O2 flag
>> in configure.host.  The optimization flag gets set by default in the
>> top-level so there is no need to duplicate it.  That way you could just use
>> CFLAG settings to accomplish what you want.
>>
>> Try the attached patch.
>
> That looks good as long as one build from the top level.  If I build
> newlib later on in it's own build directory because I just want to
> test a single change, CFLAGS is not correct, since CFLAGS is always
> empty for some reason.
>
> Assuming I configure from the toplevel and build with `make CFLAGS=-g
> CFLAGS_FOR_TARGET=-g'.  When the build is finished, newlib's CFLAGS
> setting is empty:
>
>   CFLAGS =
>
> In other directories the setting of CFLAGS reflects what I had set
> in the make run, for instance libiberty/Makefile:
>
>   CFLAGS = -g
>
> or Cygwin's Makefile:
>
>   CFLAGS=-g
>
> Why is that so?
>

I think I found the problem.  It has to do with our own version of
AC_PROG_CC.   I have checked in a patch including the configure.host
fix.  Let me know if you have any problems.

-- Jeff J.



>
> Corinna
>


Re: [PATCH/RFA]: New configure option disabling target optimization

by Corinna Vinschen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct 20 18:44, Jeff Johnston wrote:

> On 20/10/09 03:07 PM, Corinna Vinschen wrote:
>> That looks good as long as one build from the top level.  If I build
>> newlib later on in it's own build directory because I just want to
>> test a single change, CFLAGS is not correct, since CFLAGS is always
>> empty for some reason.
>> [...]
>
> I think I found the problem.  It has to do with our own version of
> AC_PROG_CC.   I have checked in a patch including the configure.host fix.  
> Let me know if you have any problems.

This appears to work well.  Thanks for the patch!


Corinna

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat