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 fails with "incompatible function pointer type" on Apple m3 #35148

Closed
jaydorsey opened this issue Nov 29, 2023 · 12 comments
Closed

Make fails with "incompatible function pointer type" on Apple m3 #35148

jaydorsey opened this issue Nov 29, 2023 · 12 comments

Comments

@jaydorsey
Copy link

jaydorsey commented Nov 29, 2023

What version of gRPC and what language are you using?

All grpc gem versions from 1.54.2 thru 1.59.2, ruby

What operating system (Linux, Windows,...) and version?

OS: macOS 14.1.1
Chip: M3 Max

What runtime / compiler are you using (e.g. python version or version of gcc)

ruby: 3.1.2 (and 3.2.2)
gcc: 13.2.0 (homebrew)
llvm: 17.0.6 (homebrew)
Command Line Tools: 15.0.0.0.1.1694021235
Xcode: 15.0.1

What did you do?

I'm trying to install the grpc gem on a new Macbook Pro with an M3 Max chip using the command gem install grpc -v 1.54.2

I've also tried cloning the repo & building from source/running tests

What did you expect to see?

I expected the gem to install after it builds from source

What did you see instead?

I see 1 error that causes the grpc build to fail:

rb_channel.c:764:40: error: incompatible function pointer types passing 'VALUE (VALUE)' (aka 'unsigned long (unsigned long)') to parameter of type 'VALUE (*)(void *)' (aka 'unsigned long (*)(void *)') [-Wincompatible-function-pointer-types]
  764 |   background_thread = rb_thread_create(run_poll_channels_loop, NULL);
      |                                        ^~~~~~~~~~~~~~~~~~~~~~

Anything else we should know about your project / environment?

I've tried installing with both default macOS binaries (gcc/clang, etc.) with similar results but a different set of error messages (ranlib, etc.)

I tried setting the relevant paths (LDFLAGS, CPPFLAGS, etc.) per the homebrew instructions, and without the paths.

I tried installing with ruby 3.2.2 with the same error

I tried installing 1.60.0.pre and that install worked so there may be a patch/workaround for it that I can upgrade to. I can't use this as a workaround in the current situation, because of cascading dependencies.

I'd love to find out that I'm missing something in the install, or that I've configured something wrong. The only solution that comes to mind is a) buying a new laptop (without an M3 chip); b) Forgetting about locally installing any of this and work inside of a docker container

I'm wondering if this is an issue related to the m3 chipset

@jaydorsey jaydorsey changed the title incompatible function pointer type on Apple m3 Make fails with "incompatible function pointer type" on Apple m3 Nov 29, 2023
@alto-ruby
Copy link
Contributor

alto-ruby commented Dec 1, 2023

#35194 should be able to fix it.

The reason 1.60.0.pre installation succeeds is because started to distribute arm64 binary for mac, so no compiling is needed. It would be great if you can upgrade to 1.60.0 release to unblock yourself. @jaydorsey

@apolcyn Is it possible that we publish v1.54.2 arm64-darwin binary or back port the fix for this user?

@jaydorsey
Copy link
Author

I can't upgrade in the project at this point, this only affects me and I can work around it by working inside of a docker container.

I was hoping that I was just missing some kind of build/library configuration. I think there's a homebrew install for 1.5.x but I can't seem to recreate whatever steps they do to build it.

If it's a potentially breaking change to backport it, it's probably not worth it. I know we'll update our library at some point and I do have a workaround. Thank you for looking at this though.

Happy to leave this issue open for others to chime in but we can also close it

@jaydorsey
Copy link
Author

@alto-ruby I pulled down your patch, setup submodules, did a rake build, and then a gem install on the package.

I got a new error. I don't know much about C but I'll see if I can dig thru the diff between 1.54.2 and your change + 1.60 which does seem to compile just fine.

I'm also going to unpin grpc from our gemfile for local development, and then just discard those changes. Between those solutions, and docker, I have options to unblock me.

I appreciate you taking the time to look at this, thank you.

rb_channel.c:786:30: error: incompatible function pointer types passing 'void (void *)' to parameter of type 'void *(*)(void *)' [-Wincompatible-function-pointer-types]
  786 |   rb_thread_call_without_gvl(run_poll_channels_loop_unblocking_func, NULL, NULL,
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@alto-ruby
Copy link
Contributor

It can be fixed the same way, I'll update the PR.
Sorry that I don't have the same environment to reproduce it, only fixing the errors you provided.

@alto-ruby
Copy link
Contributor

I just found out that there is already #34481 fixing the same issue

@jaydorsey
Copy link
Author

I just found out that there is already #34481 fixing the same issue

Oh thank you, I'll take a look. I think I tried installing w/ downgraded versions of many things (llvm, gcc, etc.) but I know I didn't look at clang.

I'll look at that related PR, I appreciate you following up on this!

I'm going to close this issue since it looks like the root cause/resolution is being addressed in that pull request, and that answered the heart of my original question "Am I missing some compilation flags that would let me get this working"

@jaydorsey
Copy link
Author

@alto-ruby One quick update: based on your comment, I was able to fix my system and get grpc 1.54.2 installed!

  1. brew install llvm@15
  2. Add all the path/export changes it notes in the install output
  3. Make sure you clear out any previous path/export overrides where llvm was configured (which is probably 17 if your install was recent)

After that, a regular old gem install grpc -v 1.54.2 or bundle install works. Thank you!

@technicalpickles
Copy link

I got curious if there's a less invasive way to work around the issue than installing llvm@15. Based on

#34481 talks about:

clang 16 defaults -Wincompatible-function-pointer-types to be on. This causes a number of hard errors due to implicit conversions between void * and void, such as:

If that is the case, it should be possible to turn it off right? Reading https://clang.llvm.org/docs/UsersManual.html#options-to-control-error-and-warning-messages make it seem like this could do it:

-Wno-error=incompatible-function-pointer-type

I'm used to being able to pass in things like that to CFLAGS, but either I'm not able to pass it in that way, or setting it on the command line doesn't make it all the way down to the generated Makefile 🤔

@flipsasser
Copy link

flipsasser commented Jan 31, 2024

@technicalpickles you can use pass-thru arguments on gem install, so something like gem install grpc:[VERSION] -- -Wno-error=incompatible-function-pointer-type will pass those flags on to the compiler

I mean, that didn't actually WORK for me, but I'm experimenting with flags now. Sigh. This is a pain!

@oleg-vinted
Copy link

oleg-vinted commented Mar 8, 2024

If you're using Bundler, you can set this override like this:

bundle config set --global build.grpc "--with-cflags=-Wno-error=incompatible-function-pointer-types"

Ref https://bundler.io/v2.5/man/bundle-config.1.html#BUILD-OPTIONS

@stathis-alexander
Copy link

FYI - Looks like this issue is fixed in 1.62.1

@pprencel
Copy link

@technicalpickles @flipsasser
One of those solutions should work for you:
gem install grpc -v 1.54.2 -- --with-cflags=-Wno-error=incompatible-function-pointer-types
or
bundle config set --global build.grpc "--with-cflags=-Wno-error=incompatible-function-pointer-types"

Actually grpc build error relates to Wincompatible-function-pointer-types, not Wincompatible-function-pointer-type
So it looks like it won't work for you because of the typo 🤭

kamalmarhubi added a commit to kamalmarhubi/dotfiles-nix that referenced this issue Jun 13, 2024
This had to be from nixpkgs-23.05-darwin because of a build failure in
grpc that I think is related to grpc/grpc#35148
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants