On 19/12/19 09:36 +0000, Jonathan Wakely wrote:
On 05/12/19 17:12 +0100, Christophe Lyon wrote:
On Thu, 5 Dec 2019 at 12:43, Jonathan Wakely <jwak...@redhat.com> wrote:

On 05/12/19 09:00 +0100, Christophe Lyon wrote:
On Tue, 3 Dec 2019 at 10:16, Jonathan Wakely <jwak...@redhat.com> wrote:

On 03/12/19 09:11 +0100, Christophe Lyon wrote:
>On Mon, 16 Sep 2019 at 04:34, Tom Honermann <t...@honermann.net> wrote:
>>
>> A revised patch is attached that modifies the tests for deleted ostream
>> inserters to require C++2a.  This is required by the revision of patch
>> 2/4 that adds proper preprocessor conditionals to the definitions.
>>
>> Tom.
>>
>> On 9/15/19 3:40 PM, Tom Honermann wrote:
>> > This patch adds new tests to validate new deleted overloads of wchar_t,
>> > char8_t, char16_t, and char32_t for ordinary and wide formatted
>> > character and string ostream inserters.
>> >
>> > Additionally, new tests are added to validate invocations of u8path with
>> > sequences of char8_t for both the C++17 and filesystem TS implementations.
>> >
>> > libstdc++-v3/ChangeLog:
>> >
>> > 2019-09-15  Tom Honermann  <t...@honermann.net>
>> >
>> >       *
>> > 
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/deleted.cc:
>> >
>> >         New test to validate deleted overloads of character and string
>> >         inserters for narrow ostreams.
>> >       *
>> > 
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/wchar_t/deleted.cc:
>> >
>> >         New test to validate deleted overloads of character and string
>> >         inserters for wide ostreams.
>> >       *
>> > libstdc++-v3/testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc:
>> >         New test to validate u8path invocations with sequences of
>> >         char8_t.
>> >       *
>> > 
libstdc++-v3/testsuite/experimental/filesystem/path/factory/u8path-char8_t.cc
>> >
>> >         New test to validate u8path invocations with sequences of
>> >         char8_t.
>> >
>
>Hi,
>
>I've noticed that the new test
>27_io/filesystem/path/factory/u8path-char8_t.cc
>fails to compile on arm-none-eabi with default cpu/fpu, because:
>/tools/arm-none-eabi/bin/ld:
>/obj-arm-none-eabi/gcc3/arm-none-eabi/libstdc++-v3/src/.libs/libstdc++.a(string-inst.o):
>in function `_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_':
>string-inst.cc:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_]+0xf4):
>undefined reference to `_ZSt15__alloc_on_moveISaIcEEvRT_S2_'
>[etc...]

That function is defined inline and so should be instantiated in any
TU that needs it, and so should not give linker errors. There was a
similar bug reported the other day that turned out to be pilot error:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92733

Hi,
Sorry for the delay, it took me a while to reproduce the problem manually.
I think I see this because I build that particular configuration with
CXXFLAGS_FOR_TARGET=-fno-threadsafe-statics

Does that sound plausible?

Not really ... I still don't know why that function template would
ever be undefined.


Hmmm that's because doing CXXFLAGS_FOR_TARGET means that the generated
Makefile contains:
CXXFLAGS = -fno-threadsafe-statics
while if I don't define CXXFLAGS_FOR_TARGET, it contains
CXXFLAGS = -g -O2 -D_GNU_SOURCE

Re-compiling string-inst with -O2 removes the undefined reference

Sigh... looks like I fixed something similar 7 years ago :-(
https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=189046

So... the current configure.ac code makes sure -O2 and -g are present
in CXXFLAGS_FOR_TARGET only if it's derived from CXXFLAGS, which
happens only when CXXFLAGS_FOR_TARGET is NOT overridden, and not
cross-compiling...

We have:
  case " $CXXFLAGS " in
    *" -O2 "*) ;;
    *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;;
  esac

Why isn't it case "$CXXFLAGS_FOR_TARGET" instead? And that whole
case/esac should be after the 'fi'.
Or is it that way on purpose?

So it seems the fix for the problem I saw is for me to use
CXXFLAGS_FOR_TARGET="-O2 -g  -fno-threadsafe-statics"

This is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92927 and thanks
to the bisected revision number in the PR I see what the problem is.

To be clear, PR 92927 is about the undefined references when building
with -O0, and will be fixed soon by the attached patch that I've just
committed to trunk.

I don't know the answer to the question about CXXFLAGS_FOR_TARGET, and
don't know if it's that way on purpose. Please feel free to create a
bug for it, or propose a patch.


commit 5adbd32971c31ec3f0d05f883aba6015f98fbc33
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Fri Dec 20 11:03:40 2019 +0000

    libstdc++: Add inline to maybe-constexpr functions (PR 92927)
    
    Originally these functions were always inline. I changed them in r277342
    to be always constexpr, then in r277588 changed them to be constexpr for
    C++14, but I didn't restore the 'inline' for C++11. That leads to linker
    errors when libstdc++.so is built unoptimized, because those functions
    don't get instantiated in src/c++11/string-inst.o
    
            PR libstdc++/92927
            * include/bits/alloc_traits.h (__alloc_on_copy, __alloc_on_move)
            (__alloc_on_swap): Add inline specifier.

diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h
index 142b23fe00f..812cff0fabe 100644
--- a/libstdc++-v3/include/bits/alloc_traits.h
+++ b/libstdc++-v3/include/bits/alloc_traits.h
@@ -567,7 +567,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
   template<typename _Alloc>
-    _GLIBCXX14_CONSTEXPR void
+    _GLIBCXX14_CONSTEXPR inline void
     __alloc_on_copy(_Alloc& __one, const _Alloc& __two)
     {
       typedef allocator_traits<_Alloc> __traits;
@@ -599,7 +599,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
   template<typename _Alloc>
-    _GLIBCXX14_CONSTEXPR void
+    _GLIBCXX14_CONSTEXPR inline void
     __alloc_on_move(_Alloc& __one, _Alloc& __two)
     {
       typedef allocator_traits<_Alloc> __traits;
@@ -626,7 +626,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
   template<typename _Alloc>
-    _GLIBCXX14_CONSTEXPR void
+    _GLIBCXX14_CONSTEXPR inline void
     __alloc_on_swap(_Alloc& __one, _Alloc& __two)
     {
       typedef allocator_traits<_Alloc> __traits;

Reply via email to