Issue |
126500
|
Summary |
[clang, CUDA, modules] Issues Compiling a CUDA Source File with C++ Modules
|
Labels |
clang
|
Assignees |
|
Reporter |
LukasBreitwieser
|
Hi All,
I ran into issues compiling a simple CUDA source file that includes a header (see `mymodule.h`) if modules are enabled. Further investigation showed that the issue persists even after removing all CUDA related code (see `main.cu`). Compiling it with `c++20` errors out due to an ambiguous call to `operator new`, while the compiler crashes with `c++17`. Here the compilation logs and generated `*.pcm` files: [logs-and-module-cache.tar.gz](https://github.com/user-attachments/files/18732220/logs-and-module-cache.tar.gz)
File `main.cu`
```cpp
#include "mymodule.h"
#include <iostream>
int main() {
std::cout << GetMessage() << std::endl;
// Problem shows up even with all CUDA related code removed.
return 0;
}
```
File `mymodule.h`
```cpp
#ifndef MYMODULE_H
#define MYMODULE_H
#include <string>
// uncommenting the following line somehow "fixes" the issue.
//#include <iostream>
inline std::string GetMessage() {
return "Hello world!";
}
#endif // MYMODULE_H
```
File `module.modulemap`
```
module mymodule {
header "mymodule.h"
export *
}
```
Compiler invocation:
```bash
clang++ \
-v \
-std=c++20 \
-x cuda \
--cuda-gpu-arch=sm_86 \
-lcuda \
-lcudart \
-fmodules \
-fmodule-map-file=module.modulemap \
-fmodules-cache-path=/tmp/clang-modules \
-o main \
main.cu
```
LLVM commit
```
commit 2b55ef187cb6029eed43d7f4c0a3640c32691b31 (HEAD -> main, origin/main, origin/HEAD)
Author: Florian Hahn <f...@fhahn.com>
Date: Wed Jan 29 10:50:01 2025 +0000
[VPlan] Add helper to run VPlan passes, verify after run (NFC). (#123640)
...
```
LLVM configuration
```bash
cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
<path-to-llvm-project-dir>/llvm
```
System Info
- OS: `Ubuntu 20.04.1 LTS`
- Compiler used to compile llvm: `g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0`
- CUDA: `12.6`
- GPU: single NVIDIA Geforce RTX 3060 with compute capability 8.6
I am happy to provide more information if needed.
Thank you in advance for taking a look and any hints on how to best debug and fix it.
Best,
Lukas
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs