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]

Re: [gcc-in-cxx] Bootstrap libcpp with c++


Hello Jerry,

* Jerry Quinn wrote on Tue, Jun 30, 2009 at 04:06:38PM CEST:
> 	* Makefile.in: (WARN_CFLAGS): Use general and C-specific
> 	warnings.
> 	(CXX, CXXFLAGS, WARN_CXXFLAGS, ALL_CXXFLAGS,
> 	ENABLE_BUILD_WITH_CXX, COMPILER): New.
> 	(COMPILE.base): Use COMPILER instead of CC.
> 	* configure.ac: Invoke AC_PROG_CXX.  Separate C-specific
> 	warnings from other warnings.  Add -Wc++-compat to C-specific
> 	warnings.  Check for --enable-build-with-cxx.  Set and
> 	substitute ENABLE_BUILD_WITH_CXX.

With this patch applied and --enable-build-with-cxx enabled, will all
files in the libcpp directory be compiled with the C++ compiler?

I think it is possible that $(CC) and $(CXX) refer to different
compilers, and they might be non-GNU.  In that case, the dependency
tracking mechanism which is called in libcpp/configure.ac for $CC only:
  ZW_PROG_COMPILER_DEPENDENCIES([CC])

also needs to be called for CXX, and also $(DEPMODE), which is currently
hard-coded to @CCDEPMODE@ in the Makefile.in file, needs to be adjusted.

With non-GNU C and C++ compilers, you cannot expect CCDEPMODE and
CXXDEPMODE to be identical, even if the compilers are guaranteed to come
from the same compiler suite and version.

Cheers,
Ralf

> --- libcpp/Makefile.in	(revision 149079)
> +++ libcpp/Makefile.in	(working copy)
> @@ -33,7 +33,10 @@
>  CATALOGS = $(patsubst %,po/%,@CATALOGS@)
>  CC = @CC@
>  CFLAGS = @CFLAGS@
> -WARN_CFLAGS = @WARN_CFLAGS@ @WARN_PEDANTIC@ @WERROR@
> +WARN_CFLAGS = @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@
> +CXX = @CXX@
> +CXXFLAGS = @CXXFLAGS@
> +WARN_CXXFLAGS = @warn@ @WARN_PEDANTIC@ @WERROR@
>  CPP = @CPP@
>  CPPFLAGS = @CPPFLAGS@
>  EXEEXT = @EXEEXT@
> @@ -68,7 +71,19 @@
>  	-I$(srcdir)/include
>  
>  ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS)
> +ALL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(INCLUDES) $(CPPFLAGS)
>  
> +# The name of the compiler to use.
> +ENABLE_BUILD_WITH_CXX = @ENABLE_BUILD_WITH_CXX@
> +ifneq ($(ENABLE_BUILD_WITH_CXX),yes)
> +COMPILER = $(CC)
> +COMPILER_FLAGS = $(ALL_CFLAGS)
> +else
> +COMPILER = $(CXX)
> +COMPILER_FLAGS = $(ALL_CXXFLAGS)
> +endif
> +
> +
>  libcpp_a_OBJS = charset.o directives.o directives-only.o errors.o \
>  	expr.o files.o identifiers.o init.o lex.o line-map.o macro.o \
>  	mkdeps.o pch.o symtab.o traditional.o
> @@ -189,7 +204,7 @@
>    install-man update-po install-html
>  
>  # Dependency rule.
> -COMPILE.base = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(ALL_CFLAGS) -c
> +COMPILE.base = $(COMPILER) $(DEFS) $(INCLUDES) $(CPPFLAGS)
> $(COMPILER_FLAGS) -c
>  ifeq ($(DEPMODE),depmode=gcc3)
>  # Note that we put the dependencies into a .Tpo file, then move them
>  # into place if the compile succeeds.  We need this because gcc does

> --- libcpp/configure.ac	(revision 149079)
> +++ libcpp/configure.ac	(working copy)
> @@ -11,8 +11,18 @@
>  AC_PROG_MAKE_SET
>  AC_PROG_INSTALL
>  AC_PROG_CC
> +AC_PROG_CXX
>  AC_PROG_RANLIB
>  
> +# See if we are building gcc with C++.
> +# Do this early so setting lang to C++ affects following tests
> +AC_ARG_ENABLE(build-with-cxx,
> +[  --enable-build-with-cxx build with C++ compiler instead of C
> compiler],
> +[ENABLE_BUILD_WITH_CXX=$enableval
> +AC_LANG(C++)],
> +ENABLE_BUILD_WITH_CXX=no)
> +AC_SUBST(ENABLE_BUILD_WITH_CXX)
> +
>  MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
>  AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal])
>  AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf])
> @@ -21,9 +31,10 @@
>  # Figure out what compiler warnings we can enable.
>  # See config/warnings.m4 for details.
>  
> -ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes
> \
> -			  -Wmissing-prototypes -Wold-style-definition \
> -			  -Wmissing-format-attribute])
> +ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings \
> +			  -Wmissing-format-attribute], [warn])
> +ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \
> +			  -Wold-style-definition -Wc++-compat], [c_warn])
>  ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
>  
>  # Only enable with --enable-werror-always until existing warnings are


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