diff mbox

gcc/gcc-final: pass TARGET_CFLAGS flags to configure with --enable-cxx-flags

Message ID 1433169427-7527-1-git-send-email-jcmvbkbc@gmail.com
State Rejected
Headers show

Commit Message

Max Filippov June 1, 2015, 2:37 p.m. UTC
Currently only TARGET_ABI flags are passed to the final compiler
configure script and only when building for Xtensa. Since libstdc++ is a
normal library it should be built with full TARGET_CFLAGS on all
targets.

Pass TARGET_CFLAGS flags to gcc-final configure script for all targets
in the --enable-cxx-flags parameter.

Suggested-by: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 package/gcc/gcc-final/gcc-final.mk | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Yann E. MORIN Jan. 9, 2016, 10:08 p.m. UTC | #1
Max, All,

On 2015-06-01 17:37 +0300, Max Filippov spake thusly:
> Currently only TARGET_ABI flags are passed to the final compiler
> configure script and only when building for Xtensa. Since libstdc++ is a
> normal library it should be built with full TARGET_CFLAGS on all
> targets.
> 
> Pass TARGET_CFLAGS flags to gcc-final configure script for all targets
> in the --enable-cxx-flags parameter.
> 
> Suggested-by: Arnout Vandecappelle <arnout@mind.be>
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

So, I finally had a look at this patch. I've tested it to build a
gcc-4.9 + glibc-2.21 + binutils-2.24 toolchain with C++ support, which
then was used to suessfully build Qt5base (which is quite a heavy C++
user).

However, I'd like to understand what this is all about.

In gcc.mk, we do:

    GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS)
    [...]
    HOST_GCC_COMMON_CONF_ENV += CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"

So it looks like we were already passing the proper CXXFLAGS to gcc (we
only filter-out problematic flags, like -Os on broken gcc-4.5 for PPC).

So, what are we supposed to gain/loose with this change?

As a side note, we should not have to pass TARGET_ABI either, since it
is part of TARGET_CFLAGS and as shown above, it is already part of the
CFLAGS_FOR_TARGET that we pass gcc.

Any explanations? Something that I missed?

Regards,
Yann E. MORIN.

> ---
>  package/gcc/gcc-final/gcc-final.mk | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/package/gcc/gcc-final/gcc-final.mk b/package/gcc/gcc-final/gcc-final.mk
> index 8d7009b..59c8708 100644
> --- a/package/gcc/gcc-final/gcc-final.mk
> +++ b/package/gcc/gcc-final/gcc-final.mk
> @@ -185,8 +185,6 @@ endef
>  HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_INSTALL_USR_LIBS
>  endif
>  
> -ifeq ($(BR2_xtensa),y)
> -HOST_GCC_FINAL_CONF_OPTS += --enable-cxx-flags="$(TARGET_ABI)"
> -endif
> +HOST_GCC_FINAL_CONF_OPTS += --enable-cxx-flags="$(TARGET_CFLAGS)"
>  
>  $(eval $(host-autotools-package))
> -- 
> 1.8.1.4
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Arnout Vandecappelle March 8, 2016, 11:22 p.m. UTC | #2
Hi Max,

On 01/09/16 23:08, Yann E. MORIN wrote:
> Max, All,
>
> On 2015-06-01 17:37 +0300, Max Filippov spake thusly:
>> Currently only TARGET_ABI flags are passed to the final compiler
>> configure script and only when building for Xtensa. Since libstdc++ is a
>> normal library it should be built with full TARGET_CFLAGS on all
>> targets.
>>
>> Pass TARGET_CFLAGS flags to gcc-final configure script for all targets
>> in the --enable-cxx-flags parameter.
>>
>> Suggested-by: Arnout Vandecappelle <arnout@mind.be>
>> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
>
> So, I finally had a look at this patch. I've tested it to build a
> gcc-4.9 + glibc-2.21 + binutils-2.24 toolchain with C++ support, which
> then was used to suessfully build Qt5base (which is quite a heavy C++
> user).
>
> However, I'd like to understand what this is all about.
>
> In gcc.mk, we do:
>
>      GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS)
>      [...]
>      HOST_GCC_COMMON_CONF_ENV += CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"
>
> So it looks like we were already passing the proper CXXFLAGS to gcc (we
> only filter-out problematic flags, like -Os on broken gcc-4.5 for PPC).
>
> So, what are we supposed to gain/loose with this change?
>
> As a side note, we should not have to pass TARGET_ABI either, since it
> is part of TARGET_CFLAGS and as shown above, it is already part of the
> CFLAGS_FOR_TARGET that we pass gcc.
>
> Any explanations? Something that I missed?

  I checked in the gcc source and also couldn't find a reason why the 
