Skip to content
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

Determine if building llvm is needed #154

Closed
LegNeato opened this issue Mar 10, 2025 · 4 comments
Closed

Determine if building llvm is needed #154

LegNeato opened this issue Mar 10, 2025 · 4 comments

Comments

@LegNeato
Copy link
Contributor

We either build llvm or use https://github.com/Rust-GPU/rustc_codegen_nvvm-llvm. This was from before a time when llvm was available via rustup. Rust-GPU uses llvm tools: https://github.com/Rust-GPU/rust-gpu/blob/6e2c84d4fe64e32df4c060c5a7f3e35a32e45421/crates/rustc_codegen_spirv/build.rs#L19.

I'm not sure if we need this for NVVM or if the rust llvm components make this unnecessary. We should investigate.

@Schmiedium
Copy link
Contributor

Are we able to get llvm version 7 from llvm-tools? From the NVIDIA Docs, it looks there two dialects for nvvm, one based on llvm-7.0.1, and a newer one based on llvm-18.1.8. I did have trouble trying to use alternate versions since the includes from llvm change between versions and the rustc_llvm_wrapper from within the codegen breaks with different llvm versions, so that would have to maintained.

https://docs.nvidia.com/cuda/nvvm-ir-spec/index.html

Switching to the newer dialect may be an issue since it's only supported on Blackwell architecture and later, so the most recent releases from NVIDIA.

I'm not sure what the compatibility is between versions of llvm, like if version 18 can produce IR that NVCC would still accept as valid for older cards. I think that's another question to answer

Just some of my thoughts from messing around with various versions of llvm

@LegNeato
Copy link
Contributor Author

Yeah, I don't think we can only support Blackwell+. I'm also not familiar which past versions of llvm are available to rustc and how it interfaces. It would be nice to pull down a version via rustup, even if we have to write our own glue code.

@jorge-ortega
Copy link
Collaborator

It seems to me that rustc llvm-tools component only provides binaries for working with IR like llc, llvm-ar, opt, and friends. It does not include headers or libraries needed by the backend to generate IR. I'm actually not sure if the component is required at all today.

The llvm wrapper in rustc tries to support multiple versions of LLVM, and ours is mostly a copy of that, even though we only need to support for 7 or 18 (whenever we get around to that). LLVMs migration to opaque pointers makes versions 17 or greater incompatible with 7. Trying to find a version in the middle that still supports typed pointers AND still compatible with 7 would unlikely be worth the effort.

@LegNeato
Copy link
Contributor Author

@jorge-ortega makes sense!

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

No branches or pull requests

3 participants