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

Make CI and the nightly release work on Windows #127

Closed
wants to merge 7 commits into from

Conversation

Michael-F-Bryan
Copy link
Contributor

Closes #101.

@Michael-F-Bryan
Copy link
Contributor Author

I believe this is the issue we are running into: rust-lang/rust-bindgen#1797 (comment)

@Michael-F-Bryan Michael-F-Bryan force-pushed the 101-windows-ci-builds branch from 48c5342 to a23a28a Compare July 6, 2021 01:28
@Michael-F-Bryan
Copy link
Contributor Author

I made some progress on this by playing around on my Windows VM...

When you see something like this:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xstddef:283:22: error: 'auto' return without trailing return type; deduced return types are a C++14 extension, err: true
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xutility:1427:16: error: constexpr function's return type 'void' is not a literal type, err: true
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xutility:1476:22: error: 'auto' return without trailing return type; deduced return types are a C++14 extension, err: true
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xutility:1481:16: error: no viable conversion from returned value of type 'std::_Distance_unknown' to function return type 'int', err: true
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xutility:1783:27: error: constexpr function's return type 'void' is not a literal type, err: true
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xutility:1788:20: error: constexpr function's return type 'void' is not a literal type, err: true
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xutility:1801:20: error: constexpr function's return type 'void' is not a literal type, err: true
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xutility:3799:18: error: 'auto' return without trailing return type; deduced return types are a C++14 extension, err: true
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xutility:3903:27: error: constexpr function's return type 'void' is not a literal type, err: true
  fatal error: too many errors emitted, stopping now [-ferror-limit=], err: true
  thread 'main' panicked at 'Unable to generate bindings: ()', C:\Users\runneradmin\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\tflite-0.9.6\build.rs:237:40

It's because bindgen is defaulting to an older version of the C++ CTL on Windows. You can fix this by asking it to pass -std=c++17 to libclang (echo "BINDGEN_EXTRA_CLANG_ARGS=-std=c++17" >> $env:GITHUB_ENV).

Next the Microsoft compiler, cl, will complain about a dodgy argument.

  running: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX64\\x64\\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "C:\\Users\\runneradmin\\.cargo\\registry\\src\\github.aaakk.us.kg-1ecc6299db9ec823\\tflite-0.9.6" "-I" "C:\\Users\\runneradmin\\.cargo\\registry\\src\\github.aaakk.us.kg-1ecc6299db9ec823\\tflite-0.9.6\\submodules\\tensorflow" "-I" "C:\\Users\\runneradmin\\.cargo\\registry\\src\\github.aaakk.us.kg-1ecc6299db9ec823\\tflite-0.9.6\\submodules\\downloads/flatbuffers/include" "-W4" "-fPIC" "-std=c++14" "-Wno-sign-compare" "-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK" "-DFLATBUFFERS_POLYMORPHIC_NATIVETABLE" "-FoD:\\a\\rune\\rune\\target\\debug\\build\\tflite-e183d799789c93c3\\out\\rust_cpp\\cpp_closures.o" "-c" "D:\\a\\rune\\rune\\target\\debug\\build\\tflite-e183d799789c93c3\\out\\rust_cpp\\cpp_closures.cpp"
  cargo:warning=cl : Command line error D8021 : invalid numeric argument '/Wno-sign-compare'
  exit code: 2

I resolved that by just telling the build to use clang++ (which we need for bindgen anyway) instead of cl.

> $env:CC = "clang"
> $env:CXX = "clang++"

This isn't 100% perfect though because CMake decides to compile position-independent code (-fPIC), which isn't a thing on x86_64-pc-windows-msvc.

running: "clang++" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "--target=x86_64-pc-windows-msvc" "-I" "C:\\Users\\Michael\\Documents\\tflite-rs" "-I" "C:\\Users\\Michael\\Documents\\tflite-rs\\submodules\\tensorflow" "-I" "C:\\Users\\Michael\\Documents\\tflite-rs\\submodules\\downloads/flatbuffers/include" "-Wall" "-Wextra" "-fPIC" "-std=c++14" "-Wno-sign-compare" "-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK" "-DFLATBUFFERS_POLYMORPHIC_NATIVETABLE" "-o" "C:\\Users\\Michael\\Documents\\tflite-rs\\target\\x86_64-pc-windows-msvc\\debug\\build\\tflite-788407d034bca9a4\\out\\rust_cpp\\cpp_closures.o" "-c" "C:\\Users\\Michael\\Documents\\tflite-rs\\target\\x86_64-pc-windows-msvc\\debug\\build\\tflite-788407d034bca9a4\\out\\rust_cpp\\cpp_closures.cpp"
cargo:warning=clang++: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'

@Michael-F-Bryan
Copy link
Contributor Author

I'm going to close this for now. Windows builds should be naturally handled when librunecoral has Windows support (hotg-ai/librunecoral#2) and we fully remove the tflite crate.

@Michael-F-Bryan Michael-F-Bryan deleted the 101-windows-ci-builds branch October 25, 2021 16:39
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

Successfully merging this pull request may close these issues.

Make sure tflite compiles in the Windows CI environment
1 participant