Patchwork PATCH: Remove AM_MAKEFLAGS from libsanitizer

login
register
mail settings
Submitter H.J. Lu
Date Dec. 12, 2012, 5:30 p.m.
Message ID <CAMe9rOoofad8-7YZi9CToV2u7rhQ+TzRqAgGQ-+sG4SDh3SZ-A@mail.gmail.com>
Download mbox | patch
Permalink /patch/205586/
State New
Headers show

Comments

H.J. Lu - Dec. 12, 2012, 5:30 p.m.
On Wed, Dec 12, 2012 at 6:46 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
> Il 12/12/2012 15:41, H.J. Lu ha scritto:
>> MAKEOVERRIDES is used for multilib.  I got
>>
>> /bin/sh ../libtool --tag=CXX   --mode=compile  -D_GNU_SOURCE -D_DEBUG
>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
>> -DASAN_HAS_EXCEPTIONS=1 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
>> -DASAN_NEEDS_SEGV=1  -I.
>> -I/export/gnu/import/git/gcc/libsanitizer/asan  -I
>> /export/gnu/import/git/gcc/libsanitizer/include -I
>> /export/gnu/import/git/gcc/libsanitizer  -Wall -W
>> -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC
>> -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables
>> -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions
>> -I../../libstdc++-v3/include
>> -I../../libstdc++-v3/include/x86_64-unknown-linux-gnu
>> -I/export/gnu/import/git/gcc/libsanitizer/../libstdc++-v3/libsupc++ -g
>> -O2 -D_GNU_SOURCE  -m32 -MT asan_malloc_linux.lo -MD -MP -MF
>> .deps/asan_malloc_linux.Tpo -c -o asan_malloc_linux.lo
>> /export/gnu/import/git/gcc/libsanitizer/asan/asan_malloc_linux.cc
>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>> libtool: compile: Try `libtool --help' for more information.
>> make[8]: *** [asan_allocator.lo] Error 1
>> make[8]: *** Waiting for unfinished jobs....
>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>> libtool: compile: Try `libtool --help' for more information
>>
>> I checked in this patch to restore MAKEOVERRIDES.
>
> This will break "make CFLAGS=-g".  Please revert the AM_MAKEFLAGS change
> fully.

Done.

> However, your patch that removed AM_MAKEFLAGS similarly broke "make
> CC=foo".  While it is much less useful, this nevertheless may be the
> sign of a bigger problem.  Why did you need to remove CC/CXX from
> AM_MAKEFLAGS in the first place?
>

After further investigation, I found

RAW_CXX_TARGET_EXPORTS = \
        $(BASE_TARGET_EXPORTS) \
        CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
        CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
export CXX;
...

all-stage1-target-libsanitizer: configure-stage1-target-libsanitizer
        @[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
        @r=`${PWD_COMMAND}`; export r; \
        s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
        TFLAGS="$(STAGE1_TFLAGS)"; \
        $(RAW_CXX_TARGET_EXPORTS)  \
        cd $(TARGET_SUBDIR)/libsanitizer && \
        $(MAKE) $(BASE_FLAGS_TO_PASS) \
                CFLAGS="$(CFLAGS_FOR_TARGET)" \
                CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
                LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
                CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
                CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
                LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
                $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)'
'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
                  \
                TFLAGS="$(STAGE1_TFLAGS)" \
                $(TARGET-stage1-target-libsanitizer)

The problem is

CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'

Those are bogus since

1. We never set RAW_CXX_FOR_TARGET.
2. We have set

        CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
        CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
export CXX;

in RAW_CXX_TARGET_EXPORTS.  There is no need to do anything.

As the result, we get empty CXX and CXX_FOR_TARGET for multilib
libsanitizer build.  That is why removing CC/CXX from AM_MAKEFLAGS
was needed.  I am testing this patch.  But we don't want to pass
CC/CXX to multilib build since:

