[clang] [clang-repl][CUDA] Move CUDA module registration to beginning of global_ctors (PR #66658)
Anubhab Ghosh via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 18 10:20:29 PDT 2023
================
@@ -794,7 +794,7 @@ void CodeGenModule::Release() {
AddGlobalCtor(ObjCInitFunction);
if (Context.getLangOpts().CUDA && CUDARuntime) {
if (llvm::Function *CudaCtorFunction = CUDARuntime->finalizeModule())
- AddGlobalCtor(CudaCtorFunction);
+ AddGlobalCtor(CudaCtorFunction, /*Priority=*/0);
----------------
argentite wrote:
The underlying issues is not actually clang-repl specific, it also affects clang. For example, this seems to succeed in `nvcc` but fails with `clang`:
```cpp
#include <cstdio>
__global__ void kernel() {}
class C {
public:
C() {
kernel<<<1, 1>>>();
printf("Error: %d\n", cudaGetLastError());
}
};
C c;
int main() {}
```
This is fixed by this patch. Maybe we can look for a proper solution to this?
https://github.com/llvm/llvm-project/pull/66658
More information about the cfe-commits
mailing list