This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, ARM] Avoid pulling in unwinder for 64-bit division
- From: Julian Brown <julian at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Oct 2009 14:10:12 +0000
- Subject: [PATCH, ARM] Avoid pulling in unwinder for 64-bit division
This patch sets compilation flags for the relevant parts of libgcc on
ARM such that the unwinder is not unnecessarily pulled in to the linked
executable when 64-bit division is used. This can be quite a
significant space saving on bare-metal systems.
Cross-tested on ARM EABI, and verified with a test program which
performs 64-bit division. OK to apply?
Julian
ChangeLog
libgcc/
* config.host (arm*-*-linux*, arm*-*-uclinux*, arm*-*-eabi*)
(arm*-*-symbianelf): Add arm/t-divmod-ef to tmake_file.
* Makefile.in (LIB2_DIVMOD_EXCEPTION_FLAGS): Set to previous
default if not set by a target-specific Makefile fragment.
(lib2-divmod-o, lib2-divmod-s-o): Use above.
* config/arm/t-divmod-ef: New.
* shared-object.mk (c_flags-$(base)$(objext)): New.
($(base)$(objext)): Use above.
* static-object.mk (c_flags-$(base)$(objext)): New.
($(base)$(objext)): Use above.
Index: libgcc/shared-object.mk
===================================================================
--- libgcc/shared-object.mk (revision 153062)
+++ libgcc/shared-object.mk (working copy)
@@ -8,11 +8,13 @@ base := $(basename $(notdir $o))
ifeq ($(suffix $o),.c)
+c_flags-$(base)$(objext) := $(c_flags)
$(base)$(objext): $o
- $(gcc_compile) $(c_flags) -c $< $(vis_hide)
+ $(gcc_compile) $(c_flags-$@) -c $< $(vis_hide)
+c_flags-$(base)_s$(objext) := $(c_flags)
$(base)_s$(objext): $o
- $(gcc_s_compile) $(c_flags) -c $<
+ $(gcc_s_compile) $(c_flags-$@) -c $<
else
Index: libgcc/config.host
===================================================================
--- libgcc/config.host (revision 153062)
+++ libgcc/config.host (working copy)
@@ -205,12 +205,15 @@ arm*-*-netbsdelf*)
arm*-*-netbsd*)
;;
arm*-*-linux*) # ARM GNU/Linux with ELF
+ tmake_file="${tmake_file} arm/t-divmod-ef"
;;
arm*-*-uclinux*) # ARM ucLinux
+ tmake_file="${tmake_file} arm/t-divmod-ef"
;;
arm*-*-ecos-elf)
;;
arm*-*-eabi* | arm*-*-symbianelf* )
+ tmake_file="${tmake_file} arm/t-divmod-ef"
;;
arm*-*-rtems*)
;;
Index: libgcc/static-object.mk
===================================================================
--- libgcc/static-object.mk (revision 153062)
+++ libgcc/static-object.mk (working copy)
@@ -8,8 +8,9 @@ base := $(basename $(notdir $o))
ifeq ($(suffix $o),.c)
+c_flags-$(base)$(objext) := $(c_flags)
$(base)$(objext): $o
- $(gcc_compile) $(c_flags) -c $< $(vis_hide)
+ $(gcc_compile) $(c_flags-$@) -c $< $(vis_hide)
else
Index: libgcc/Makefile.in
===================================================================
--- libgcc/Makefile.in (revision 153062)
+++ libgcc/Makefile.in (working copy)
@@ -400,18 +400,24 @@ libgcc-s-objects += $(patsubst %,%_s$(ob
endif
endif
+ifeq ($(LIB2_DIVMOD_EXCEPTION_FLAGS),)
+# Provide default flags for compiling divmod functions, if they haven't been
+# set already by a target-specific Makefile fragment.
+LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions -fnon-call-exceptions
+endif
+
# Build LIB2_DIVMOD_FUNCS.
lib2-divmod-o = $(patsubst %,%$(objext),$(LIB2_DIVMOD_FUNCS))
$(lib2-divmod-o): %$(objext): $(gcc_srcdir)/libgcc2.c
$(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
- -fexceptions -fnon-call-exceptions $(vis_hide)
+ $(LIB2_DIVMOD_EXCEPTION_FLAGS) $(vis_hide)
libgcc-objects += $(lib2-divmod-o)
ifeq ($(enable_shared),yes)
lib2-divmod-s-o = $(patsubst %,%_s$(objext),$(LIB2_DIVMOD_FUNCS))
$(lib2-divmod-s-o): %_s$(objext): $(gcc_srcdir)/libgcc2.c
$(gcc_s_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
- -fexceptions -fnon-call-exceptions
+ $(LIB2_DIVMOD_EXCEPTION_FLAGS)
libgcc-s-objects += $(lib2-divmod-s-o)
endif
Index: libgcc/config/arm/t-divmod-ef
===================================================================
--- libgcc/config/arm/t-divmod-ef (revision 0)
+++ libgcc/config/arm/t-divmod-ef (revision 0)
@@ -0,0 +1,4 @@
+# On ARM, specifying -fnon-call-exceptions will needlessly pull in
+# the unwinder in simple programs which use 64-bit division. Omitting
+# the option is safe.
+LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions