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 build error in Ruby 3.0 on macOS #135

Merged
merged 1 commit into from
Dec 23, 2020
Merged

Fix build error in Ruby 3.0 on macOS #135

merged 1 commit into from
Dec 23, 2020

Conversation

yoshoku
Copy link
Contributor

@yoshoku yoshoku commented Dec 19, 2020

I failed to install rice gem on Ruby 3.0 on macOS 11.1.

$ ruby -v
ruby 3.0.0preview2 (2020-12-08 master d7a16670c3) [x86_64-darwin20]
$ gem install rice
Building native extensions. This could take a while...

...

checking for ruby.h... no
configure: error: could not find ruby.h (check config.log)

Makefile not found

...

I checked config.log and found that it was due to the used of __declspec in Ruby 3.

In file included from conftest.cpp:14:
In file included from /Users/foo/.anyenv/envs/rbenv/versions/3.0.0-preview2/include/ruby-3.0.0/ruby.h:31:
In file included from /Users/foo/.anyenv/envs/rbenv/versions/3.0.0-preview2/include/ruby-3.0.0/ruby/ruby.h:23:
In file included from /Users/foo/.anyenv/envs/rbenv/versions/3.0.0-preview2/include/ruby-3.0.0/ruby/defines.h:74:
In file included from /Users/foo/.anyenv/envs/rbenv/versions/3.0.0-preview2/include/ruby-3.0.0/ruby/backward/2/attributes.h:43:
In file included from /Users/foo/.anyenv/envs/rbenv/versions/3.0.0-preview2/include/ruby-3.0.0/ruby/internal/attr/pure.h:25:
/Users/foo/.anyenv/envs/rbenv/versions/3.0.0-preview2/include/ruby-3.0.0/ruby/assert.h:132:1: 
error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
RBIMPL_ATTR_NORETURN()
^
/Users/foo/.anyenv/envs/rbenv/versions/3.0.0-preview2/include/ruby-3.0.0/ruby/internal/attr/noreturn.h:29:33: 
note: expanded from macro 'RBIMPL_ATTR_NORETURN'
# define RBIMPL_ATTR_NORETURN() __declspec(noreturn)

Therefore, I have added -fdeclspec to CPPFLAGS in extconf.rb for Ruby 3.0 on macOS.
I have confirmed that the build is successful.

@jasonroelofs
Copy link
Collaborator

Need to get my system up to Big Sur myself, but this looks fine. Thanks for the fix!

@jasonroelofs jasonroelofs merged commit 377acde into ruby-rice:master Dec 23, 2020
@yoshoku yoshoku deleted the fix_ruby3_darwin branch December 24, 2020 03:38
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.

2 participants