Skip to content

vecadd example: couldn't load codegen backend, undefined symbol: _ZN4llvm23EnableABIBreakingChecksE #211

Closed
@hduoc2003

Description

@hduoc2003

✅ Solution: set LLVM_LINK_SHARED=1 when building like #7

I attempted to run the vecadd example but encountered the following errors:

➜  vecadd git:(main) ✗ LLVM_LINK_STATIC=1 cargo build
   Compiling vecadd v0.1.0 (/root/hduoc2003/code/Rust-CUDA/examples/cuda/vecadd)
error: failed to run custom build command for `vecadd v0.1.0 (/root/hduoc2003/code/Rust-CUDA/examples/cuda/vecadd)`

Caused by:
  process didn't exit successfully: `/root/hduoc2003/code/Rust-CUDA/target/debug/build/vecadd-dbe33157c5bca8c3/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:rerun-if-changed=kernels
  cargo:rerun-if-changed=kernels

  --- stderr
  error: failed to run `rustc` to learn about target-specific information

  Caused by:
    process didn't exit successfully: `/root/.rustup/toolchains/nightly-2025-03-02-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names -Zcodegen-backend=/root/hduoc2003/code/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so '-Zcrate-attr=feature(register_tool)' '-Zcrate-attr=register_tool(nvvm_internal)' -Zcrate-attr=no_std -Zsaturating_float_casts=false '-Cllvm-args=-arch=compute_61 --override-libm' --target nvptx64-nvidia-cuda --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg -Wwarnings` (exit status: 1)
    --- stderr
    error: couldn't load codegen backend /root/hduoc2003/code/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so: undefined symbol: _ZN4llvm23EnableABIBreakingChecksE


  thread 'main' panicked at crates/cuda_builder/src/lib.rs:508:10:
  Did not find output file in rustc output
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Context

I'm using Ubuntu 22.04 and installed all required packages as in ubuntu22-cuda12 dockerfile.


Environment

$ llvm-config --version
7.0.1

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Tue_Feb_27_16:19:38_PST_2024
Cuda compilation tools, release 12.4, V12.4.99
Build cuda_12.4.r12.4/compiler.33961263_0

rust-toolchain.toml

Same as main branch.

[toolchain]
channel = "nightly-2025-03-02"
components = [
    "clippy",
    "llvm-tools-preview",
    "rust-src",
    "rustc-dev",
    "rustfmt",
    "rust-analyzer"
]

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