CXXFLAGS_FOR_TARGET wouldn't work. Since you haven't replied to this, I've 
marked your patch as rejected in patchwork. If you do still fel it is warranted, 
please repost with a satisfactory explanation.

  Regards,
  Arnout

>
> Regards,
> Yann E. MORIN.
>
>> ---
>>   package/gcc/gcc-final/gcc-final.mk | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/package/gcc/gcc-final/gcc-final.mk b/package/gcc/gcc-final/gcc-final.mk
>> index 8d7009b..59c8708 100644
>> --- a/package/gcc/gcc-final/gcc-final.mk
>> +++ b/package/gcc/gcc-final/gcc-final.mk
>> @@ -185,8 +185,6 @@ endef
>>   HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_INSTALL_USR_LIBS
>>   endif
>>
>> -ifeq ($(BR2_xtensa),y)
>> -HOST_GCC_FINAL_CONF_OPTS += --enable-cxx-flags="$(TARGET_ABI)"
>> -endif
>> +HOST_GCC_FINAL_CONF_OPTS += --enable-cxx-flags="$(TARGET_CFLAGS)"
>>
>>   $(eval $(host-autotools-package))
>> --
>> 1.8.1.4
>>
>> _______________________________________________
>> buildroot mailing list
>> buildroot@busybox.net
>> http://lists.busybox.net/mailman/listinfo/buildroot
>
Max Filippov March 10, 2016, 9:37 a.m. UTC | #3
Arnout, Yann,

On Wed, Mar 9, 2016 at 2:22 AM, Arnout Vandecappelle <arnout@mind.be> wrote:
> On 01/09/16 23:08, Yann E. MORIN wrote:
>> On 2015-06-01 17:37 +0300, Max Filippov spake thusly:
>>>
>>> Currently only TARGET_ABI flags are passed to the final compiler
>>> configure script and only when building for Xtensa. Since libstdc++ is a
>>> normal library it should be built with full TARGET_CFLAGS on all
>>> targets.
>>>
>>> Pass TARGET_CFLAGS flags to gcc-final configure script for all targets
>>> in the --enable-cxx-flags parameter.
>>>
>>> Suggested-by: Arnout Vandecappelle <arnout@mind.be>
>>> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
>>
>>
>> So, I finally had a look at this patch. I've tested it to build a
>> gcc-4.9 + glibc-2.21 + binutils-2.24 toolchain with C++ support, which
>> then was used to suessfully build Qt5base (which is quite a heavy C++
>> user).
>>
>> However, I'd like to understand what this is all about.
>>
>> In gcc.mk, we do:
>>
>>      GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS)
>>      [...]
>>      HOST_GCC_COMMON_CONF_ENV +=
>> CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"
>>
>> So it looks like we were already passing the proper CXXFLAGS to gcc (we
>> only filter-out problematic flags, like -Os on broken gcc-4.5 for PPC).
>>
>> So, what are we supposed to gain/loose with this change?
>>
>> As a side note, we should not have to pass TARGET_ABI either, since it
>> is part of TARGET_CFLAGS and as shown above, it is already part of the
>> CFLAGS_FOR_TARGET that we pass gcc.
>>
>> Any explanations? Something that I missed?
>
>
>  I checked in the gcc source and also couldn't find a reason why the
> CXXFLAGS_FOR_TARGET wouldn't work. Since you haven't replied to this, I've
> marked your patch as rejected in patchwork. If you do still fel it is
> warranted, please repost with a satisfactory explanation.

Sorry, took me too long to answer the first mail.

