[patch, libgfortran] Build with -ffunction-sections -fdata-sections
Tobias Burnus
burnus@net-b.de
Thu Apr 16 18:28:00 GMT 2009
Ulrich Weigand wrote:
> most GCC target libraries are built with -ffunction-section -fdata-sections
> if the compiler / target supports those options.
> This brings done the minimal footprint of the Fortran library on SPU from
>
>> 150 KB to about 40 KB, and in addition enables use of automatic overlay
>>
> support to run even programs making significant use of the library.
> Tested on spu-elf. OK for mainline?
>
OK. The patch looks OK and Paolo (reply) and Andrew (#gcc) confirmed
that the option is OK. Thanks for making gfortran more useful on SPU.
* * *
For completeness, it was added to C++ with the patch
http://gcc.gnu.org/viewcvs?view=rev&revision=34593
http://gcc.gnu.org/ml/libstdc++/2000-06/msg00069.html
Tobias
> ChangeLog:
>
> * configure.ac: Test for -ffunction-sections -fdata-sections and
> set SECTION_FLAGS accordingly.
> * configure: Regenerate.
>
> * Makefile.am: Add SECTION_FLAGS to AM_CFLAGS.
> * Makefile.in: Regenerate.
>
> [Diffs for generated files omitted.]
>
> Index: libgfortran/configure.ac
> ===================================================================
> *** libgfortran/configure.ac (revision 144779)
> --- libgfortran/configure.ac (working copy)
> *************** LDFLAGS="$save_LDFLAGS"
> *** 149,154 ****
> --- 149,175 ----
> AC_MSG_RESULT($gfortran_use_symver)
> AM_CONDITIONAL(LIBGFOR_USE_SYMVER, [test "x$gfortran_use_symver" = xyes])
>
> + # Figure out whether the compiler supports "-ffunction-sections -fdata-sections",
> + # similarly to how libstdc++ does it
> + ac_test_CFLAGS="${CFLAGS+set}"
> + ac_save_CFLAGS="$CFLAGS"
> +
> + # Check for -ffunction-sections -fdata-sections
> + AC_MSG_CHECKING([for gcc that supports -ffunction-sections -fdata-sections])
> + CFLAGS='-Werror -ffunction-sections -fdata-sections'
> + AC_TRY_COMPILE(, [int foo;], [ac_fdsections=yes], [ac_fdsections=no])
> + if test "$ac_test_CFLAGS" = set; then
> + CFLAGS="$ac_save_CFLAGS"
> + else
> + # this is the suspicious part
> + CFLAGS=""
> + fi
> + if test x"$ac_fdsections" = x"yes"; then
> + SECTION_FLAGS='-ffunction-sections -fdata-sections'
> + fi
> + AC_MSG_RESULT($ac_fdsections)
> + AC_SUBST(SECTION_FLAGS)
> +
> # Find other programs we need.
> AC_CHECK_TOOL(AS, as)
> AC_CHECK_TOOL(AR, ar)
> Index: libgfortran/Makefile.am
> ===================================================================
> *** libgfortran/Makefile.am (revision 144779)
> --- libgfortran/Makefile.am (working copy)
> *************** AM_CPPFLAGS = -iquote$(srcdir)/io -I$(sr
> *** 33,38 ****
> --- 33,42 ----
> # Fortran rules for complex multiplication and division
> AM_CFLAGS += -fcx-fortran-rules
>
> + # Use -ffunction-sections -fdata-sections if supported by the compiler
> + SECTION_FLAGS = @SECTION_FLAGS@
> + AM_CFLAGS += $(SECTION_FLAGS)
> +
> gfor_io_src= \
> io/close.c \
> io/file_pos.c \
>
More information about the Fortran
mailing list