Closed PataviniMa closed 2 years ago
This seems like an upstream issue. From their setup.py, it looks like they're building a ton of C and C++ with identical flags. For gcc, compiling a C file with -std=c++14
only emits a warning, but to clang
that's an error.
It seems like you're using NDK r25b, so switching to gcc probably isn't an option.
Maybe you can just remove the -std
flag completely and let clang use its default dialect for each type? The default dialects for that version of clang should be gnu17
for C and gnu++14
for C++, which should be a more-or-less superset of what's required. No guarantees, of course, but that seems like the least painful solution.
I'm looking at this part of their setup.py, and it looks like you might be able to set the environment variable GRPC_PYTHON_CFLAGS
to the correct value. In this case, you might be able to set it to -fvisibility=hidden -fno-wrapv -fno-exceptions
.
It took some hours of "compile - get error - find solution" looping, but I've finally managed to cross-compile grpcio using crossenv. Thanks for pointing me in the right direction. I'll leave my findings here for future reference. Python version (for both build and host): 3.10.5 grpcio source code version: 1.49.1 COMPILE_ARGS: I removed "-std=c++14", nothing else. LINK_ARGS: I removed "-lpthread" and "-lrt" (they don't have an Android counterpart as they are integrated in libc), and I added "-llog" and "-static-libstdc++" (without those two, I was getting runtime "cannot locate symbol" errors). Then, I had to set the "GRPC_PYTHON_DISABLE_LIBC_COMPATIBILITY" flag to true to get past other compile issues (see here). All this modifications were made to the {source}/setup.py file. Last but not least, I had to comment a line in this header file: {source}/third_party/cares/config_linux/ares_config.h to solve another runtime issue (see here). Now, I have a .whl feel I can import to my Android device, install it via pip, and it's working like a charm! If anyone is attempting the same, I'll leave all the edits I've made (in the form of .patch files) attached to this post. I'll also add the full build log.
Hello, first of all, I'd like to express all my gratitude for such an amazing tool. Keep up the good work!
I'm desperately trying to cross compile grpcio from ubuntu (x86_64) to android (aarch64). Both build python and host python are version 3.10.5. The build seems to proceed without issues, until I get this error:
Full building log
So, evidently, the compiler is complaining because of the '-std=c++14' used for a C source file. The question is: how can I remove that flag for C source files ONLY, leaving it for C++ files? Any help is highly appreciated. Thank you!