[hjl@gnu-mic-2 x86_64-unknown-linux-gnu]$ grep "^CXX ="
libsanitizer/Makefile 32/libsanitizer/Makefile
libsanitizer/Makefile:CXX =
/export/build/gnu/gcc-asan/build-x86_64-linux/./gcc/xgcc
-shared-libgcc -B/export/build/gnu/gcc-asan/build-x86_64-linux/./gcc
-nostdinc++ -L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src
-L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-B/usr/local/x86_64-unknown-linux-gnu/bin/
-B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem
/usr/local/x86_64-unknown-linux-gnu/include -isystem
/usr/local/x86_64-unknown-linux-gnu/sys-include
32/libsanitizer/Makefile:CXX =
/export/build/gnu/gcc-asan/build-x86_64-linux/./gcc/xgcc
-shared-libgcc -B/export/build/gnu/gcc-asan/build-x86_64-linux/./gcc
-nostdinc++ -L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/32/libstdc++-v3/src
-L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs
-B/usr/local/x86_64-unknown-linux-gnu/bin/
-B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem
/usr/local/x86_64-unknown-linux-gnu/include -isystem
/usr/local/x86_64-unknown-linux-gnu/sys-include  -m32
[hjl@gnu-mic-2 x86_64-unknown-linux-gnu]$

As you can see, CXX are different for multilib.  If we CXX down:

all-multi:
        $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE)

we may get the wrong CXX for multilib.

This patch fixes multilib build.  But we may still want to keep
AM_MAKEFLAGS for "make CFLAGS=-g".
Paolo Bonzini - Dec. 12, 2012, 6:01 p.m.
Il 12/12/2012 18:30, H.J. Lu ha scritto:
> On Wed, Dec 12, 2012 at 6:46 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
>> Il 12/12/2012 15:41, H.J. Lu ha scritto:
>>> MAKEOVERRIDES is used for multilib.  I got
>>>
>>> /bin/sh ../libtool --tag=CXX   --mode=compile  -D_GNU_SOURCE -D_DEBUG
>>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
>>> -DASAN_HAS_EXCEPTIONS=1 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
>>> -DASAN_NEEDS_SEGV=1  -I.
>>> -I/export/gnu/import/git/gcc/libsanitizer/asan  -I
>>> /export/gnu/import/git/gcc/libsanitizer/include -I
>>> /export/gnu/import/git/gcc/libsanitizer  -Wall -W
>>> -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC
>>> -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables
>>> -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions
>>> -I../../libstdc++-v3/include
>>> -I../../libstdc++-v3/include/x86_64-unknown-linux-gnu
>>> -I/export/gnu/import/git/gcc/libsanitizer/../libstdc++-v3/libsupc++ -g
>>> -O2 -D_GNU_SOURCE  -m32 -MT asan_malloc_linux.lo -MD -MP -MF
>>> .deps/asan_malloc_linux.Tpo -c -o asan_malloc_linux.lo
>>> /export/gnu/import/git/gcc/libsanitizer/asan/asan_malloc_linux.cc
>>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>>> libtool: compile: Try `libtool --help' for more information.
>>> make[8]: *** [asan_allocator.lo] Error 1
>>> make[8]: *** Waiting for unfinished jobs....
>>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>>> libtool: compile: Try `libtool --help' for more information
>>>
>>> I checked in this patch to restore MAKEOVERRIDES.
>>
>> This will break "make CFLAGS=-g".  Please revert the AM_MAKEFLAGS change
>> fully.
> 
> Done.
> 
>> However, your patch that removed AM_MAKEFLAGS similarly broke "make
>> CC=foo".  While it is much less useful, this nevertheless may be the
>> sign of a bigger problem.  Why did you need to remove CC/CXX from
>> AM_MAKEFLAGS in the first place?
>>
> 
> After further investigation, I found
> 
> RAW_CXX_TARGET_EXPORTS = \
>         $(BASE_TARGET_EXPORTS) \
>         CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
>         CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
> export CXX;
> ...
> 
> all-stage1-target-libsanitizer: configure-stage1-target-libsanitizer
>         @[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
>         @r=`${PWD_COMMAND}`; export r; \
>         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
>         TFLAGS="$(STAGE1_TFLAGS)"; \
>         $(RAW_CXX_TARGET_EXPORTS)  \
>         cd $(TARGET_SUBDIR)/libsanitizer && \
>         $(MAKE) $(BASE_FLAGS_TO_PASS) \
>                 CFLAGS="$(CFLAGS_FOR_TARGET)" \
>                 CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
>                 LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
>                 CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
>                 CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
>                 LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
>                 $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)'
> 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
>                   \
>                 TFLAGS="$(STAGE1_TFLAGS)" \
>                 $(TARGET-stage1-target-libsanitizer)
> 
> The problem is
> 
> CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'
> 
> Those are bogus since
> 
> 1. We never set RAW_CXX_FOR_TARGET.
> 2. We have set
> 
>         CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
>         CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
> export CXX;
> 
> in RAW_CXX_TARGET_EXPORTS.  There is no need to do anything.

