Repository navigation
Commit f626041
authored
Fix CUDA backend Windows build under C++20 (pytorch#23135)
### Summary
All \`test-model-cuda-windows-e2e\` jobs on main fail to build:
\`\`\`
backends\cuda\runtime\platform\platform.cpp(63,20): error C2440:
'initializing': cannot convert from 'std::basic_string<char8_t,...>' to
'std::basic_string<char,...>'
\`\`\`
pytorch#22793 made \`executorch_core\` export \`cxx_std_20\`, so
\`cuda_platform\` now compiles as C++20, where
\`std::filesystem::path::u8string()\` returns \`std::u8string\`, which
no longer converts to \`std::string\`.
Fix: load the library with \`LoadLibraryW(path.c_str())\` (which is also
correct for non-ASCII paths), and build a UTF-8 \`std::string\` only for
the error log. The conversion compiles under both C++17 and C++20.
**Second fix:** once platform.cpp built, `aoti_cuda_shims` failed next:
```
c10/util/safe_numerics.h(71): error : namespace "std" has no member "countl_zero"
```
The `.cu` shims are compiled by nvcc, and `backends/cuda/CMakeLists.txt`
pinned `CMAKE_CUDA_STANDARD 17`. `cxx_std_20` on `executorch_core` only
raises the CXX language, so it never reaches nvcc. The CUDA backend now
uses C++20 for both CXX and CUDA on Windows (matching the top-level
rule) and stays on C++17 elsewhere.
### Test plan
CI: \`Test CUDA Windows Export and E2E\` (triggered by the
\`backends/cuda/**\` path filter).1 parent 82c3bc0 commit f626041
2 files changed
Lines changed: 14 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
20 | 29 | | |
21 | | - | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
| 63 | + | |
65 | 64 | | |
66 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
0 commit comments