libc++ MinGW build failure

Hi,

I wanted to take another look at libc++ on Windows, but I get a build failure due to (I think) libc++ itself:

  • clang++ -c -g -Os -fPIC -std=c++0x -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2 -Wstrict-overflow=4 -nostdinc++ -I…/include …/src/condition_variable.cpp
    In file included from …/src/condition_variable.cpp:10:
    …/include\condition_variable:158:25: error: constructor for ‘std::__1::condition_variable_any’ must explicitly initialize the member ‘_cv’ which does not have a default constructor
    condition_variable_any::condition_variable_any()
    ^
    …/include\condition_variable:121:24: note: member is declared here
    condition_variable _cv;
    ^
    …/include__mutex_base:301:23: note: ‘std::__1::condition_variable’ declared here
    class _LIBCPP_VISIBLE condition_variable
    ^
    In file included from …/src/condition_variable.cpp:11:
    …/include\thread:433:11: error: no matching constructor for initialization of ‘std::__1::mutex’
    mutex __mut;
    ^
    …/include__mutex_base:48:5: note: candidate constructor not viable: requires 1 argument, but 0 were provided
    mutex(const mutex&);// = delete;
    ^
    In file included from …/src/condition_variable.cpp:11:
    …/include\thread:434:24: error: no matching constructor for initialization of ‘std::__1::condition_variable’
    condition_variable __cv;
    ^
    …/include__mutex_base:314:5: note: candidate constructor not viable: requires 1 argument, but 0 were provided
    condition_variable(const condition_variable&); // = delete;
    ^
    In file included from …/src/condition_variable.cpp:10:
    In file included from …/include\condition_variable:112:
    …/include\memory:2087:40: error: constructor for
    ‘std::__1::__libcpp_compressed_pair_imp<std::__1::allocatorstd::__1::mutex, std::__1::mutex, 1>’ must explicitly initialize the member ‘_second’ which does not have a default constructor
    _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
    ^
    …/include\memory:2369:11: note: in instantiation of member function
    ‘std::__1::__libcpp_compressed_pair_imp<std::__1::allocatorstd::__1::mutex, std::__1::mutex, 1>::__libcpp_compressed_pair_imp’ requested here
    : base(_VSTD::forward<_T1_param>(__t1)) {}
    ^
    …/include\memory:3693:12: note: in instantiation of member function
    ‘std::__1::__compressed_pair<std::__1::allocatorstd::__1::mutex, std::__1::mutex>::__compressed_pair’ requested here
    : _data(_VSTD::move(__a)) {}
    ^
    …/include\memory:4272:26: note: in instantiation of member function
    ‘std::__1::__shared_ptr_emplace<std::__1::mutex, std::__1::allocatorstd::__1::mutex>::__shared_ptr_emplace’ requested here
    ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)…);
    ^
    …/include\memory:4631:12: note: in instantiation of function template specialization
    ‘std::__1::shared_ptrstd::__1::mutex::make_shared<>’ requested here
    return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)…);
    ^
    …/include\condition_variable:159:14: note: in instantiation of function template specialization ‘std::__1::make_shared<std::__1::mutex, >’ requested here
    : _mut(make_shared()) {}
    ^
    …/include\memory:2075:9: note: member is declared here
    _T2 _second;
    ^
    …/include__mutex_base:34:23: note: ‘std::__1::mutex’ declared here
    class _LIBCPP_VISIBLE mutex
    ^
    4 errors generated.

This is with Clang 3.1. Any ideas?

Thanks,

Ruben

PS: please keep me in CC, I am not subscribed to cfe-dev

Hi,

I wanted to take another look at libc++ on Windows,

Thanks!

but I get a build failure due to (I think) libc++ itself:

+ clang++ -c -g -Os -fPIC -std=c++0x -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2 -Wstrict-overflow=4 -nostdinc++ -I../include ../src/condition_variable.cpp
In file included from ../src/condition_variable.cpp:10:
../include\condition_variable:158:25: error: constructor for 'std::__1::condition_variable_any' must explicitly initialize the member '__cv_' which does not have a default constructor
condition_variable_any::condition_variable_any()
                        ^

Just looking at this first one: condition_variable is required to have a default constructor. condition_variable (in <__mutex_base>) is currently only implemented on top of pthread_cond_t, and does have a default constructor if pthread_cond_t exists. Does pthread_cond_t exist in your environment?

Howard

> Hi,
>
> I wanted to take another look at libc++ on Windows,

Thanks!

> but I get a build failure due to (I think) libc++ itself:
>
> + clang++ -c -g -Os -fPIC -std=c++0x -fstrict-aliasing -Wall -Wextra
-Wshadow -Wconversion -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2
-Wstrict-overflow=4 -nostdinc++ -I../include ../src/condition_variable.cpp
> In file included from ../src/condition_variable.cpp:10:
> ../include\condition_variable:158:25: error: constructor for
'std::__1::condition_variable_any' must explicitly initialize the member
'__cv_' which does not have a default constructor
> condition_variable_any::condition_variable_any()
> ^

Just looking at this first one: condition_variable is required to have a
default constructor. condition_variable (in <__mutex_base>) is currently
only implemented on top of pthread_cond_t, and does have a default
constructor if pthread_cond_t exists. Does pthread_cond_t exist in your
environment?

Yes, I rely on winpthreads to provide the stuff used by libc++ (I really
should take the time to learn all this and write a proper Win32
implementation, but I'm currently too lazy to do so ;-)). pthread_cond_t is
defined in pthread.h. I checked the preprocessed source (attached) and it
is indeed typedef'ed. This worked last time I updated the test results :confused:

Ruben

condition_variable.zip (65.1 KB)

So can you default construct a condition_variable? I note in your preprocess:

    constexpr condition_variable() : __cv_((pthread_cond_t *)((void *) (size_t) -1)) {}

which looks like a valid condition_variable default constructor to me, as long as it compiles...

Howard

Someone has informed me an SVN Clang build does work, so it must be a Clang
3.1 issue. I'll build a new Clang and continue with that then.

Thanks,

Ruben