Nope, if you remove this you get the wrong definition of CC and CXX from
EXTRA_TARGET_FLAGS.  Instead, you need to add RAW_CXX_FOR_TARGET to
AM_MAKEFLAGS and EXTRA_TARGET_FLAGS.

Paolo

> As the result, we get empty CXX and CXX_FOR_TARGET for multilib
> libsanitizer build.  That is why removing CC/CXX from AM_MAKEFLAGS
> was needed.  I am testing this patch.  But we don't want to pass
> CC/CXX to multilib build since:
> 
> [hjl@gnu-mic-2 x86_64-unknown-linux-gnu]$ grep "^CXX ="
> libsanitizer/Makefile 32/libsanitizer/Makefile
> libsanitizer/Makefile:CXX =
> /export/build/gnu/gcc-asan/build-x86_64-linux/./gcc/xgcc
> -shared-libgcc -B/export/build/gnu/gcc-asan/build-x86_64-linux/./gcc
> -nostdinc++ -L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src
> -L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
> -B/usr/local/x86_64-unknown-linux-gnu/bin/
> -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem
> /usr/local/x86_64-unknown-linux-gnu/include -isystem
> /usr/local/x86_64-unknown-linux-gnu/sys-include
> 32/libsanitizer/Makefile:CXX =
> /export/build/gnu/gcc-asan/build-x86_64-linux/./gcc/xgcc
> -shared-libgcc -B/export/build/gnu/gcc-asan/build-x86_64-linux/./gcc
> -nostdinc++ -L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/32/libstdc++-v3/src
> -L/export/build/gnu/gcc-asan/build-x86_64-linux/x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs
> -B/usr/local/x86_64-unknown-linux-gnu/bin/
> -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem
> /usr/local/x86_64-unknown-linux-gnu/include -isystem
> /usr/local/x86_64-unknown-linux-gnu/sys-include  -m32
> [hjl@gnu-mic-2 x86_64-unknown-linux-gnu]$
> 
> As you can see, CXX are different for multilib.  If we CXX down:
> 
> all-multi:
>         $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE)
> 
> we may get the wrong CXX for multilib.
> 
> This patch fixes multilib build.  But we may still want to keep
> AM_MAKEFLAGS for "make CFLAGS=-g".
> 
>
H.J. Lu - Dec. 12, 2012, 6:11 p.m.
On Wed, Dec 12, 2012 at 10:01 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
> Il 12/12/2012 18:30, H.J. Lu ha scritto:
>> On Wed, Dec 12, 2012 at 6:46 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
>>> Il 12/12/2012 15:41, H.J. Lu ha scritto:
>>>> MAKEOVERRIDES is used for multilib.  I got
>>>>
>>>> /bin/sh ../libtool --tag=CXX   --mode=compile  -D_GNU_SOURCE -D_DEBUG
>>>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
>>>> -DASAN_HAS_EXCEPTIONS=1 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
>>>> -DASAN_NEEDS_SEGV=1  -I.
>>>> -I/export/gnu/import/git/gcc/libsanitizer/asan  -I
>>>> /export/gnu/import/git/gcc/libsanitizer/include -I
>>>> /export/gnu/import/git/gcc/libsanitizer  -Wall -W
>>>> -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC
>>>> -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables
>>>> -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions
>>>> -I../../libstdc++-v3/include
>>>> -I../../libstdc++-v3/include/x86_64-unknown-linux-gnu
>>>> -I/export/gnu/import/git/gcc/libsanitizer/../libstdc++-v3/libsupc++ -g
>>>> -O2 -D_GNU_SOURCE  -m32 -MT asan_malloc_linux.lo -MD -MP -MF
>>>> .deps/asan_malloc_linux.Tpo -c -o asan_malloc_linux.lo
>>>> /export/gnu/import/git/gcc/libsanitizer/asan/asan_malloc_linux.cc
>>>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>>>> libtool: compile: Try `libtool --help' for more information.
>>>> make[8]: *** [asan_allocator.lo] Error 1
>>>> make[8]: *** Waiting for unfinished jobs....
>>>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>>>> libtool: compile: Try `libtool --help' for more information
>>>>
>>>> I checked in this patch to restore MAKEOVERRIDES.
>>>
>>> This will break "make CFLAGS=-g".  Please revert the AM_MAKEFLAGS change
>>> fully.
>>
>> Done.
>>
>>> However, your patch that removed AM_MAKEFLAGS similarly broke "make
>>> CC=foo".  While it is much less useful, this nevertheless may be the
>>> sign of a bigger problem.  Why did you need to remove CC/CXX from
>>> AM_MAKEFLAGS in the first place?
>>>
>>
>> After further investigation, I found
>>
>> RAW_CXX_TARGET_EXPORTS = \
>>         $(BASE_TARGET_EXPORTS) \
>>         CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
>>         CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
>> export CXX;
>> ...
>>
>> all-stage1-target-libsanitizer: configure-stage1-target-libsanitizer
>>         @[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
>>         @r=`${PWD_COMMAND}`; export r; \
>>         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
>>         TFLAGS="$(STAGE1_TFLAGS)"; \
>>         $(RAW_CXX_TARGET_EXPORTS)  \
>>         cd $(TARGET_SUBDIR)/libsanitizer && \
>>         $(MAKE) $(BASE_FLAGS_TO_PASS) \
>>                 CFLAGS="$(CFLAGS_FOR_TARGET)" \
>>                 CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
>>                 LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
>>                 CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
>>                 CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
>>                 LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
>>                 $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)'
>> 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
>>                   \
>>                 TFLAGS="$(STAGE1_TFLAGS)" \
>>                 $(TARGET-stage1-target-libsanitizer)
>>
>> The problem is
>>
>> CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'
>>
>> Those are bogus since
>>
>> 1. We never set RAW_CXX_FOR_TARGET.
>> 2. We have set
>>
>>         CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
>>         CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
>> export CXX;
>>
>> in RAW_CXX_TARGET_EXPORTS.  There is no need to do anything.
>
> Nope, if you remove this you get the wrong definition of CC and CXX from
> EXTRA_TARGET_FLAGS.  Instead, you need to add RAW_CXX_FOR_TARGET to
> AM_MAKEFLAGS and EXTRA_TARGET_FLAGS.
>

