Skip to content

Commit

Permalink
Set CXX for CUDA, if conditions are met.
Browse files Browse the repository at this point in the history
Thanks to Dev for the suggestion.

We've had a long-standing "issue" with Archlinux that, because it distributes
really new compilers, these may not play nicely with what nvcc expects. To get
around that, there's a gcc and g++ in $CUDA_PATH/bin. I've manually gotten
around compilation issues by setting $CXX to this, but now $CXX will be set if:

1) $CXX is not already set
2) $CUDA_PATH is set
3) $CUDA_PATH/bin/g++ exists
  • Loading branch information
cjordan committed Sep 14, 2023
1 parent 00e5549 commit 2d120b2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ mod gpu {
.cudart("shared") // We handle linking cudart statically
.include("src/fee/gpu/")
.file("src/fee/gpu/fee.cu");
// If $CXX is not set but $CUDA_PATH is, search for
// $CUDA_PATH/bin/g++ and if it exists, set that as $CXX.
if !env::var_os("CXX").is_some() {
// Unlike above, we care about $CUDA_PATH being unicode.
if let Ok(cuda_path) = env::var("CUDA_PATH") {
// Look for the g++ that CUDA wants.
let compiler = std::path::PathBuf::from(cuda_path).join("bin/g++");
if compiler.exists() {
println!("cargo:warning=Setting $CXX to {}", compiler.display());
env::set_var("CXX", compiler.into_os_string());
}
}
}
// Loop over each arch and sm
for arch in arches {
for &sm in &sms {
Expand Down

0 comments on commit 2d120b2

Please sign in to comment.