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

Building tikv-client for Windows (x86_64-pc-windows-gnu) #362

Closed
tobiemh opened this issue Aug 10, 2022 · 6 comments
Closed

Building tikv-client for Windows (x86_64-pc-windows-gnu) #362

tobiemh opened this issue Aug 10, 2022 · 6 comments

Comments

@tobiemh
Copy link

tobiemh commented Aug 10, 2022

Hi,

I'm trying to build a library (which uses tikv-client as a dependency). I've attempted to compile this library on Windows (in Github Actions), Ubuntu (in Github Actions), and macOS (locally), none of which are working.

The issue that I have is that grpc-sys is unable to build successfully.

On Windows I have tried with the default environment (which includes all of the necessary packages), and I have also installed the following packages just in case:

pacman --noconfirm -S mingw-w64-x86_64-yasm mingw-w64-clang-x86_64-clang mingw-w64-x86_64-binutils mingw-w64-x86_64-openssl

On Ubuntu I have installed:

sudo apt-get -y install mingw-w64

And on macOS I have installed:

brew install clang mingw-w64

In Github Actions, the tooling versions I am using are:

go version go1.17.12 windows/amd64
cargo 1.62.1 (a748cf5a3 2022-06-08)
rustc 1.62.1 (e092d0b6b 2022-07-16)
cmake version 3.23.3
gcc.exe (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 11.2.0
g++.exe (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 11.2.0
perl v5.32.1 built for x86_64-msys-thread-multi

There are two issues that I am encountering:

1. First issue

The build fails with:

C:/Users/runneradmin/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/grpcio-sys-0.8.1/grpc/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc:451:26: error: 'numeric_limits' is not a member of 'std'
...
C:/Users/runneradmin/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/grpcio-sys-0.8.1/grpc/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc:451:49: error: expected primary-expression before '>' token
...
C:/Users/runneradmin/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/grpcio-sys-0.8.1/grpc/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc:451:52: error: '::max' has not been declared; did you mean 'std::max'?

This error can be solved by editing the grpcio-sys-0.8.1/grpc/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc and adding #include <limits> towards the top. Currently tikv-client relies on grpcio@v0.8.3 which relies on grpcio-sys@v0.8.1. This issue has been fixed in the later versions of grpcio and grpcio-sys.

Is there a possibility of upgrading the grpcio dependency in tikv-client?

2. Second issue

Once this issue is solved, we hit another issue. The build fails with:

././grpc/include/grpc/impl/codegen/port_platform.h:54:10: fatal error: 'windows.h' file not found
././grpc/include/grpc/impl/codegen/port_platform.h:54:10: fatal error: 'windows.h' file not found, err: true
  thread 'main' panicked at 'Unable to generate grpc bindings: ()', /Users/tobie/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/grpcio-sys-0.8.1/build.rs:370:10

I am not too sure how to get around this issue. I have set the following in my .cargo/config.toml file, but it does not change the outcome:

[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
ar = "x86_64-w64-mingw32-gcc-ar"

Does anyone know a way of getting tikv-client and/or grpcio to build for x86_64-pc-windows-gnu?

@ekexium
Copy link
Collaborator

ekexium commented Aug 11, 2022

Thanks for the feedback. grpcio has been updated to 0.10 in master. Could you try that?
Does the second problem happen only on Windows?

@tobiemh
Copy link
Author

tobiemh commented Aug 11, 2022

Hi @ekexium yes I saw this just after I posted the issue! I'm currently building off the master version, and it takes a lot longer (so I'm presuming that the C build works this time), but I get now this error:

error: couldn't read /Users/tobie/Repositories/surrealdb/target/x86_64-pc-windows-gnu/release/build/grpcio-sys-89eb569412f5ce5d/out/grpc-bindings.rs: No such file or directory (os error 2)
 --> /Users/tobie/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/grpcio-sys-0.10.3+1.44.0-patched/src/lib.rs:8:5
  |
8 |     include!(env!("BINDING_PATH"));
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `grpcio-sys` due to previous error
make: *** [build] Error 101

This is when cross-compiling from macOS (macos on aarch64) to Windows (x86_64-pc-windows-gnu).

I'll go and test this in Ubuntu (Github Actions) now.

@ekexium
Copy link
Collaborator

ekexium commented Aug 11, 2022

I tried a bit on my own linux. Seems to me cross compiling grpcio is difficult. There is a doc (it may be outdated) https://github.com/tikv/grpc-rs/blob/master/cross_compile.md

Maybe just try if it builds on Windows? If not, I suggest asking in tikv/grpc-rs.

@tobiemh
Copy link
Author

tobiemh commented Aug 11, 2022

Hi @ekexium yeah I've looked at that doc - it's very outdated!

@tobiemh
Copy link
Author

tobiemh commented Aug 11, 2022

Have created an issue for this problem in the tikv/grpc-rs repository: tikv/grpc-rs#585

@andylokandy
Copy link
Collaborator

should be fixed by #399

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

3 participants