We have set CXX and CXX_FOR_TARGET before EXTRA_TARGET_FLAGS
is used:

RAW_CXX_TARGET_EXPORTS = \
        $(BASE_TARGET_EXPORTS) \
        CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
        CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
export CXX;

Shouldn't we the right CXX and CXX_FOR_TARGET?
Paolo Bonzini - Dec. 12, 2012, 10:13 p.m.
Il 12/12/2012 19:11, H.J. Lu ha scritto:
>>> >>
>>> >> in RAW_CXX_TARGET_EXPORTS.  There is no need to do anything.
>> >
>> > Nope, if you remove this you get the wrong definition of CC and CXX from
>> > EXTRA_TARGET_FLAGS.  Instead, you need to add RAW_CXX_FOR_TARGET to
>> > AM_MAKEFLAGS and EXTRA_TARGET_FLAGS.
>> >
> We have set CXX and CXX_FOR_TARGET before EXTRA_TARGET_FLAGS
> is used:
> 
> RAW_CXX_TARGET_EXPORTS = \
>         $(BASE_TARGET_EXPORTS) \
>         CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
>         CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
> export CXX;
> 
> Shouldn't we the right CXX and CXX_FOR_TARGET?

The purpose of EXTRA_TARGET_FLAGS is to forward any *_FOR_TARGET
variable passed on the command line to the toplevel Makefile.

