Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README example fails do build on windows with MS-MPI #183

Closed
PipInSpace opened this issue Apr 16, 2024 · 5 comments
Closed

README example fails do build on windows with MS-MPI #183

PipInSpace opened this issue Apr 16, 2024 · 5 comments

Comments

@PipInSpace
Copy link

I have attempted to build the example code in the README on windows. MS-MPI and LLVM/libclang are installed an their path variables set. I get the following error on the custom build command:

PS D:\Programming\Git\mspi-tests> cargo build
   Compiling mpi-sys v0.2.1
error: failed to run custom build command for `mpi-sys v0.2.1`

Caused by:
  process didn't exit successfully: `D:\Programming\Git\mspi-tests\target\debug\build\mpi-sys-1b6f4601ab826597\build-script-build` (exit code: 101)
  --- stdout
  cargo:rustc-cfg=msmpi
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-pc-windows-msvc")
  HOST = Some("x86_64-pc-windows-msvc")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
  CC_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
  CC_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  DEBUG = Some("true")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  rsmpi.c
  cargo:rerun-if-env-changed=AR_x86_64-pc-windows-msvc
  AR_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=AR_x86_64_pc_windows_msvc
  AR_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=HOST_AR
  HOST_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=ARFLAGS_x86_64-pc-windows-msvc
  ARFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=ARFLAGS_x86_64_pc_windows_msvc
  ARFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=HOST_ARFLAGS
  HOST_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rustc-link-search=native=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\atlmfc\lib\x64
  cargo:rustc-link-lib=static=rsmpi
  cargo:rustc-link-search=native=D:\Programming\Git\mspi-tests\target\debug\build\mpi-sys-b247709d622bce4e\out
  cargo:rustc-link-search=native=C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64\
  cargo:rustc-link-lib=msmpi

  --- stderr
  thread 'main' panicked at C:\Users\...\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bindgen-0.68.1\ir\context.rs:553:15:
  libclang error; possible causes include:
  - Invalid flag syntax
  - Unrecognized flags
  - Invalid flag arguments
  - File I/O errors
  - Host vs. target architecture mismatch
  If you encounter an error missing from this list, please file an issue or a PR!
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I have not touched any code, so I don't know how to interpret the possible errors listed. I apologize if I have overlooked something, but this appears like a crate issue to me.

@jedbrown
Copy link
Contributor

It looks like an environment problem. Can you compare what you're trying with what is tested in CI? Let us know how we can improve the instructions.
https://github.com/rsmpi/rsmpi/blob/main/.github/workflows/test.yaml#L59-L66
(I don't run on Windows so I'm not exposed to the quirks, but I do intend for it to be supported and rely on CI.)

@PipInSpace
Copy link
Author

I have tried cloning the rsmpi repository and running the tests with cargo test --features complex,derive (which I assume was meant by trying the CI tests). I have verified that MS-MPI is fully installed and all crates are updated. The build fails with the exact same issue, the log is identical except for the file locations.

@jedbrown
Copy link
Contributor

Something must be different between your configuration and the Windows CI where rsmpi is tested. The error is coming from bindgen. I'd recommend seeing if you can run cargo test in the bindgen repo, and if not, reporting in their issues or discussions. https://github.com/rust-lang/rust-bindgen/discussions

@PipInSpace
Copy link
Author

PipInSpace commented Jun 3, 2024

I finally found the cause of this! It seems to have been a strange problem with bindgen:
bindgen needs libclang which I had installed via LLVM. To use libclang the LIBCLANG_PATH environment variable needs to be set according to some bindgen docs (https://rust-lang.github.io/rust-bindgen/requirements.html#windows) and it was for me, to the correct location of "C:\Program Files\LLVM\bin" . This doesn't seem to enough for bindgen in my case though, and the build failed with a cryptic error.

The example builds successfully after adding the environment variable CLANG_PATH="C:\Program Files\LLVM\bin\clang.exe" which explicitly defines the location of clang.

@jedbrown
Copy link
Contributor

If this is something we can document or otherwise make more robust, feel free to open a PR to update the docs.

Once the MPI ABI is widely available, we'll be able to drop the dependency on bindgen. I've been involved in that process for a while and it will take some time to make it into distributions. For Windows in particular, it'll depend on MS-MPI adding support. MS-MPI currently only claims compliance with MPI-2.2 (2009) and a subset of MPI-3.1 (2015) so I can't estimate how long it'll take to deploy the ABI (which is still working its way through standardization).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants