automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best means to override CXXFLAGS locally


From: Dan McMahill
Subject: Re: Best means to override CXXFLAGS locally
Date: Mon, 30 Oct 2006 08:44:07 -0500
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7.11) Gecko/20050802

Akim Demaille wrote:
What would be the cleanest means to handle this exception?


Here is what I did:
- Force automake to generate an object specific rule by
  using some foo_CXXFLAGS
- Open Makefile.in, get the specific rules.
- Use LTCOMPILECXX to factor the common part
- Append $(MY_NOPTION_CXXFLAGS) to it
- rename the (object) output file name Automake used
- include all this in the Makefile.am
- remove the foo_CXXFLAGS so that Automake do not
  produce a rule for this object
- and therefore my own rule is obeyed with conflict
- and finally pray for no significant changes in the
  future versions of Automake ;)

# This is an edited copy of Automake's compilation rule so that we can
# insert $(PARSER_CXXFLAGS) *after* $(CXXFLAGS) to override -O2.
# Using foo_CXXFLAGS does not suffice, since CXXFLAGS, a user
# variable, appears last.
ugrammar.lo: ugrammar.cc
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) $(PARSER_CXXFLAGS) -MT ugrammar.lo -MD -MP -MF "$(DEPDIR)/ugrammar.Tpo" -c -o ugrammar.lo `test -f 'ugrammar.cc' || echo '$(srcdir)/'`ugrammar.cc; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/ugrammar.Tpo" "$(DEPDIR)/ ugrammar.Plo"; else rm -f "$(DEPDIR)/ugrammar.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ugrammar.cc' object='ugrammar.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $ (depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) $(PARSER_CXXFLAGS) -c -o ugrammar.lo `test -f 'ugrammar.cc' || echo '$(srcdir)/'`ugrammar.cc


Is there anything better to do?  Is there a trap I just fell in?

Does it work with non-gcc compilers?

I've used something like this:

# work around buggy compilers when compiling the parser with optimization
# make sure no one sneaks a -O* in on us via one of these variables
# set in the environment
CXX_NOOPT=$(CXX:-O%=)
CPPFLAGS_NOOPT=$(CPPFLAGS:-O%=)
CXXFLAGS_NOOPT=$(CXXFLAGS:-O%=)

And if you're using libtool, you can define a LTCXXCOMPILE_NOOPT in a similar way.

It is a common enough problem that I wonder if it is worth requesting a automake feature that lists a set of files which may have problems with optimizing compilers. As much as I hate to suggest it, you could then use autoconf to define a conditional where you tabulate known bad compilers. You could also just across the board prevent optimization on a particular set of files.

-Dan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]