[Bug libstdc++/53579] libstdc++ configure atomicity tests use CXXFLAGS instead of CXXFLAGS_FOR_TARGET

2014-11-10 Thread ramana at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53579

Ramana Radhakrishnan ramana at gcc dot gnu.org changed:

   What|Removed |Added

 CC||ramana at gcc dot gnu.org

--- Comment #2 from Ramana Radhakrishnan ramana at gcc dot gnu.org ---
This is not just the atomicity tests that are affected.

 Now that we've switched to C++ in the main compiler, folks (especially in the
business of building cross-compilers) just set CXXFLAGS in the environment and
assume that this implies that the compiler built is built with the appropriate
CXXFLAGS. So, it's very easy to build a libstdc++ with the value of CXXFLAGS
set to something that wasn't expected. The build system appears to honour the
difference between CFLAGS and CFLAGS_FOR_TARGET, so it is natural that folks
expect that CXXFLAGS to behave in the same fashion.


[Bug libstdc++/53579] libstdc++ configure atomicity tests use CXXFLAGS instead of CXXFLAGS_FOR_TARGET

2012-08-07 Thread bkoz at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53579

Benjamin Kosnik bkoz at gcc dot gnu.org changed:

   What|Removed |Added

 CC||bkoz at gcc dot gnu.org

--- Comment #1 from Benjamin Kosnik bkoz at gcc dot gnu.org 2012-08-07 
20:53:26 UTC ---

Some notes.

src/Makefile.am does not export CXXFLAGS_FOR_TARGET, only CFLAGS_FOR_TARGET. 

The problem is that configure CXXFLAGS ends up being different than build
CXXFLAGS. And configure flags don't play with CXXFLAGS_FOR_TARGET (but build
flags do.)

gcc/Makefile.in has the pass down for target libs:
EXTRA_TARGET_FLAGS = \
'AR=$$(AR_FOR_TARGET)' \
'AS=$(COMPILER_AS_FOR_TARGET)' \
'CC=$$(CC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
'CFLAGS=$$(CFLAGS_FOR_TARGET)' \
'CXX=$$(CXX_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET)' \

This is what is expected and needed for build, but for configure the situation
is not working in an equivalent manner.

config/mt-gnu:
CXXFLAGS_FOR_TARGET = $(CXXFLAGS) -D_GNU_SOURCE

configure.ac:
if test x$CXXFLAGS_FOR_TARGET = x; then
  CXXFLAGS_FOR_TARGET=$CXXFLAGS
  case  $CXXFLAGS  in
* -O2 *) ;;
*) CXXFLAGS_FOR_TARGET=-O2 $CXXFLAGS_FOR_TARGET ;;
  esac
  case  $CXXFLAGS  in
* -g * | * -g3 *) ;;
*) CXXFLAGS_FOR_TARGET=-g $CXXFLAGS_FOR_TARGET ;;
  esac
fi
AC_SUBST(CXXFLAGS_FOR_TARGET)

ie, CXXFLAGS_FOR_TARGET is what should be used, not CXXFLAGS

There are a lot of C++ configure tests in libstdc++ (and other target libs!)
that use CXXFLAGS assuming it's the real thing used to build the library. Not
just atomicity. A consistent solution would be nice here. 

Possible solutions:

1) Setup GLIBCXX_CONFIGURE to export GLIBCXX_CXXFLAGS, which is then used
consistently during configure only, and incorporates CXXFLAGS_FOR_TARGET.
(Makefiles still use CXXFLAGS).

2) use CFLAGS_FOR_TARGET in libstdc++ config

3) like one, but have something like CXXFLAGS_EXTRA_FOR_TARGET which (unlike
CXXFLAGS_FOR_TARGET) is not supposed to replace CXXFLAGS, but instead is always
added to CXXFLAGS, not substituted for it.