Skip to content

Commit 9443c12

Browse files
committed
Fix: add optix finding logic for linux and move nvvm logic to helper
1 parent a75fc66 commit 9443c12

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

crates/find_cuda_helper/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,32 @@ pub fn find_optix_root() -> Option<PathBuf> {
127127
.or_else(|| env::var("OPTIX_ROOT_DIR").ok())
128128
.map(PathBuf::from)
129129
}
130+
131+
#[cfg(target_family = "unix")]
132+
pub fn find_optix_root() -> Option<PathBuf> {
133+
env::var("OPTIX_ROOT")
134+
.ok()
135+
.or_else(|| env::var("OPTIX_ROOT_DIR").ok())
136+
.map(PathBuf::from)
137+
}
138+
139+
#[cfg(target_os = "windows")]
140+
pub fn find_libnvvm_bin_dir() -> String {
141+
find_cuda_root()
142+
.expect("Failed to find CUDA ROOT, make sure the CUDA SDK is installed and CUDA_PATH or CUDA_ROOT are set!")
143+
.join("nvvm")
144+
.join("lib")
145+
.join("x64")
146+
.to_string_lossy()
147+
.into_owned()
148+
}
149+
150+
#[cfg(target_os = "linux")]
151+
pub fn find_libnvvm_bin_dir() -> String {
152+
find_cuda_root()
153+
.expect("Failed to find CUDA ROOT, make sure the CUDA SDK is installed and CUDA_PATH or CUDA_ROOT are set!")
154+
.join("nvvm")
155+
.join("lib64")
156+
.to_string_lossy()
157+
.into_owned()
158+
}

crates/nvvm/build.rs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,6 @@
1-
use find_cuda_helper::find_cuda_root;
2-
3-
#[cfg(target_os = "windows")]
4-
fn lib_search_path() -> String {
5-
find_cuda_root()
6-
.expect("Failed to find CUDA ROOT, make sure the CUDA SDK is installed and CUDA_PATH or CUDA_ROOT are set!")
7-
.join("nvvm")
8-
.join("lib")
9-
.join("x64")
10-
.to_string_lossy()
11-
.into_owned()
12-
}
13-
14-
#[cfg(target_os = "linux")]
15-
fn lib_search_path() -> String {
16-
format!("{}/nvvm/lib64", std::env::var("CUDA_ROOT").unwrap())
17-
}
18-
19-
fn libnvvm_build() {
20-
println!("cargo:rustc-link-search={}", lib_search_path());
21-
println!("cargo:rustc-link-lib=dylib=nvvm");
22-
}
1+
use find_cuda_helper::find_libnvvm_bin_dir;
232

243
fn main() {
25-
libnvvm_build()
4+
println!("cargo:rustc-link-search={}", find_libnvvm_bin_dir());
5+
println!("cargo:rustc-link-lib=dylib=nvvm");
266
}

0 commit comments

Comments
 (0)