AFAICS neither gcc-4.8.x nor gcc-4.9.x propagate CXXFLAGS_FOR_TARGET
to CXXFLAGS for builds of libstdc++. gcc-5.x however does.
Compare the following build log excerpts for libstdc++ of gcc-4.8, gcc-4.9 and
gcc-5 (I've reverted 2dcab526a97d and c44cf2cc97df before running these builds):

gcc-4.8:
make[3]: Entering directory
'/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.8.5/build/xtensa-buildroot-linux-uclibc/libstdc++-v3'
/usr/bin/make "AR_FLAGS=rc" "CC_FOR_BUILD=/usr/bin/gcc"
"CC_FOR_TARGET=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.8.5/build/./gcc/xgcc
-B/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.8.5/build/./gcc/"
"CFLAGS=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"CXXFLAGS=-O2 -I/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/include
-D_GNU_SOURCE" "CFLAGS_FOR_BUILD=-O2
-I/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/include"
"CFLAGS_FOR_TARGET=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"INSTALL=/usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c -m
644" "INSTALL_PROGRAM=/usr/bin/install -c"
"INSTALL_SCRIPT=/usr/bin/install -c" "LDFLAGS="
"LIBCFLAGS=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"LIBCFLAGS_FOR_TARGET=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"MAKE=/usr/bin/make"
"MAKEINFO=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.8.5/missing
makeinfo --split-size=5000000 --split-size=5000000 " "SHELL=/bin/bash"
"RUNTESTFLAGS="
"exec_prefix=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr"
"infodir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/share/info"
"libdir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/lib"
"includedir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/include"
"prefix=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr"
"tooldir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc"
"gxx_include_dir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/include/c++/4.8.5"
"AR=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/bin/ar"
"AS=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.8.5/build/./gcc/as"
"LD=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.8.5/build/./gcc/collect-ld"
"RANLIB=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/bin/ranlib"
"NM=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.8.5/build/./gcc/nm"
"NM_FOR_BUILD="
"NM_FOR_TARGET=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/bin/nm"
"DESTDIR=" "WERROR=" all-recursive

gcc-4.9:
make[3]: Entering directory
'/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.9.3/build/xtensa-buildroot-linux-uclibc/libstdc++-v3'
/usr/bin/make "AR_FLAGS=rc" "CC_FOR_BUILD=/usr/bin/gcc"
"CC_FOR_TARGET=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.9.3/build/./gcc/xgcc
-B/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.9.3/build/./gcc/"
"CFLAGS=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"CXXFLAGS=-O2 -I/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/include
-D_GNU_SOURCE" "CFLAGS_FOR_BUILD=-O2
-I/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/include"
"CFLAGS_FOR_TARGET=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"INSTALL=/usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c -m
644" "INSTALL_PROGRAM=/usr/bin/install -c"
"INSTALL_SCRIPT=/usr/bin/install -c" "LDFLAGS="
"LIBCFLAGS=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"LIBCFLAGS_FOR_TARGET=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"MAKE=/usr/bin/make"
"MAKEINFO=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.9.3/missing
makeinfo --split-size=5000000 --split-size=5000000 " "SHELL=/bin/bash"
"RUNTESTFLAGS="
"exec_prefix=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr"
"infodir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/share/info"
"libdir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/lib"
"includedir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/include"
"prefix=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr"
"tooldir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc"
"gxx_include_dir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/include/c++/4.9.3"
"AR=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/bin/ar"
"AS=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.9.3/build/./gcc/as"
"LD=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.9.3/build/./gcc/collect-ld"
"RANLIB=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/bin/ranlib"
"NM=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-4.9.3/build/./gcc/nm"
"NM_FOR_BUILD="
"NM_FOR_TARGET=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/bin/nm"
"DESTDIR=" "WERROR=" all-recursive

gcc-5:
make[3]: Entering directory
'/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-5.3.0/build/xtensa-buildroot-linux-uclibc/libstdc++-v3'
/usr/bin/make "AR_FLAGS=rc" "CC_FOR_BUILD=/usr/bin/gcc"
"CC_FOR_TARGET=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-5.3.0/build/./gcc/xgcc
-B/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-5.3.0/build/./gcc/"
"CFLAGS=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"CXXFLAGS=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2
-D_GNU_SOURCE" "CFLAGS_FOR_BUILD=-O2
-I/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/include"
"CFLAGS_FOR_TARGET=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"INSTALL=/usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c -m
644" "INSTALL_PROGRAM=/usr/bin/install -c"
"INSTALL_SCRIPT=/usr/bin/install -c" "LDFLAGS="
"LIBCFLAGS=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"LIBCFLAGS_FOR_TARGET=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -g2"
"MAKE=/usr/bin/make"
"MAKEINFO=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-5.3.0/missing
makeinfo --split-size=5000000 --split-size=5000000 " "SHELL=/bin/bash"
"RUNTESTFLAGS="
"exec_prefix=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr"
"infodir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/share/info"
"libdir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/lib"
"includedir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/include"
"prefix=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr"
"tooldir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc"
"gxx_include_dir=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/include/c++/5.3.0"
"AR=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/bin/ar"
"AS=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-5.3.0/build/./gcc/as"
"LD=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-5.3.0/build/./gcc/collect-ld"
"RANLIB=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/bin/ranlib"
"NM=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/build/host-gcc-final-5.3.0/build/./gcc/nm"
"NM_FOR_BUILD="
"NM_FOR_TARGET=/home/jcmvbkbc/tmp/br/build-gdb-binutils-update-dc233c/host/usr/xtensa-buildroot-linux-uclibc/bin/nm"
"DESTDIR=" "WERROR=" all-recursive

With --enable-cxx-flags="$(TARGET_CFLAGS)" in the
HOST_GCC_FINAL_CONF_OPTS make invocation lines are the same,
but makefiles in libstdc++ differ by the EXTRA_CXX_FLAGS.

OTOH since flags propagation is fixed in gcc-5.x maybe backporting
that fix is the right thing?
Arnout Vandecappelle March 10, 2016, 9:46 a.m. UTC | #4
On 03/10/16 10:37, Max Filippov wrote:
> Arnout, Yann,
>
> On Wed, Mar 9, 2016 at 2:22 AM, Arnout Vandecappelle <arnout@mind.be> wrote:
>> On 01/09/16 23:08, Yann E. MORIN wrote:
>>> On 2015-06-01 17:37 +0300, Max Filippov spake thusly:
>>>>
>>>> Currently only TARGET_ABI flags are passed to the final compiler
>>>> configure script and only when building for Xtensa. Since libstdc++ is a
>>>> normal library it should be built with full TARGET_CFLAGS on all
>>>> targets.
>>>>
>>>> Pass TARGET_CFLAGS flags to gcc-final configure script for all targets
>>>> in the --enable-cxx-flags parameter.
>>>>
>>>> Suggested-by: Arnout Vandecappelle <arnout@mind.be>
>>>> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
>>>
>>>
>>> So, I finally had a look at this patch. I've tested it to build a
>>> gcc-4.9 + glibc-2.21 + binutils-2.24 toolchain with C++ support, which
>>> then was used to suessfully build Qt5base (which is quite a heavy C++
>>> user).
>>>
>>> However, I'd like to understand what this is all about.
>>>
>>> In gcc.mk, we do:
>>>
>>>       GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS)
>>>       [...]
>>>       HOST_GCC_COMMON_CONF_ENV +=
>>> CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"
>>>
>>> So it looks like we were already passing the proper CXXFLAGS to gcc (we
>>> only filter-out problematic flags, like -Os on broken gcc-4.5 for PPC).
>>>
>>> So, what are we supposed to gain/loose with this change?
>>>
>>> As a side note, we should not have to pass TARGET_ABI either, since it
>>> is part of TARGET_CFLAGS and as shown above, it is already part of the
>>> CFLAGS_FOR_TARGET that we pass gcc.
>>>
>>> Any explanations? Something that I missed?
>>
>>
>>   I checked in the gcc source and also couldn't find a reason why the
>> CXXFLAGS_FOR_TARGET wouldn't work. Since you haven't replied to this, I've
>> marked your patch as rejected in patchwork. If you do still fel it is
>> warranted, please repost with a satisfactory explanation.
>
> Sorry, took me too long to answer the first mail.
>
> AFAICS neither gcc-4.8.x nor gcc-4.9.x propagate CXXFLAGS_FOR_TARGET
> to CXXFLAGS for builds of libstdc++. gcc-5.x however does.

  Of course, I only checked the source of gcc-5.x :-)

