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