aboutsummaryrefslogtreecommitdiffhomepage
path: root/zluda/build.rs
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2021-01-08 17:17:46 +0100
committerGitHub <[email protected]>2021-01-08 17:17:46 +0100
commit078ae20c2c0aff93858eeb69d0c46dad4d997998 (patch)
tree38d2313c5bab64e2a84c90a219bd60ce6808f116 /zluda/build.rs
parent2c0e9b912fe341bd1e513614014fa43b666d257d (diff)
downloadZLUDA-078ae20c2c0aff93858eeb69d0c46dad4d997998.tar.gz
ZLUDA-078ae20c2c0aff93858eeb69d0c46dad4d997998.zip
Improve build procedure and instructions (#28)
Fixes issues pointed out in #27: * spirv_tools-sys was build in non-test profiles * By default ZLUDA dll has a wrong name * We relied on third-party OpenCL installation on Windows * We encouraged building debug configuration * We didn't provide build information for developers (cmake, python, submodules)
Diffstat (limited to 'zluda/build.rs')
-rw-r--r--zluda/build.rs39
1 files changed, 16 insertions, 23 deletions
diff --git a/zluda/build.rs b/zluda/build.rs
index 3b8999f..94c2c6f 100644
--- a/zluda/build.rs
+++ b/zluda/build.rs
@@ -1,27 +1,20 @@
+use env::VarError;
+use std::{env, path::PathBuf};
+
// HACK ALERT
-// This buidl script has been copy-pasted from cl-sys to avoid CUDA libraries
-// overriding path to OpenCL
+// This is a temporary hack to to make sure that linker does not pick up
+// NVIDIA OpenCL .lib using paths injected by cl-sys
- fn main() {
+fn main() -> Result<(), VarError> {
if cfg!(windows) {
- let known_sdk = [
- // E.g. "c:\Program Files (x86)\Intel\OpenCL SDK\lib\x86\"
- ("INTELOCLSDKROOT", "x64", "x86"),
- // E.g. "c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\Win32\"
- ("CUDA_PATH", "x64", "Win32"),
- // E.g. "C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86\"
- ("AMDAPPSDKROOT", "x86_64", "x86"),
- ];
-
- for info in known_sdk.iter() {
- if let Ok(sdk) = std::env::var(info.0) {
- let mut path = std::path::PathBuf::from(sdk);
- path.push("lib");
- path.push(if cfg!(target_arch="x86_64") { info.1 } else { info.2 });
- println!("cargo:rustc-link-search=native={}", path.display());
- }
- }
-
- println!("cargo:rustc-link-search=native=C:\\Program Files (x86)\\OCL_SDK_Light\\lib\\x86_64");
+ let env = env::var("CARGO_CFG_TARGET_ENV")?;
+ if env == "msvc" {
+ let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
+ path.push("lib");
+ println!("cargo:rustc-link-search=native={}", path.display());
+ } else {
+ println!("cargo:rustc-link-search=native=C:\\Windows\\System32");
+ };
}
-} \ No newline at end of file
+ Ok(())
+}