LLVM error when emitting PTX code with debuginfo

f8cbdbf
Opened by Jorge Aparicio at 2023-04-05 17:38:46

STR

$ cargo new --lib kernel && cd $_

$ edit src/lib.rs && cat $_
#![feature(lang_items)]
#![feature(no_core)]
#![no_core]  // Just to avoid using Xargo

fn foo() {}

#[lang = "copy"]
trait Copy {}

#[lang = "sized"]
trait Sized {}
$ edit nvptx64-nvidia-cuda.json && cat $_
{
  "arch": "nvptx64",
  "cpu": "sm_20",
  "data-layout": "e-i64:64-v16:16-v32:32-n16:32:64",
  "llvm-target": "nvptx64-nvidia-cuda",
  "max-atomic-width": 0,
  "os": "cuda",
  "panic-strategy": "abort",
  "target-endian": "little",
  "target-pointer-width": "64"
}
$ cargo rustc --target nvptx64-nvidia-cuda -- --emit=asm
   Compiling kernel v0.1.0 (file:///home/japaric/tmp/kernel)
warning: function is never used: `foo`, #[warn(dead_code)] on by default
 --> src/lib.rs:5:1
  |
5 | fn foo() {}
  | ^^^^^^^^^^^

All DICompileUnits must be listed in llvm.dbg.cu
LLVM ERROR: Broken module found, compilation aborted!
error: Could not compile `kernel`.

Workaround

Don't try to emit debuginfo:

# Cargo.toml
[profile.dev]
debug = false
  1. Is this still an issue? I got some helpful error messages telling me to add target-c-int-width and linker-flavor, and after adding "target-c-int-width": "32" and "linker-flavor": "ld" it seems to compile fine.

    Evan Stoll at 2019-01-18 14:17:55