Paolo
H.J. Lu - Dec. 12, 2012, 11:01 p.m.
On Wed, Dec 12, 2012 at 2:13 PM, Paolo Bonzini <bonzini@gnu.org> wrote:
> Il 12/12/2012 19:11, H.J. Lu ha scritto:
>>>> >>
>>>> >> in RAW_CXX_TARGET_EXPORTS.  There is no need to do anything.
>>> >
>>> > Nope, if you remove this you get the wrong definition of CC and CXX from
>>> > EXTRA_TARGET_FLAGS.  Instead, you need to add RAW_CXX_FOR_TARGET to
>>> > AM_MAKEFLAGS and EXTRA_TARGET_FLAGS.
>>> >
>> We have set CXX and CXX_FOR_TARGET before EXTRA_TARGET_FLAGS
>> is used:
>>
>> RAW_CXX_TARGET_EXPORTS = \
>>         $(BASE_TARGET_EXPORTS) \
>>         CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
>>         CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
>> export CXX;
>>
>> Shouldn't we the right CXX and CXX_FOR_TARGET?
>
> The purpose of EXTRA_TARGET_FLAGS is to forward any *_FOR_TARGET
> variable passed on the command line to the toplevel Makefile.
>

We don't pass down RAW_CXX_FOR_TARGET from toplevel
Makefile.  If one wants to change RAW_CXX_FOR_TARGET
from command line, he/she should do

# make RAW_CXX_FOR_TARGET=xxx

and RAW_CXX_TARGET_EXPORTS should handle it properly.
H.J. Lu - Dec. 12, 2012, 11:23 p.m.
On Wed, Dec 12, 2012 at 3:01 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Dec 12, 2012 at 2:13 PM, Paolo Bonzini <bonzini@gnu.org> wrote:
>> Il 12/12/2012 19:11, H.J. Lu ha scritto:
>>>>> >>
>>>>> >> in RAW_CXX_TARGET_EXPORTS.  There is no need to do anything.
>>>> >
>>>> > Nope, if you remove this you get the wrong definition of CC and CXX from
>>>> > EXTRA_TARGET_FLAGS.  Instead, you need to add RAW_CXX_FOR_TARGET to
>>>> > AM_MAKEFLAGS and EXTRA_TARGET_FLAGS.
>>>> >
>>> We have set CXX and CXX_FOR_TARGET before EXTRA_TARGET_FLAGS
>>> is used:
>>>
>>> RAW_CXX_TARGET_EXPORTS = \
>>>         $(BASE_TARGET_EXPORTS) \
>>>         CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
>>>         CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
>>> export CXX;
>>>
>>> Shouldn't we the right CXX and CXX_FOR_TARGET?
>>
>> The purpose of EXTRA_TARGET_FLAGS is to forward any *_FOR_TARGET
>> variable passed on the command line to the toplevel Makefile.
>>
>
> We don't pass down RAW_CXX_FOR_TARGET from toplevel
> Makefile.  If one wants to change RAW_CXX_FOR_TARGET
> from command line, he/she should do
>
> # make RAW_CXX_FOR_TARGET=xxx
>
> and RAW_CXX_TARGET_EXPORTS should handle it properly.

Also there are:

# ------------------------------
# Special directives to GNU Make
# ------------------------------

# Don't pass command-line variables to submakes.
.NOEXPORT:
MAKEOVERRIDES=

in toplevel Makefile.  How does

# make *_FOR_TARGET=xxxx

work at toplevel?
Paolo Bonzini - Dec. 13, 2012, 7:32 a.m.
Il 13/12/2012 00:23, H.J. Lu ha scritto:
> On Wed, Dec 12, 2012 at 3:01 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Wed, Dec 12, 2012 at 2:13 PM, Paolo Bonzini <bonzini@gnu.org> wrote:
>>> Il 12/12/2012 19:11, H.J. Lu ha scritto:
>>>>>>>>
>>>>>>>> in RAW_CXX_TARGET_EXPORTS.  There is no need to do anything.
>>>>>>
>>>>>> Nope, if you remove this you get the wrong definition of CC and CXX from
>>>>>> EXTRA_TARGET_FLAGS.  Instead, you need to add RAW_CXX_FOR_TARGET to
>>>>>> AM_MAKEFLAGS and EXTRA_TARGET_FLAGS.
>>>>>>
>>>> We have set CXX and CXX_FOR_TARGET before EXTRA_TARGET_FLAGS
>>>> is used:
>>>>
>>>> RAW_CXX_TARGET_EXPORTS = \
>>>>         $(BASE_TARGET_EXPORTS) \
>>>>         CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
>>>>         CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS";
>>>> export CXX;
>>>>
>>>> Shouldn't we the right CXX and CXX_FOR_TARGET?
>>>
>>> The purpose of EXTRA_TARGET_FLAGS is to forward any *_FOR_TARGET
>>> variable passed on the command line to the toplevel Makefile.
>>>
>>
>> We don't pass down RAW_CXX_FOR_TARGET from toplevel
>> Makefile.  If one wants to change RAW_CXX_FOR_TARGET
>> from command line, he/she should do
>>
>> # make RAW_CXX_FOR_TARGET=xxx
>>
>> and RAW_CXX_TARGET_EXPORTS should handle it properly.

NORMAL_TARGET_EXPORTS and RAW_CXX_TARGET_EXPORTS is (mostly) for
configure time.  Makefiles do not use the environment variables, so you
need EXTRA_TARGET_FLAGS (and more generally the args argument to the
"all" macro) instead.

> 
> Also there are:
> 
> # ------------------------------
> # Special directives to GNU Make
> # ------------------------------
> 
> # Don't pass command-line variables to submakes.
> .NOEXPORT:
> MAKEOVERRIDES=
> 
> in toplevel Makefile.  How does
> 
> # make *_FOR_TARGET=xxxx
> 
> work at toplevel?

That's what I'm trying to say: the purpose of EXTRA_TARGET_FLAGS is to
forward any *_FOR_TARGET>> variable passed on the command line to the
toplevel Makefile.

Paolo

Patch

diff --git a/Makefile.tpl b/Makefile.tpl
index 5cdc119..dbcd5c3 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -1281,7 +1281,7 @@  maybe-[+make_target+]-[+module+]:
[+make_target+]-[+module+]

 [+ all prefix="target-" subdir="$(TARGET_SUBDIR)"
        exports="$(RAW_CXX_TARGET_EXPORTS)"
-       args="$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)'
'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'" +]
+       args="$(EXTRA_TARGET_FLAGS)" +]
 [+ ELSE +]