I was installing darling according the the instruction on the wiki. When running the make command, it stops at 92% with the following errors:
[ 92%] Building CXX object src/libstdcxx/CMakeFiles/stdcxx.dir/src/compatibility.o
In file included from /home/michael/darling/src/libstdcxx/src/compatibility.cc:52:
/home/michael/darling/src/libstdcxx/include/c++/4.2.1/sstream:120:3: error: exception specification needed for member of incomplete class 'std::basic_stringbuf<char>'
~basic_stringbuf() {}
^
/home/michael/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:264:25: note: in evaluation of exception specification for 'std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::~basic_stringbuf' needed here
extern template class basic_stringbuf<char>;
^
/home/michael/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:264:25: note: in instantiation of template class 'std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >' requested here
/home/michael/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:264:25: note: definition of 'std::basic_stringbuf<char>' is not complete until the closing '}'
In file included from /home/michael/darling/src/libstdcxx/src/compatibility.cc:52:
/home/michael/darling/src/libstdcxx/include/c++/4.2.1/sstream:120:3: error: exception specification needed for member of incomplete class 'std::basic_stringbuf<wchar_t>'
~basic_stringbuf() {}
^
/home/michael/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:270:25: note: in evaluation of exception specification for 'std::basic_stringbuf<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::~basic_stringbuf' needed here
extern template class basic_stringbuf<wchar_t>;
^
/home/michael/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:270:25: note: in instantiation of template class 'std::basic_stringbuf<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' requested here
/home/michael/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:270:25: note: definition of 'std::basic_stringbuf<wchar_t>' is not complete until the closing '}'
2 errors generated.
make[2]: *** [src/libstdcxx/CMakeFiles/stdcxx.dir/build.make:167: src/libstdcxx/CMakeFiles/stdcxx.dir/src/compatibility.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:45404: src/libstdcxx/CMakeFiles/stdcxx.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Can anyone help me fix this issue?
What distro are you using?
I am using Arch. uname -a returns
Linux archlinux 5.3.5-arch1-1-ARCH #1 SMP PREEMPT Mon Oct 7 19:03:08 UTC 2019 x86_64 GNU/Linux
I'm having the exact same issue on my gentoo, using Clang9:
[ 94%] Building CXX object src/libstdcxx/CMakeFiles/stdcxx.dir/src/compatibility.o
In file included from /data/michel/prof/darling/src/libstdcxx/src/compatibility.cc:52:
/data/michel/prof/darling/src/libstdcxx/include/c++/4.2.1/sstream:120:3: error: exception specification needed for member of incomplete class 'std::basic_stringbuf<char>'
~basic_stringbuf() {}
^
/data/michel/prof/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:264:25: note: in evaluation of exception specification for 'std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::~basic_stringbuf' need
ed here
extern template class basic_stringbuf<char>;
^
/data/michel/prof/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:264:25: note: in instantiation of template class 'std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >' requested here
/data/michel/prof/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:264:25: note: definition of 'std::basic_stringbuf<char>' is not complete until the closing '}'
In file included from /data/michel/prof/darling/src/libstdcxx/src/compatibility.cc:52:
/data/michel/prof/darling/src/libstdcxx/include/c++/4.2.1/sstream:120:3: error: exception specification needed for member of incomplete class 'std::basic_stringbuf<wchar_t>'
~basic_stringbuf() {}
^
/data/michel/prof/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:270:25: note: in evaluation of exception specification for 'std::basic_stringbuf<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::~basic_string
buf' needed here
extern template class basic_stringbuf<wchar_t>;
^
/data/michel/prof/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:270:25: note: in instantiation of template class 'std::basic_stringbuf<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' requested here
/data/michel/prof/darling/src/libstdcxx/include/c++/4.2.1/bits/sstream.tcc:270:25: note: definition of 'std::basic_stringbuf<wchar_t>' is not complete until the closing '}'
2 errors generated.
make[3]: *** [src/libstdcxx/CMakeFiles/stdcxx.dir/build.make:167: src/libstdcxx/CMakeFiles/stdcxx.dir/src/compatibility.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:45404: src/libstdcxx/CMakeFiles/stdcxx.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:45416: src/libstdcxx/CMakeFiles/stdcxx.dir/rule] Error 2
make: *** [Makefile:14204: stdcxx] Error 2
Sadly my c++ skills are not that great for me to fix it by myself.
I've downgraded clang8 and was able to build Darling without the error. So I think it's a problem with clang9.
I'll give that a try as well and report back if it works. Thanks!
Same error on Ubuntu 19.10
Got the same error with clang 9.0 installed on Arch 5.3.
Rollback to clang 8.0 fixed the problem.
Seems that clang 9 forces the destructor to handle exceptions in that context...
This also affects Fedora 31.
It has been a while since I have done C++, but it is strange that this member is consider to be part of an incomplete class.
@abaurens If I understand this correctly, the issue is that there isn't a throw() or noexcept next to those functions/methods, right?
@CuriousTommy
Well, first of all, i think the destructor is considered to be in an incomplete class because it is actually defined inside the class itself. I mean, it's not just the prototype of it (maybe it has something to do with the stream_buffer inheritance as well).
For some reason, this used to compile on older version of clang and does not anymore.
According to what i understand of it, throw or noexcept should fix this error, yes (this destructor is empty anyway).
Gonna try with noexcept later today, but compilation is soooooo long (and this error appears at the verry end of it), so it's pretty long to check it..
adding noexcept at destructor definition worked like a charm, but ther's the same error hidden here.
adding noexcept for it as well made the stdcxx module compilant.
darling/src/libstdcxx/include/c++/4.2.1/sstream : L120
~basic_stringbuf() noexcept {}
darling/src/libstdcxx/include/c++/4.2.1/ext/stdio_sync_filebuf.h : L77
virtual ~stdio_sync_filebuf() noexcept {}
@abaurens I can confirm that your fixes do work, excellent work!
For the non-coding users, I created a patch that you can apply. Create a file called clang9_exception_fix.patch in the darling folder and execute git apply clang9_exception_fix.patch in terminal to apply the patch.
diff --git a/src/libstdcxx/include/c++/4.2.1/ext/stdio_sync_filebuf.h b/src/libstdcxx/include/c++/4.2.1/ext/stdio_sync_filebuf.h
index 5dc9e05d..29cf86b5 100644
--- a/src/libstdcxx/include/c++/4.2.1/ext/stdio_sync_filebuf.h
+++ b/src/libstdcxx/include/c++/4.2.1/ext/stdio_sync_filebuf.h
@@ -74,7 +74,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
#if BUILDING_LIBSTDCXX
__attribute__((used))
- virtual ~stdio_sync_filebuf() {}
+ virtual ~stdio_sync_filebuf() noexcept {}
#endif
/**
diff --git a/src/libstdcxx/include/c++/4.2.1/sstream b/src/libstdcxx/include/c++/4.2.1/sstream
index 3d746c71..037141e7 100644
--- a/src/libstdcxx/include/c++/4.2.1/sstream
+++ b/src/libstdcxx/include/c++/4.2.1/sstream
@@ -117,7 +117,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if BUILDING_LIBSTDCXX
__attribute__((used))
- ~basic_stringbuf() {}
+ ~basic_stringbuf() noexcept {}
#endif
// Get and set:
Well, first of all, I think the destructor is considered to be in an incomplete class because it is actually defined inside the class itself. I mean, it's not just the prototype of it (maybe it has something to do with the
stream_bufferinheritance as well).
I guess I need to read up more on what an incomplete class is to a better understanding of why stream_buffer is considered an incomplete class.
@ahyattdev Would you be able to create a commit to fix this issue?
Has anyone made a pull request/commit fixing this? Still experiencing it on Fedora 31.
Most helpful comment
@abaurens I can confirm that your fixes do work, excellent work!
For the non-coding users, I created a patch that you can apply. Create a file called
clang9_exception_fix.patchin the darling folder and executegit apply clang9_exception_fix.patchin terminal to apply the patch.I guess I need to read up more on what an incomplete class is to a better understanding of why stream_buffer is considered an incomplete class.