nvcc with MSVC as host compiler (Windows) can't compile stdexec: compiler detection takes the nvcc branch and skips the MSVC settings
Les mainteneurs répondent en général sous 2 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 18/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Domaine
- build-system, devtools
Piste de recherche
The detection logic is in include/stdexec/__detail/__config.hpp, where the NVCC branch runs before the MSVC checks, so STDEXEC_MSVC() and STDEXEC_MSVC_HEADERS() are never set under nvcc with an MSVC host. Related spots are __spin_loop_pause.hpp, __meta.hpp (__mk_indices) and __connect.hpp (__connect_declfn_v). Done would mean the minimal nvcc_msvc.cu example compiles with nvcc on Windows, or the header fails early with a clear #error; the maintainers have not yet decided which, so confirm the direction first.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
With nvcc on Windows (MSVC as host compiler), even a minimal program fails to compile at current main (1d58877ad898fa3422658d47b28f67deb9c10e80). We ran into this while building HPX with CUDA on Windows.
Versions: CUDA 13.0 (nvcc V13.0.88), MSVC 19.44.35229 (VS 2022 17.14, x64), Windows 11. CUDA 13.0 doesn't accept MSVC 19.52 (VS 18) as host compiler.
// nvcc_msvc.cu
#include <stdexec/execution.hpp>
int main()
{
auto s = stdexec::just(41) | stdexec::then([](int i) { return i + 1; });
auto [v] = stdexec::sync_wait(std::move(s)).value();
return v == 42 ? 0 : 1;
}
nvcc -std=c++20 -Xcompiler=-Zc:__cplusplus -Xcompiler=-Zc:preprocessor -Xcompiler=/EHsc --extended-lambda --expt-relaxed-constexpr -arch=sm_89 -I stdexec/include nvcc_msvc.cu
(-Zc:__cplusplus and -Zc:preprocessor are needed to get past the C++20 check and the preprocessor check in __config.hpp.)
Output (paths shortened, repeated lines removed):
include/stdexec/__detail/__meta.hpp(168): error: declaration is incompatible with variable template "stdexec::__pack::__mk_indices" (declared at line 163)
include/stdexec/__detail/__connect.hpp(83): error: declaration is incompatible with variable template "stdexec::__connect::__connect_declfn_v" (declared at line 77)
include/stdexec/__detail/__connect.hpp(90): error: declaration is incompatible with variable template "stdexec::__connect::__connect_declfn_v" (declared at line 77)
include/stdexec/__detail/__connect.hpp(103): error: declaration is incompatible with variable template "stdexec::__connect::__connect_declfn_v" (declared at line 97)
include/stdexec/__detail/__connect.hpp(110): error: declaration is incompatible with variable template "stdexec::__connect::__connect_declfn_v" (declared at line 97)
include/stdexec/__detail/__spin_loop_pause.hpp(48): error: identifier "__builtin_ia32_pause" is undefined
include/stdexec/__detail/__transform_completion_signatures.hpp(360): error: type name is not allowed
include/stdexec/__detail/__transform_completion_signatures.hpp(360): error: too many initializer values
include/stdexec/__detail/__transform_completion_signatures.hpp(400): error: type name is not allowed
include/stdexec/__detail/__transform_completion_signatures.hpp(400): error: too many initializer values
include/stdexec/__detail/__sync_wait.hpp(353): error: no instance of function template "stdexec::connect_t::operator()" matches the argument list
include/stdexec/__detail/__sync_wait.hpp(355): error: static assertion failed with "..."
nvcc_msvc.cu(6): error: expression must have class type but it has type "void"
15 errors detected in the compilation of "nvcc_msvc.cu".
The cause seems to be the compiler detection in __config.hpp: the __NVCC__ branch comes first, so with an MSVC host neither STDEXEC_MSVC() nor STDEXEC_MSVC_HEADERS() is ever set, although _MSC_VER is defined and the MSVC standard library is used. As a result:
__spin_loop_pause()takes the GCC branch (__builtin_ia32_pause()) instead of_mm_pause()from<intrin.h>.__make_indicesfalls back to theexternvariable template partial specializations (__mk_indices), and__connect.hppuses the__connect_declfn_vspecializations instead of the function-based version it already has for MSVC. nvcc's front end in MSVC mode rejects both ("declaration is incompatible with variable template").- After the front end,
clcompiles nvcc's preprocessed output (.cudafe1.cpp). The macros were already expanded with__NVCC__defined, so the MSVC workarounds keyed onSTDEXEC_MSVC()are missing there too.
What we tried in a local copy of 04de75de58 (the revision HPX uses today, which fails with the same __mk_indices and __builtin_ia32_pause errors): setting STDEXEC_MSVC_HEADERS() to 1 in the nvcc branch when _MSC_VER is defined fixes the __builtin_ia32_pause error, and using std::make_index_sequence for __make_indices fixes the __mk_indices error. With HPX's CUDA test files, and with the MSVC __msplice_helper variant enabled for nvcc as well, the front end then gets through, but cl fails on the .cudafe1.cpp file: first an internal compiler error (C1001) at __typeinfo.hpp(289), then errors such as C7571 (enable_sender: variable template has already been initialized) at __execution_fwd.hpp(287) and C7608 (atomic constraint should be a constant expression) at __sender_concepts.hpp(131) and __sender_introspection.hpp(259). So it takes more than a few local fixes, and the MSVC code paths would have to apply to both nvcc's front end and the host compilation.
Is nvcc with an MSVC host meant to be supported? If yes, would a separate STDEXEC_NVCC_MSVC_HOST() (or setting STDEXEC_MSVC_HEADERS() and the MSVC workarounds whenever _MSC_VER is defined) be the direction you'd want? If not, it would help to say so in the README and to fail early with an #error, so users don't get errors from deep inside the library.
- Langage dominant
- C++
- Étoiles
- 2.5k
- Forks
- 285
- Merge moyen
- 2 j 5 h
- PR mergées (30 j)
- 82
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NVIDIA/stdexec
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
NVIDIA/stdexec#1751 · 3 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 4/5 Plus d'une semaine Accessibilité débutants 18/100
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 3/5 1-3 heures Accessibilité débutants 25/100
NVIDIA/stdexec#2400 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
sequence: missing transition (?)Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 12/100
NVIDIA/stdexec#2344 · 4 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 15/100
NVIDIA/stdexec#2342 · 2 commentaires · 3 réactions ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de NVIDIA/stdexec
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
eclipse-score/lifecycle#929 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
colbymchenry/codegraph#3223 ·
Les mainteneurs répondent en général sous 1 jour