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

Fix compilation on newer clang #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

casperisfine
Copy link

posix-spawn.c:226:27: error: incompatible function pointer types passing 'int (VALUE, VALUE, posix_spawn_file_actions_t *)' (aka 'int (unsigned long, unsigned long, void **)') to parameter of type 'int
(*)(VALUE, VALUE, VALUE)' (aka 'int (*)(unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
        rb_hash_foreach(options, posixspawn_file_actions_operations_iter, (VALUE)fops);
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/rubies/3.4-dev-03-19/include/ruby-3.4.0+0/ruby/internal/intern/hash.h:83:40: note: passing argument to parameter 'func' here
void rb_hash_foreach(VALUE hash, int (*func)(VALUE key, VALUE val, VALUE arg), VALUE arg);

```
posix-spawn.c:226:27: error: incompatible function pointer types passing 'int (VALUE, VALUE, posix_spawn_file_actions_t *)' (aka 'int (unsigned long, unsigned long, void **)') to parameter of type 'int
(*)(VALUE, VALUE, VALUE)' (aka 'int (*)(unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
        rb_hash_foreach(options, posixspawn_file_actions_operations_iter, (VALUE)fops);
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/rubies/3.4-dev-03-19/include/ruby-3.4.0+0/ruby/internal/intern/hash.h:83:40: note: passing argument to parameter 'func' here
void rb_hash_foreach(VALUE hash, int (*func)(VALUE key, VALUE val, VALUE arg), VALUE arg);
```
@dtaivpp
Copy link

dtaivpp commented Mar 27, 2024

I wanted to bump this as I am coming across the same issue at the moment. I ran the tests and observed these failures.

Finished in 1.940804s, 76.7723 runs/s, 242.1677 assertions/s.

  1) Failure:
ChildTest#test_max_with_stubborn_child_pgroup_kill [test/test_child.rb:127]:
POSIX::Spawn::MaximumOutputExceeded expected but nothing was raised.

  2) Failure:
ChildTest#test_max_with_stubborn_child [test/test_child.rb:120]:
POSIX::Spawn::MaximumOutputExceeded expected but nothing was raised.

  3) Failure:
ChildTest#test_max_with_child_hierarchy_pgroup_kill [test/test_child.rb:113]:
POSIX::Spawn::MaximumOutputExceeded expected but nothing was raised.

  4) Failure:
ChildTest#test_max_with_partial_output [test/test_child.rb:135]:
POSIX::Spawn::MaximumOutputExceeded expected but nothing was raised.

  5) Failure:
ChildTest#test_max [test/test_child.rb:92]:
POSIX::Spawn::MaximumOutputExceeded expected but nothing was raised.

  6) Failure:
ChildTest#test_max_with_child_hierarchy [test/test_child.rb:106]:
POSIX::Spawn::MaximumOutputExceeded expected but nothing was raised.

I am not super familiar with the project and these may already be known issues.

Additionally, the benchmarks seem to run without issue.

benchmarking fork/exec vs. posix_spawn over 1000 runs at 100M res
                                               user     system      total        real
fspawn (fork/exec):                        0.025123   0.284463   1.182938 (  1.492710)
pspawn (posix_spawn):                      0.011391   0.393620   0.833269 (  0.944768)
spawn (native):                            0.020049   0.270129   0.903074 (  1.162991)

Let me know if I can help move this along. I am on MacOS Sonoma 14.4, M1

@casperisfine
Copy link
Author

@dtaivpp just FYI, posix-spawn usefulness with modern rubies is rather limited. A long time ago Ruby started using vfork to spawn sub processes, which is essentially the same thing posix-spawn does.

THe only exception to that is if you are running as root, Ruby de-optimize to use regular fork.

All this to say, unless some other gem cause you this hard dependency, the best course of action is likely to just stop using posix-spawn. I only submitted the PR because it was easy in case it was helpful for others.

@dtaivpp
Copy link

dtaivpp commented Mar 27, 2024

@casperisfine thanks for the context. jekyll-last-modified-at depends on it and looks to be unmaintained so I was hoping to find a fix here. Maybe I should look to see if someone has a replacement for it at this point though. 😐

Thanks for the info as well!

@casperisfine
Copy link
Author

As short term you can point your gemfile at this PR:

gem "posix-spawn", github: "https://github.com/rtomayko/posix-spawn/pull/93"

NB: make sure you don't have a git_source(:github) { |repo| "https://github.com/#{repo}.git" } line in your Gemfile, if you do, just delete it.

@ThisIsMissEm
Copy link

This worked for me on clang 15.0.0 (clang-1500.3.9.4) on arm64-apple-darwin23.5.0, and also for a coworker on archlinux.

@sol2070
Copy link

sol2070 commented Aug 9, 2024

I was having problems on Arch Linux after Ruby updated to 3.2.0.

gem "posix-spawn", github: "https://github.com/rtomayko/posix-spawn/pull/93"

This worked! Thanks!

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.

5 participants