> Compare the following build log excerpts for libstdc++ of gcc-4.8, gcc-4.9 and
> gcc-5 (I've reverted 2dcab526a97d and c44cf2cc97df before running these builds):
>
[snip]
> With --enable-cxx-flags="$(TARGET_CFLAGS)" in the
> HOST_GCC_FINAL_CONF_OPTS make invocation lines are the same,
> but makefiles in libstdc++ differ by the EXTRA_CXX_FLAGS.
>
> OTOH since flags propagation is fixed in gcc-5.x maybe backporting
> that fix is the right thing?

  If the backport is easy, by all means go for it. It's not as if we don't have 
gcc patches already :-)

  If the backport turns out to be difficult, I'm OK with taking your original 
patch (because even on gcc5 it doesn't change anything in practice). But it 
needs a comment mentioning this version dependency, so that the workaround can 
be removed when 4.9 is removed from buildroot.

  Regards,
  Arnout
Max Filippov March 10, 2016, 9:57 a.m. UTC | #5
On Thu, Mar 10, 2016 at 12:46 PM, Arnout Vandecappelle <arnout@mind.be> wrote:
> On 03/10/16 10:37, Max Filippov wrote:
>> AFAICS neither gcc-4.8.x nor gcc-4.9.x propagate CXXFLAGS_FOR_TARGET
>> to CXXFLAGS for builds of libstdc++. gcc-5.x however does.

[...]

>> OTOH since flags propagation is fixed in gcc-5.x maybe backporting
>> that fix is the right thing?
>
>  If the backport is easy, by all means go for it. It's not as if we don't
> have gcc patches already :-)

Ok, let me see if I can figure it out.
diff mbox

Patch

diff --git a/package/gcc/gcc-final/gcc-final.mk b/package/gcc/gcc-final/gcc-final.mk
index 8d7009b..59c8708 100644
--- a/package/gcc/gcc-final/gcc-final.mk
+++ b/package/gcc/gcc-final/gcc-final.mk
@@ -185,8 +185,6 @@  endef
 HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_INSTALL_USR_LIBS
 endif
 
-ifeq ($(BR2_xtensa),y)
-HOST_GCC_FINAL_CONF_OPTS += --enable-cxx-flags="$(TARGET_ABI)"
-endif
+HOST_GCC_FINAL_CONF_OPTS += --enable-cxx-flags="$(TARGET_CFLAGS)"
 
 $(eval $(host-autotools-package))