Skip to content

Commit d3534a6

Browse files
committed
Fix: try linking in both /lib and /lib64 on linux
1 parent 74a5747 commit d3534a6

File tree

1 file changed

+14
-16
lines changed
  • crates/find_cuda_helper/src

1 file changed

+14
-16
lines changed

crates/find_cuda_helper/src/lib.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ use std::{
77

88
pub fn include_cuda() {
99
if env::var("DOCS_RS").is_err() && !cfg!(doc) {
10-
let cuda_lib_dir = find_cuda_lib_dir().expect("Could not find a cuda installation");
11-
println!("cargo:rustc-link-search=native={}", cuda_lib_dir.display());
10+
let paths = find_cuda_lib_dirs();
11+
if paths.is_empty() {
12+
panic!("Could not find a cuda installation");
13+
}
14+
for path in paths {
15+
println!("cargo:rustc-link-search=native={}", path.display());
16+
}
1217

1318
println!("cargo:rustc-link-lib=dylib=cuda");
1419
println!("cargo:rerun-if-changed=build.rs");
@@ -51,7 +56,7 @@ pub fn find_cuda_root() -> Option<PathBuf> {
5156
}
5257

5358
#[cfg(target_os = "windows")]
54-
pub fn find_cuda_lib_dir() -> Option<PathBuf> {
59+
pub fn find_cuda_lib_dirs() -> Vec<PathBuf> {
5560
if let Some(root_path) = find_cuda_root() {
5661
// To do this the right way, we check to see which target we're building for.
5762
let target = env::var("TARGET")
@@ -93,28 +98,21 @@ pub fn find_cuda_lib_dir() -> Option<PathBuf> {
9398
let lib_dir = root_path.join("lib").join(lib_path);
9499

95100
return if lib_dir.is_dir() {
96-
Some(lib_dir)
101+
vec![lib_dir]
97102
} else {
98-
None
103+
vec![]
99104
};
100105
}
101106

102-
None
107+
vec![]
103108
}
104109

105110
#[cfg(not(target_os = "windows"))]
106-
pub fn find_cuda_lib_dir() -> Option<PathBuf> {
111+
pub fn find_cuda_lib_dirs() -> Vec<PathBuf> {
107112
if let Some(root_path) = find_cuda_root() {
108-
let lib_dir = root_path.join("lib64");
109-
// TODO (AL): we probably want to check for an actual library under here
110-
// too...
111-
if lib_dir.is_dir() {
112-
Some(lib_dir)
113-
} else {
114-
None
115-
}
113+
vec![root_path.clone().join("lib64"), root_path.join("lib")]
116114
} else {
117-
None
115+
vec![]
118116
}
119117
}
120118

0 commit comments

Comments
 (0)