diff mbox

Use C++ in COMPILER_FOR_BUILD if needed (issue6191056)

Message ID 20120508224653.B528A102847@torture.tor.corp.google.com
State New
Headers show

Commit Message

Diego Novillo May 8, 2012, 10:46 p.m. UTC
Found this while testing the C++ conversion for vec.[ch] on the
cxx-conversion branch.  We do not build the build/*.o files with g++,
so I was getting lots of syntax errors while compiling build/vec.o.

I am not completely sure if the changes are correct.  But it works for
me.

Tested on x86_64.  OK for trunk?

2012-05-08   Diego Novillo  <dnovillo@google.com>

	* Makefile.in (CXX_FOR_BUILD): Define.
	(BUILD_CXX_FLAGS): Define
	(COMPILER_FOR_BUILD): Set to CXX_FOR_BUILD if building with C++.
	(LINKER_FOR_BUILD): Likewise.
	(BUILD_COMPILERFLAGS): Set to BUILD_CXXFLAGS if building with C++.
	(BUILD_LINKERFLAGS): Likewise.


--
This patch is available for review at http://codereview.appspot.com/6191056

Comments

Diego Novillo May 30, 2012, 12:03 p.m. UTC | #1
Ping.

On Tue, May 8, 2012 at 6:46 PM, Diego Novillo <dnovillo@google.com> wrote:
>
> Found this while testing the C++ conversion for vec.[ch] on the
> cxx-conversion branch.  We do not build the build/*.o files with g++,
> so I was getting lots of syntax errors while compiling build/vec.o.
>
> I am not completely sure if the changes are correct.  But it works for
> me.
>
> Tested on x86_64.  OK for trunk?
>
> 2012-05-08   Diego Novillo  <dnovillo@google.com>
>
>        * Makefile.in (CXX_FOR_BUILD): Define.
>        (BUILD_CXX_FLAGS): Define
>        (COMPILER_FOR_BUILD): Set to CXX_FOR_BUILD if building with C++.
>        (LINKER_FOR_BUILD): Likewise.
>        (BUILD_COMPILERFLAGS): Set to BUILD_CXXFLAGS if building with C++.
>        (BUILD_LINKERFLAGS): Likewise.
>
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index ec27f88..1aa9dad 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -728,15 +728,27 @@ DIR = ../gcc
>
>  # Native compiler for the build machine and its switches.
>  CC_FOR_BUILD = @CC_FOR_BUILD@
> +CXX_FOR_BUILD = @CXX_FOR_BUILD@
>  BUILD_CFLAGS= @BUILD_CFLAGS@ -DGENERATOR_FILE
> +BUILD_CXXFLAGS = $(INTERNAL_CFLAGS) $(CXXFLAGS) -DGENERATOR_FILE
>
>  # Native compiler that we use.  This may be C++ some day.
> +ifneq ($(ENABLE_BUILD_WITH_CXX),yes)
>  COMPILER_FOR_BUILD = $(CC_FOR_BUILD)
>  BUILD_COMPILERFLAGS = $(BUILD_CFLAGS)
> +else
> +COMPILER_FOR_BUILD = $(CXX_FOR_BUILD)
> +BUILD_COMPILERFLAGS = $(BUILD_CXXFLAGS)
> +endif
>
>  # Native linker that we use.
> +ifneq ($(ENABLE_BUILD_WITH_CXX),yes)
>  LINKER_FOR_BUILD = $(CC_FOR_BUILD)
>  BUILD_LINKERFLAGS = $(BUILD_CFLAGS)
> +else
> +LINKER_FOR_BUILD = $(CXX_FOR_BUILD)
> +BUILD_LINKERFLAGS = $(BUILD_CXXFLAGS)
> +endif
>
>  # Native linker and preprocessor flags.  For x-fragment overrides.
>  BUILD_LDFLAGS=@BUILD_LDFLAGS@
>
> --
> This patch is available for review at http://codereview.appspot.com/6191056
DJ Delorie May 30, 2012, 5:42 p.m. UTC | #2
> >  BUILD_CFLAGS= @BUILD_CFLAGS@ -DGENERATOR_FILE
> > +BUILD_CXXFLAGS = $(INTERNAL_CFLAGS) $(CXXFLAGS) -DGENERATOR_FILE

Why are these so different?

The rest seem OK
diff mbox

Patch

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index ec27f88..1aa9dad 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -728,15 +728,27 @@  DIR = ../gcc
 
 # Native compiler for the build machine and its switches.
 CC_FOR_BUILD = @CC_FOR_BUILD@
+CXX_FOR_BUILD = @CXX_FOR_BUILD@
 BUILD_CFLAGS= @BUILD_CFLAGS@ -DGENERATOR_FILE
+BUILD_CXXFLAGS = $(INTERNAL_CFLAGS) $(CXXFLAGS) -DGENERATOR_FILE
 
 # Native compiler that we use.  This may be C++ some day.
+ifneq ($(ENABLE_BUILD_WITH_CXX),yes)
 COMPILER_FOR_BUILD = $(CC_FOR_BUILD)
 BUILD_COMPILERFLAGS = $(BUILD_CFLAGS)
+else
+COMPILER_FOR_BUILD = $(CXX_FOR_BUILD)
+BUILD_COMPILERFLAGS = $(BUILD_CXXFLAGS)
+endif
 
 # Native linker that we use.
+ifneq ($(ENABLE_BUILD_WITH_CXX),yes)
 LINKER_FOR_BUILD = $(CC_FOR_BUILD)
 BUILD_LINKERFLAGS = $(BUILD_CFLAGS)
+else
+LINKER_FOR_BUILD = $(CXX_FOR_BUILD)
+BUILD_LINKERFLAGS = $(BUILD_CXXFLAGS)
+endif
 
 # Native linker and preprocessor flags.  For x-fragment overrides.
 BUILD_LDFLAGS=@BUILD_LDFLAGS@