svn commit: r241823 - in head: . etc etc/atf etc/mtree lib lib/atf lib/atf/libatf-c lib/atf/libatf-c++ libexec libexec/atf libexec/atf/atf-check share share/atf share/doc share/doc/atf share/exampl...

Dimitry Andric dim at FreeBSD.org
Mon Oct 22 11:29:56 UTC 2012


On 2012-10-22 09:24, Garrett Cooper wrote:
> On Mon, Oct 22, 2012 at 12:00 AM, Jan Beich <jbeich at tormail.org> wrote:
...
>> atf-run fails to link when using -stdlib=libc++. It works if I remove
>> `throw' from check_stream(). Any clue?
>>
>> test-program.o: In function `(anonymous namespace)::check_stream(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)':
>> /usr/src/usr.bin/atf/atf-run/../../../contrib/atf/atf-run/test-program.cpp:76: undefined reference to `std::__1::basic_ios<char, std::__1::char_traits<char> >::clear(unsigned int)'
>> clang++: error: linker command failed with exit code 1 (use -v to see invocation)
>
> Is it a bug in libc++ where it's doing the wrong thing inlining some
> values for basic_ios (my guess is based on the snippet example at:
> http://www.cplusplus.com/reference/iostream/ios/clear/ ):
>
> $ p4 diff -du ios
> --- //depot/user/gcooper/atf-head/src/contrib/libc++/include/ios
>   2012-05-20 04:37:04.000000000 0000
> +++ /scratch/p4/user/gcooper/atf-head/src/contrib/libc++/include/ios
>   2012-05-20 04:37:04.000000000 0000
> @@ -575,10 +575,10 @@
>       _LIBCPP_ALWAYS_INLINE
>           _LIBCPP_EXPLICIT
>           operator bool() const {return !fail();}
> -    _LIBCPP_ALWAYS_INLINE bool operator!() const    {return  fail();}
> -    _LIBCPP_ALWAYS_INLINE iostate rdstate() const   {return ios_base::rdstate();}
> -    _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}
> -    _LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);}
> +    _LIBCPP_INLINE_VISIBILITY bool operator!() const    {return  fail();}
> +    _LIBCPP_INLINE_VISIBILITY iostate rdstate() const   {return ios_base::rdstate();}
> +    void clear(iostate __state = goodbit) {ios_base::clear(__state);}
> +    _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state) {ios_base::setstate(__state);}
>       _LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();}
>       _LIBCPP_ALWAYS_INLINE bool eof() const  {return ios_base::eof();}
>       _LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();}
>
> I'm building clang and libc++ in my VM to confirm.

I don't think so, as these member functions are supposed to be always
inlined.  E.g. basic_ios::clear() should always be expanded inline to
ios_base::clear(), which is a normal (out of line) function.

However, the visibility stuff is always terribly confusing, so you might
have a found a real issue.  Note that in libc++ trunk, the attributes of
these member functions have not changed.

In any case, I cannot reproduce the link error on my system.

-Dimitry


More information about the svn-src-all mailing list