coroutine support in clang

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

coroutine support in clang

Deep Majumder via cfe-dev

Hello,

 

Clang throws an error on Windows when I try to compile the following test.

 

ksh-3.2$ cat test.cpp

#include <coroutine>

#include <iostream>

using namespace std;

using std::coroutine_handle;

using std::suspend_always;

 

ksh-3.2$ clang-cl -c /std:c++latest test.cpp

test2.cpp(4,12): error: no member named 'coroutine_handle' in namespace 'std'

using std::coroutine_handle;

      ~~~~~^

test2.cpp(5,12): error: no member named 'suspend_always' in namespace 'std'

using std::suspend_always;

      ~~~~~^

2 errors generated.

 

I noticed the STL implementation (https://github.com/microsoft/STL/blob/master/stl/inc/coroutine#L16) was guarded with __cpp_lib_coroutine.  So I tried clang-cl -c /std:c++latest -D__cpp_lib_coroutine test.cpp and the header successfully compiled.

 

From https://github.com/microsoft/STL/issues/1223, it looks like the errors are a known issue. __cpp_lib_coroutine will be defined by library only if compiler defines __cpp_impl_coroutine. I assume clang doesn’t define the feature test macro because we lack sufficient coroutine support. Would someone here be able to confirm?

 

Also, if anyone has information about current status of coroutine support/what is missing, any help is greatly appreciated.

 

Thank you,

Elizabeth


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: coroutine support in clang

Deep Majumder via cfe-dev
On Wed, Jan 20, 2021 at 12:03 PM Andrews, Elizabeth via cfe-dev <[hidden email]> wrote:

Hello,

 

Clang throws an error on Windows when I try to compile the following test.

 

ksh-3.2$ cat test.cpp

#include <coroutine>

#include <iostream>

using namespace std;

using std::coroutine_handle;

using std::suspend_always;

 

ksh-3.2$ clang-cl -c /std:c++latest test.cpp

test2.cpp(4,12): error: no member named 'coroutine_handle' in namespace 'std'

using std::coroutine_handle;

      ~~~~~^

test2.cpp(5,12): error: no member named 'suspend_always' in namespace 'std'

using std::suspend_always;

      ~~~~~^

2 errors generated.

 

I noticed the STL implementation (https://github.com/microsoft/STL/blob/master/stl/inc/coroutine#L16) was guarded with __cpp_lib_coroutine.  So I tried clang-cl -c /std:c++latest -D__cpp_lib_coroutine test.cpp and the header successfully compiled.

 

From https://github.com/microsoft/STL/issues/1223, it looks like the errors are a known issue. __cpp_lib_coroutine will be defined by library only if compiler defines __cpp_impl_coroutine. I assume clang doesn’t define the feature test macro because we lack sufficient coroutine support. Would someone here be able to confirm?


STL <coroutine> developer here: my understanding is that a secret cabal of compiler developers agreed on a common ABI for C++20 coroutine frames, the so-called "Denver ABI". MSVC implements this ABI under /std:c++latest (as of IIRC Visual Studio 2019 version 16.8) but Clang does not yet do so. The intrinsics used to interface the library to the compiler are the same that Clang has been using since the era of TS coroutines, so the header will compile, but the STL expects the Denver ABI so the behavior of those intrinsics is wrong.

We're hopeful that Clang will start defining the C++20 feature-test macro (__cpp_impl_coroutine) when the Denver ABI is implemented so our <coroutine> header will light up automatically.

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: coroutine support in clang

Deep Majumder via cfe-dev
Thanks for the information Casey!

Would you happen to know where I can find this ABI and if anyone is working on the implementation in Clang?

Elizabeth

From: Casey Carter <[hidden email]>
Sent: Wednesday, January 20, 2021 3:11 PM
To: Andrews, Elizabeth <[hidden email]>
Cc: [hidden email]
Subject: Re: [cfe-dev] coroutine support in clang

On Wed, Jan 20, 2021 at 12:03 PM Andrews, Elizabeth via cfe-dev <mailto:[hidden email]> wrote:
Hello,
 
Clang throws an error on Windows when I try to compile the following test.
 
ksh-3.2$ cat test.cpp
#include <coroutine>
#include <iostream>
using namespace std;
using std::coroutine_handle;
using std::suspend_always;
 
ksh-3.2$ clang-cl -c /std:c++latest test.cpp
test2.cpp(4,12): error: no member named 'coroutine_handle' in namespace 'std'
using std::coroutine_handle;
      ~~~~~^
test2.cpp(5,12): error: no member named 'suspend_always' in namespace 'std'
using std::suspend_always;
      ~~~~~^
2 errors generated.
 
I noticed the STL implementation (https://github.com/microsoft/STL/blob/master/stl/inc/coroutine#L16) was guarded with __cpp_lib_coroutine.  So I tried clang-cl -c /std:c++latest -D__cpp_lib_coroutine test.cpp and the header successfully compiled.
 
From https://github.com/microsoft/STL/issues/1223, it looks like the errors are a known issue. __cpp_lib_coroutine will be defined by library only if compiler defines __cpp_impl_coroutine. I assume clang doesn’t define the feature test macro because we lack sufficient coroutine support. Would someone here be able to confirm?

STL <coroutine> developer here: my understanding is that a secret cabal of compiler developers agreed on a common ABI for C++20 coroutine frames, the so-called "Denver ABI". MSVC implements this ABI under /std:c++latest (as of IIRC Visual Studio 2019 version 16.8) but Clang does not yet do so. The intrinsics used to interface the library to the compiler are the same that Clang has been using since the era of TS coroutines, so the header will compile, but the STL expects the Denver ABI so the behavior of those intrinsics is wrong.

We're hopeful that Clang will start defining the C++20 feature-test macro (__cpp_impl_coroutine) when the Denver ABI is implemented so our <coroutine> header will light up automatically.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: coroutine support in clang

Deep Majumder via cfe-dev
On Wed, Jan 20, 2021 at 12:32 PM Andrews, Elizabeth via cfe-dev <[hidden email]> wrote:
Thanks for the information Casey!

Would you happen to know where I can find this ABI and if anyone is working on the implementation in Clang?

Here is a copy of the original document, which is basically a napkin design. I don't know if anyone is working on implementing it in Clang.

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: coroutine support in clang

Deep Majumder via cfe-dev

Ok. Thank you!

 

From: Casey Carter <[hidden email]>
Sent: Wednesday, January 20, 2021 4:39 PM
To: Andrews, Elizabeth <[hidden email]>
Cc: [hidden email]
Subject: Re: [cfe-dev] coroutine support in clang

 

On Wed, Jan 20, 2021 at 12:32 PM Andrews, Elizabeth via cfe-dev <[hidden email]> wrote:

Thanks for the information Casey!

Would you happen to know where I can find this ABI and if anyone is working on the implementation in Clang?

 

Here is a copy of the original document, which is basically a napkin design. I don't know if anyone is working on implementing it in Clang.


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev