diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 9a69320c8b17ca0c7714824ed329c966c9481994..dbe5f06645d0c799774dba405587ab3841ef0bdd 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-20  Hans-Peter Nilsson  <hp@axis.com>
+
+	* static-object.mk (c_flags-$o): Save c_flags.
+	($(base)$(objext)): Use it.
+
 2011-11-18  Steve Ellcey  <sje@cup.hp.com>
 
 	* Makefile.in (c_flags): Set to -fno-exceptions to build libunwind.
diff --git a/libgcc/static-object.mk b/libgcc/static-object.mk
index ab75d3288c3afd197f27c51e2e2f138695e84776..930f009cd4219538380b846bc1593fd9292ad954 100644
--- a/libgcc/static-object.mk
+++ b/libgcc/static-object.mk
@@ -6,10 +6,15 @@ iter-items := $(filter-out $o,$(iter-items))
 
 base := $(basename $(notdir $o))
 
+# Copy c_flags to a rule-specific copy and use the copy, to avoid the
+# following rules being affected by later changes to c_flags in the
+# including file.
+c_flags-$o := $(c_flags)
+
 ifeq ($(suffix $o),.c)
 
 $(base)$(objext): $o
-	$(gcc_compile) $(c_flags) -c $< $(vis_hide)
+	$(gcc_compile) $(c_flags-$<) -c $< $(vis_hide)
 
 else