Skip to content

Error compiling example: couldn't load codegen backend symbol #163

Closed
@igor-semyonov

Description

@igor-semyonov

Hi,

I am trying to compile the cpu add example using cargo build.

First I had to uncomment this line:

// "x86_64-unknown-linux-gnu" => "linux-x86_64",

This fixed the error of no prebuilt supported LLVM target.

rustc_codegen_nvvm now builds successfully.

Then I did cargo build again on the cpu add example.
I got the following error:

    error: couldn't load codegen backend /home/kdcadet/code/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so: undefined symbol: _ZN4llvm6Triple9normalizeB5cxx11ENS_9StringRefE

Then I checked that so file for that symbol:

~ via 🐍 v3.12.9
❯ readelf -Ws /home/kdcadet/code/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so|grep _ZN4llvm6Triple9normalizeB5cxx11ENS_9StringRefE
   716: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN4llvm6Triple9normalizeB5cxx11ENS_9StringRefE
 71968: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN4llvm6Triple9normalizeB5cxx11ENS_9StringRefE

~ via 🐍 v3.12.9
❯ nm -gD /home/kdcadet/code/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so|grep _ZN4llvm6Triple9normalizeB5cxx11ENS_9StringRefE
                 U _ZN4llvm6Triple9normalizeB5cxx11ENS_9StringRefE

I am not that familiar with elf or so files, but it seems like the symbol is, in fact, present.

My OS: Gentoo Linux

cuda/cpu/add on  main [$!] is 📦 v0.1.0 via 🦀 v1.87.0-nightly took 6s
➜ rustc -Vv
rustc 1.87.0-nightly (8c392966a 2025-03-01)
binary: rustc
commit-hash: 8c392966a013fd8a09e6b78b3c8d6e442bc278e1
commit-date: 2025-03-01
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

cuda/cpu/add on  main [$!] is 📦 v0.1.0 via 🦀 v1.87.0-nightly took 3s
❯ git log --oneline -1
1083480 (HEAD -> main, origin/main, origin/HEAD) Fix optix examples (#160)

I am on the latest commit, as of writing, on the main branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions