On Wed, Dec 12, 2012 at 6:46 AM, Paolo Bonzini <[email protected]> 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".
--
H.J.
---
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 +]
[+ configure prefix="target-" subdir="$(TARGET_SUBDIR)"
check_multilibs=true
@@ -1313,11 +1313,7 @@ ELSE normal_cxx +]
$(NORMAL_TARGET_EXPORTS) \[+
ENDIF raw_cxx +]
(cd $(TARGET_SUBDIR)/[+module+] && \
- $(MAKE) $(TARGET_FLAGS_TO_PASS) [+
- IF raw_cxx
- +] 'CXX=$$(RAW_CXX_FOR_TARGET)'
'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)' [+
- ENDIF raw_cxx
- +] [+extra_make_flags+] check)
+ $(MAKE) $(TARGET_FLAGS_TO_PASS) [+extra_make_flags+] check)
[+ ENDIF no_check +]
@endif target-[+module+]