Skip to content

LLVM error when emitting PTX code with debuginfo #38785

Open
@japaric

Description

@japaric

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.O-NVPTXTarget: the NVPTX LLVM backend for running rust on GPUs, https://llvm.org/docs/NVPTXUsage.htmlT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions