public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [build, libgcc] Correctly apply c_flags in shared-object.mk
@ 2011-06-14 15:02 Rainer Orth
  0 siblings, 0 replies; only message in thread
From: Rainer Orth @ 2011-06-14 15:02 UTC (permalink / raw)
  To: gcc-patches; +Cc: Paolo Bonzini, Ralf Wildenhues

When I first did a Solaris 11/x86 bootstrap with gld after checking in
my ENABLE_EXECUTE_STACK patch, I found that several acats and gnat.dg
tests were failing.  This hadn't happened with Sun ld.

Reghunting revealed that this had been introduced by that patch.
Fortunately, not the code itself was at fault.  Instead, before the
patch _enable_execute_stack.o had been compiled without -fexceptions,
while afterwards (with enable-execute-stack.c added to LIB2ADD)
-fexceptions was used.  I don't yet understand why this is a problem,
and only with gld, but clearly this is not how the LIB2ADD and
LIB2ADD_ST objects are supposed to be compiled.  In libgcc/Makefile.in,
we have

# Build LIB2ADD and LIB2ADD_ST.
[...]
c_flags :=
iter-items := $(LIB2ADD) $(LIB2ADD_ST)
include $(iterator)

with

iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/shared-object.mk,$(iter-items))

The problem is that the rule created from shared-object.mk to compile
LIB2ADD members refers to $(c_flags), but that variable is evaluated at
the point the rule is invoked, not when it is created.

Makefile.in sets c_flags 3 times:

# Build LIB2ADD and LIB2ADD_ST.
[...]
c_flags :=

# Build LIB2ADDEH, LIB2ADDEHSTATIC, and LIB2ADDEHSHARED.  If we don't have
[...]
c_flags := -fexceptions

# Build LIBUNWIND.
[...]
c_flags := -fexceptions

The effect is that not only LIB2ADDEH* and LIBUNWIND sources are
compiled with -fexceptions, but everything in LIB2ADD{, _ST}.

The following patch fixes this by storing the current value of c_flags
in a per-source variable and using that in the generated rules.  I've
checked that the LIB2ADD members are no longer compiled with
-fexceptions.  With that patch, all the acats and gnat.dg failures are
gone.

Bootstrapped without regressions on i386-pc-solaris2.11.

Ok for mainline?

	Rainer


2011-06-12  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* shared-object.mk ($o-opt): Save c_flags.
	($(base)$(objext)): Use it.
	($(base)_s$(objext)): Likewise.

diff --git a/libgcc/shared-object.mk b/libgcc/shared-object.mk
--- a/libgcc/shared-object.mk
+++ b/libgcc/shared-object.mk
@@ -6,13 +6,17 @@ iter-items := $(filter-out $o,$(iter-ite
 
 base := $(basename $(notdir $o))
 
+$o-opt := $(c_flags)
+
+#$(info $o: c_flags=$(c_flags) o-opt=$($(o)-opt))
+
 ifeq ($(suffix $o),.c)
 
 $(base)$(objext): $o
-	$(gcc_compile) $(c_flags) -c $< $(vis_hide)
+	$(gcc_compile) $($<-opt) -c $< $(vis_hide)
 
 $(base)_s$(objext): $o
-	$(gcc_s_compile) $(c_flags) -c $<
+	$(gcc_s_compile) $($<-opt) -c $<
 
 else
 

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-14 14:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-14 15:02 [build, libgcc] Correctly apply c_flags in shared-object.mk Rainer Orth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).