Opened 4 years ago

Closed 15 months ago

Last modified 15 months ago

#62208 closed defect (fixed)

py-grpcio: error: invalid argument '-std=c++11' not allowed with 'C'

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: emcrisostomo (Enrico Maria Crisostomo)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: cooljeanius (Eric Gallager), mascguy (Christopher Nielsen)
Port: py-grpcio

Description

py-grpcio does not build:

/opt/local/bin/clang-mp-9.0 -fno-strict-aliasing -fno-common -dynamic -pipe -Os -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -isysroot/ -D_WIN32_WINNT=1536 -DOPENSSL_NO_ASM=1 -DGPR_BACKWARDS_COMPATIBILITY_MODE=1 -DHAVE_CONFIG_H=1 -DGRPC_ENABLE_FORK_SUPPORT=1 -DPyMODINIT_FUNC=extern "C" __attribute__((visibility ("default"))) void -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 -Isrc/python/grpcio -Iinclude -I. -Ithird_party/abseil-cpp -Ithird_party/address_sorting/include -I/opt/local/include -Ithird_party/re2 -I/opt/local/include/openssl -Ithird_party/upb -Isrc/core/ext/upb-generated -Isrc/core/ext/upbdefs-generated -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c -o python_build/temp.macosx-10.10-i386-2.7/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.o -std=c++11 -stdlib=libc++ -fvisibility=hidden -fno-wrapv -fno-exceptions -pthread
error: invalid argument '-std=c++11' not allowed with 'C'

It's trying to give the -std=c++11 -stdlib=libc++ flags to the C compiler. C compilers don't understand those flags. Only C++ compilers do.

This probably relates to the fact that Python does not support modules written in C++. It's unfortunate that the developers of py-grpcio decided to write a module in C++ despite the fact that Python doesn't support it.

Attachments (2)

py310-grpcio-build-10.9-patched.log.gz (35.5 KB) - added by mascguy (Christopher Nielsen) 15 months ago.
patch-python-respect-cc-variable.diff (1.0 KB) - added by mascguy (Christopher Nielsen) 15 months ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 4 years ago by jmroot (Joshua Root)

Might be able to work around it by adding -xc++ to the flags.

comment:2 Changed 3 years ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added

comment:3 Changed 16 months ago by mascguy (Christopher Nielsen)

Cc: mascguy added

With the latest version of the port, the complaint now relates to std=c++14. But same fundamental issue.

Sounds like it's worth trying Josh's suggestion from comment:1 though:

Might be able to work around it by adding -xc++ to the flags.

comment:4 Changed 16 months ago by jmroot (Joshua Root)

If it's all C++, then the workaround used in py-re2 could work. But if there's a mix of C and C++, there's no way to specify the correct compiler for each from outside the build system, and you're probably looking at some patching.

comment:5 Changed 16 months ago by ryandesign (Ryan Carsten Schmidt)

Now reported to the developers: https://github.com/grpc/grpc/issues/33923

comment:6 Changed 15 months ago by jmroot (Joshua Root)

Changed 15 months ago by mascguy (Christopher Nielsen)

comment:7 Changed 15 months ago by mascguy (Christopher Nielsen)

Replying to jmroot:

So looks like this was probably fixed upstream by https://github.com/grpc/grpc/commit/31fc452b68e429c029f00b5fcc54292a303be0c6

Haven't looked too closely at the Python details yet. But I did try building py310-grpcio on 10.9, with that patch. And no luck.

Build log attached; filename: py310-grpcio-build-10.9-patched.log.gz.

If anyone's interested in taking a quick look, I'd love to hear folks' thoughts! Otherwise, I'll try to find some time to dig into this further, over the coming days...

Changed 15 months ago by mascguy (Christopher Nielsen)

comment:8 in reply to:  6 Changed 15 months ago by mascguy (Christopher Nielsen)

Replying to jmroot:

So looks like this was probably fixed upstream by https://github.com/grpc/grpc/commit/31fc452b68e429c029f00b5fcc54292a303be0c6

The patch I used - based on that commit - is also attached; filename: patch-python-respect-cc-variable.diff.

comment:9 Changed 15 months ago by jmroot (Joshua Root)

I don't see the patch being applied in that log. Did you change the patch phase override to a post-patch?

comment:10 in reply to:  9 Changed 15 months ago by mascguy (Christopher Nielsen)

Replying to jmroot:

I don't see the patch being applied in that log. Did you change the patch phase override to a post-patch?

Ah, nope, that would certainly help! With that additional change in play, the build looks good now. Thanks for the catch Josh!

comment:11 Changed 15 months ago by Christopher Nielsen <mascguy@…>

Resolution: fixed
Status: assignedclosed

In f931cfa55254ec9928d5b9a7103f11cca7b68f35/macports-ports (master):

py-grpcio*: patch to fix C compiler handling

Fixes: #62208

comment:12 in reply to:  5 Changed 15 months ago by mascguy (Christopher Nielsen)

Replying to ryandesign:

Now reported to the developers: https://github.com/grpc/grpc/issues/33923

I commented on the issue, letting folks know that the upstream patch fixes the issue. Ryan, do you want to close that?

Note: See TracTickets for help on using tickets.