Skip to content

llvm 19 support #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 58 commits into from
Closed

llvm 19 support #227

wants to merge 58 commits into from

Conversation

brandonros
Copy link

@brandonros brandonros commented Jun 8, 2025

potentially addresses all of:

@brandonros
Copy link
Author

i'm on the fence about renaming llvm to llvm7 and llvm19

i think it might not actually be needed and i might put it back

@brandonros
Copy link
Author

@LegNeato my measuring stick here is does vecadd example build with LLVM v19

could you tell me if I'm close or if I'm actually missing something huge like a mountain of work I'm not seeing?

@brandonros
Copy link
Author

 DEBUG: About to call LLVMRunPasses - THIS IS THE CRITICAL POINT
  DEBUG: Parameters:
  DEBUG:   llmod: 0x770f3d33a580
  DEBUG:   pipeline: "default<O0>"
  DEBUG:   tm: 0x770f27dafb00
  DEBUG:   pass_options: 0x770f27e00060
  DEBUG: LLVMRunPasses returned: 0
  DEBUG: LLVMRunPasses completed successfully
  DEBUG: Cleaning up pass builder options
  DEBUG: Pass builder options disposed
  DEBUG: optimize function completed successfully
  DEBUG: About to verify module before prepare_thin
  DEBUG: Module verification result: 0
  DEBUG: LLVMRustThinLTOBufferCreate called with is_thin=1, emit_summary=1
  DEBUG: Taking ThinLTO path
  DEBUG: About to run ThinLTO pass
  error: rustc interrupted by SIGSEGV, printing backtrace
(gdb) bt
#0  0x0000772679b89e10 in llvm::ValueEnumerator::EnumerateType(llvm::Type*) ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#1  0x0000772679b8d240 in llvm::ValueEnumerator::incorporateFunction(llvm::Function const&) ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#2  0x0000772679b615b2 in (anonymous namespace)::ModuleBitcodeWriter::write() ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#3  0x0000772679b5b341 in llvm::BitcodeWriter::writeModule(llvm::Module const&, bool, llvm::ModuleSummaryIndex const*, bool, std::array<unsigned int, 5ul>*) () from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#4  0x0000772679b66802 in llvm::WriteBitcodeToFile(llvm::Module const&, llvm::raw_ostream&, bool, llvm::ModuleSummaryIndex const*, bool, std::array<unsigned int, 5ul>*) () from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#5  0x000077267944549c in llvm::ThinLTOBitcodeWriterPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#6  0x00007726786b34a7 in llvm::detail::PassModel<llvm::Module, llvm::ThinLTOBitcodeWriterPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#7  0x000077267a2e0dc8 in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) () from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
--Type <RET> for more, q to quit, c to continue without paging--
#8  0x000077267867e178 in LLVMRustThinLTOBufferCreate ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#9  0x000077267859d7be in rustc_codegen_nvvm::lto::ThinBuffer::new ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#10 0x000077267858512a in <rustc_codegen_nvvm::NvvmCodegenBackend as rustc_codegen_ssa::traits::write::WriteBackendMethods>::prepare_thin () from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#11 0x00007726785ec605 in rustc_codegen_ssa::back::write::execute_optimize_work_item ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#12 0x00007726785e3cd5 in rustc_codegen_ssa::back::write::spawn_work::{{closure}} ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#13 0x0000772678404d97 in std::sys::backtrace::__rust_begin_short_backtrace ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#14 0x000077267847357f in std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}} ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#15 0x0000772678520144 in <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
    () from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#16 0x0000772678466e24 in std::panicking::try::do_call ()
--Type <RET> for more, q to quit, c to continue without paging--
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#17 0x000077267847381b in __rust_try () from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#18 0x00007726784730f1 in std::thread::Builder::spawn_unchecked_::{{closure}} ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#19 0x000077267848f987 in core::ops::function::FnOnce::call_once{{vtable.shim}} ()
   from /workspaces/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so
#20 0x000077268c55b8ab in std::sys::pal::unix::thread::Thread::new::thread_start ()
   from /root/.rustup/toolchains/nightly-2025-03-02-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-e3b06f91230294e6.so
#21 0x000077268668aaa4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447
#22 0x0000772686717a34 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100

pain

@LegNeato
Copy link
Contributor

I don't know, llvm is an area of the project I have not touched.

Copy link
Contributor

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should stay the same, right? The newer support should be optional / only enabled when

static PREBUILT_LLVM_URL: &str =
"https://github.com/rust-gpu/rustc_codegen_nvvm-llvm/releases/download/LLVM-7.1.0/";

static REQUIRED_MAJOR_LLVM_VERSION: u8 = 7;
static REQUIRED_MAJOR_LLVM_VERSION: u8 = 19;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requirement doesn't bump unless targeting a higher arch? So the logic is:

  • 7 if targeting arch supported by 7 and 19
  • 19 if targeting arch not supported by 7

@LegNeato
Copy link
Contributor

We should probably break this down, seeing as neither of us understand this space.

First, we should probably add various values for arch and stuff to enums on the rust side. Some of these might need to be gated if on 7 vs 19.

Then, we should get switching between 7 and a stubbed out / non working 19 via target arch.

Then, we should systematically fix each issue and refactor common code on the way.

@brandonros
Copy link
Author

seeing as neither of us understand this space.

ok... kind of a strange remark...

i'm just going to work on my local branch and make kernels compile with 19.1

then i was going to work backwards and "make it upstream worthy"...

@brandonros brandonros closed this Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants