This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Option to build bare-metal ARM cross-compiler for arm-none-eabi target without libunwind


This is an update to Fredrik Hederstierna's mail and patch from
12 Apr 2012.  I think he missed one place where -fexceptions needs
to be changed to -fno-exceptions.

With the attached patch, two of us (a friend and I, one on Linux and
one on Mac) can build Rockbox with gcc-4.7.0.  I'll admit I haven't
checked the repository for changes in this area, this patch is based
on stock released gcc-4.7.0.

I have no opinion on Sebastian Huber's idea of making functionality
of this kind implicit with target.

   - Larry
diff -ur libgcc-orig/configure libgcc-baremetal/configure
--- libgcc-orig/configure	2012-01-22 22:25:28.000000000 -0800
+++ libgcc-baremetal/configure	2012-05-31 07:30:36.000000000 -0700
@@ -600,6 +600,7 @@
 set_use_emutls
 set_have_cc_tls
 vis_hide
+enable_libunwind_exceptions
 fixed_point
 enable_decimal_float
 decimal_float
@@ -697,6 +698,7 @@
 with_build_libsubdir
 enable_decimal_float
 with_system_libunwind
+enable_libunwind_exceptions
 enable_sjlj_exceptions
 enable_tls
 '
@@ -1332,6 +1334,8 @@
 			enable decimal float extension to C.  Selecting 'bid'
 			or 'dpd' choses which decimal floating point format
 			to use
+  --disable-libunwind-exceptions
+			disable use of libunwind when build libgcc
   --enable-sjlj-exceptions
                           force use of builtin_setjmp for exceptions
   --enable-tls            Use thread-local storage [default=yes]
@@ -4493,6 +4497,15 @@
   fi
 
 
+# For bare metal toolchain libundwind exceptions can be disabled
+# Check whether --enable-libunwind-exceptions was given.
+if test "${enable_libunwind_exceptions+set}" = set; then :
+  enableval=$enable_libunwind_exceptions; enable_libunwind_exceptions=$enableval
+else
+  enable_libunwind_exceptions=yes
+fi
+
+
 # The sjlj test is almost duplicated here and in libgo/configure.ac (for C),
 # libstdc++-v3/acinclude.m4 and libjava/configure.ac (for C++), and
 # libobjc/configure.ac (for Objective-C).
diff -ur libgcc-orig/configure.ac libgcc-baremetal/configure.ac
--- libgcc-orig/configure.ac	2011-11-07 08:34:31.000000000 -0800
+++ libgcc-baremetal/configure.ac	2012-05-27 11:49:22.000000000 -0700
@@ -184,6 +184,14 @@
 # config.gcc also contains tests of with_system_libunwind.
 GCC_CHECK_UNWIND_GETIPINFO
 
+# For bare metal toolchain libundwind exceptions can be disabled
+AC_ARG_ENABLE(libunwind-exceptions,
+  [AC_HELP_STRING([--disable-libunwind-exceptions],
+                [disable use of libunwind when build libgcc])],
+  [enable_libunwind_exceptions=$enableval],
+  [enable_libunwind_exceptions=yes])
+AC_SUBST(enable_libunwind_exceptions)
+
 # The sjlj test is almost duplicated here and in libgo/configure.ac (for C),
 # libstdc++-v3/acinclude.m4 and libjava/configure.ac (for C++), and
 # libobjc/configure.ac (for Objective-C).
diff -ur libgcc-orig/Makefile.in libgcc-baremetal/Makefile.in
--- libgcc-orig/Makefile.in	2011-11-21 19:01:02.000000000 -0800
+++ libgcc-baremetal/Makefile.in	2012-05-29 18:45:03.000000000 -0700
@@ -41,6 +41,7 @@
 decimal_float = @decimal_float@
 enable_decimal_float = @enable_decimal_float@
 fixed_point = @fixed_point@
+enable_libunwind_exceptions = @enable_libunwind_exceptions@
 
 host_noncanonical = @host_noncanonical@
 target_noncanonical = @target_noncanonical@
@@ -497,17 +498,23 @@
 endif
 
 # Build LIB2_DIVMOD_FUNCS.
+ifeq ($(enable_libunwind_exceptions),yes)
+LIB2_DIVMOD_CFLAGS := -fexceptions -fnon-call-exceptions
+else
+LIB2_DIVMOD_CFLAGS := -fno-exceptions -fno-non-call-exceptions
+endif
+
 lib2-divmod-o = $(patsubst %,%$(objext),$(LIB2_DIVMOD_FUNCS))
 $(lib2-divmod-o): %$(objext): $(srcdir)/libgcc2.c
 	$(gcc_compile) -DL$* -c $< \
-	  -fexceptions -fnon-call-exceptions $(vis_hide)
+	  $(LIB2_DIVMOD_CFLAGS) $(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): $(srcdir)/libgcc2.c
 	$(gcc_s_compile) -DL$* -c $< \
-	  -fexceptions -fnon-call-exceptions
+	  $(LIB2_DIVMOD_CFLAGS) $(vis_hide)
 libgcc-s-objects += $(lib2-divmod-s-o)
 endif
 
@@ -810,7 +817,11 @@
 # libgcc_eh.a, only LIB2ADDEH matters.  If we do, only LIB2ADDEHSTATIC and
 # LIB2ADDEHSHARED matter.  (Usually all three are identical.)
 
+ifeq ($(enable_libunwind_exceptions),yes)
 c_flags := -fexceptions
+else
+c_flags := -fno-exceptions
+endif
 
 ifeq ($(enable_shared),yes)
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]