rust-math / intel-mkl-src

Redistribute Intel MKL as a crate
Other
81 stars 22 forks source link

How to locate mkl-dynamic-ilp64-iomp on macOS / MKL 2021.3 #66

Open joseph-long opened 3 years ago

joseph-long commented 3 years ago

I'm trying to get a "hello world" build working on macOS 11.4 with intel-mkl-src as a dependency, and I've installed Intel MKL through the oneAPI graphical installer. I can see that the pkg-config files are installed:

$ find /opt/intel -iname '*.pc'
/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig/mkl-static-lp64-seq.pc
/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig/mkl-static-ilp64-iomp.pc
/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig/mkl-dynamic-ilp64-iomp.pc
/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig/mkl-static-ilp64-seq.pc
/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig/mkl-dynamic-lp64-iomp.pc
/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig/mkl-dynamic-ilp64-seq.pc
/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig/mkl-dynamic-lp64-seq.pc
/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig/mkl-static-lp64-iomp.pc

However, they appear to be broken / misconfigured somehow?

$ PKG_CONFIG_PATH=/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig pkg-config --libs mkl-dynamic-lp64-iomp
Variable 'MKLROOT' not defined in '/opt/intel/oneapi/mkl/2021.3.0/bin/pkgconfig/mkl-dynamic-lp64-iomp.pc'

This, I assume, is why cargo is failing to build intel-mkl-src:

10:18:01 raven:port_mkl_example josephlong
$ export PKG_CONFIG_PATH="/opt/intel/oneapi/mkl/latest//bin/pkgconfig/:$PKG_CONFIG_PATH"

10:18:37 raven:port_mkl_example josephlong
$ cargo test
   Compiling intel-mkl-src v0.6.0+mkl2020.1
error: failed to run custom build command for `intel-mkl-src v0.6.0+mkl2020.1`

Caused by:
  process didn't exit successfully: `/Users/josephlong/devel/port_mkl_example/target/debug/build/intel-mkl-src-bd0310f09c0f5b31/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=MKL_DYNAMIC_ILP64_IOMP_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=MKL_DYNAMIC_ILP64_IOMP_STATIC
  cargo:rerun-if-env-changed=MKL_DYNAMIC_ILP64_IOMP_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  Error: No MKL found, and download flag is off.

Here's Cargo.toml... related issue is that I can't seem to specify dynamic on macOS and static elsewhere, hence commented lines... suggestions there would also be welcome

[package]
name = "port_mkl_example"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

# [target.'cfg(not(target_os = "macos"))'.dependencies]
# intel-mkl-src = { version = "~0.6.0", features = ["mkl-static-ilp64-iomp"], default-features = false }

[target.'cfg(target_os = "macos")'.dependencies]
intel-mkl-src = { version = "~0.6.0", features = ["mkl-dynamic-ilp64-iomp"], default-features = false }
joseph-long commented 3 years ago

I have tried export MKLROOT=/opt/intel/oneapi/mkl/latest but it does not seem to change the behavior of the build script.