Issue 238882
Summary [clang-nvlink-wrapper] --save-temps aliases LTO partition outputs
Labels
Assignees
Reporter 0z5a
    When NVPTX Full LTO uses more than one partition, `clang-nvlink-wrapper --save-temps` writes every partition to the same `.s` and `.cubin` filenames. The later partition overwrites the earlier one, and `nvlink` receives the same cubin more than once.

A minimal input containing two externally visible functions:

```c
int foo(int x) { return x + 1; }
int bar(int x) { return x * 3; }
```

Build and link it with:

```sh
clang -cc1 -triple nvptx64-nvidia-cuda -emit-llvm-bc input.c -o input.bc
clang-nvlink-wrapper --save-temps --cuda-path=/usr/local/cuda \
 --plugin-opt=lto-partitions=2 -arch sm_90 input.bc -o output
```

The generated commands pass `output.s` to both `ptxas` invocations and then pass `output.cubin` twice to `nvlink`. With CUDA 13.2, the real link fails with multiple definition errors. Without `--save-temps`, the temporary filenames are distinct and the link succeeds.

The same output-slot handling also passes an empty input to `ptxas` for an unused task slot in Unified ThinLTO. The wrapper should assign distinct files to active tasks and skip slots with no output.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to