Skip to content

Commit

Permalink
#66 Cleaning up macos support in build.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
coreylowman committed Jul 18, 2022
1 parent f641f96 commit 9ecec37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .cargo/config

This file was deleted.

14 changes: 5 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const MACOS_COMPILER_PATH: &str = "compiler/latest/mac/compiler/lib";
pub const LINK_DIRS: &[&str] = &[MACOS_COMPILER_PATH, "mkl/latest/lib"];

#[cfg(target_os = "macos")]
pub const SHARED_LIB_DIRS: &[&str] = LINK_DIRS;
pub const SHARED_LIB_DIRS: &[&str] = &["mkl/latest/lib"];

#[derive(Debug)]
pub enum BuildError {
Expand Down Expand Up @@ -154,13 +154,6 @@ fn main() -> Result<(), BuildError> {
// check to make sure that things in `SHARED_LIB_DIRS` are in `$LD_DIR`.
let path = path.replace('\\', "/");
for shared_lib_dir in SHARED_LIB_DIRS {
#[cfg(target_os = "macos")]
if *shared_lib_dir == MACOS_COMPILER_PATH {
// on macOS that directory is not set in $DYLD_LIBRARY_PATH, but
// rather we set it with rustflags in .cargo/config
continue;
}

let versioned_dir = shared_lib_dir.replace("latest", MKL_VERSION);

println!("Checking that '{shared_lib_dir}' or '{versioned_dir}' is in {LD_DIR}");
Expand Down Expand Up @@ -202,6 +195,10 @@ fn main() -> Result<(), BuildError> {
println!("cargo:rustc-link-lib=m");
println!("cargo:rustc-link-lib=dl");
}

if config!(target_os = "macos") {
println!("cargo:rustc-link-arg=-Wl,-rpath,{root}/{MACOS_COMPILER_PATH}");
}
}

// If on nightly, enable "nightly" feature
Expand All @@ -227,4 +224,3 @@ fn suggest_setvars_cmd(root: &str) -> String {
format!("source {root}/setvars.sh")
}
}

0 comments on commit 9ecec37

Please sign in to comment.