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

An option to use Rubies configured with --mkmf-verbose #505

Closed
junaruga opened this issue May 19, 2023 · 10 comments
Closed

An option to use Rubies configured with --mkmf-verbose #505

junaruga opened this issue May 19, 2023 · 10 comments

Comments

@junaruga
Copy link
Member

The feature to print compiler (e.g. gcc, clang) command lines in the build time of the Ruby native extensions is available on Ruby 3.1 or later versions, that is possible by building Ruby with configure --mkmf-verbose option.

Here is the commit on the ruby/ruby master branch. - ruby/ruby@019cbde

I would like to use the Rubies configured with --mkmf-verbose from the GitHub Actions: ruby/setup-ruby. Because I made this issue of the compiler warnings (-Wundef) printed in ruby/openssl. And the ruby/openssl's GitHub Actions CI didn't print the compiler warnings when I ran the bundle exec rake compile -- --with-cflags='-Wundef' on the CI. So, I would like to see the compiler command lines on the GitHub Actions.

I don't understand how the ruby/setup-ruby works. But seeing the code, the ruby/setup-ruby is calling https://github.com/rbenv/ruby-build.git? And seeing the https://github.com/rbenv/ruby-build, we can manage the configure options by the CONFIGURE_OPTS environment? I am not sure how much hard to implement this, and what are the concerns to add this new feature.

Considering the backward compatibility of the ruby/setup-ruby, I would like that the Rubies configured with --mkmf-verbose is optional, not a default behavior of the ruby/setup-ruby.

What do you think?

In the mean time, as a workaround, I plan to modify the mkmf.rb like this to enable the feature in GitHub Actions.

$ sudo sed -i -E 's/^V = .+/V = 1/' /path/to/mkmf.rb
$ diff mkmf.rb.orig mkmf.rb
1974c1974
< V = #{CONFIG['MKMF_VERBOSE']}
---
> V = 1
@eregon
Copy link
Member

eregon commented May 19, 2023

I don't understand how the ruby/setup-ruby works.

It's in the README early on though and easy to understand when you see it downloads a prebuilt Ruby in the actions log:
https://github.com/ruby/setup-ruby/blob/master/README.md#supported-platforms has the information, notably:

The prebuilt releases are generated by ruby-builder

I will not rebuild all Rubies with this configure flag (it's too much work for too little gain), and we don't support multiple builds of a given Ruby version. And it could be incompatible.

I suggest to make it easier to enable this feature at runtime in ruby/ruby, I don't see why it should be a configure-time option. Maybe it should be an environment variable?

@eregon eregon closed this as not planned Won't fix, can't repro, duplicate, stale May 19, 2023
@junaruga
Copy link
Member Author

junaruga commented May 20, 2023

@eregon Thanks for the info!

I will not rebuild all Rubies with this configure flag (it's too much work for too little gain), and we don't support multiple builds of a given Ruby version. And it could be incompatible.

Yes, it makes sense to me.

I suggest to make it easier to enable this feature at runtime in ruby/ruby, I don't see why it should be a configure-time option. Maybe it should be an environment variable?

I have not noticed the idea to enable this feature at runtime in ruby/ruby until you suggest it. And that makes much more sense. I plan to propose on the Ruby project's ticket and send a pull request to ruby/ruby to add the new feature by adding the MakeMakefile.with_verbose class method. The use is like the existing MakeMakefile.with_cflags. It can be used in the extconf.rb and it can be used also from the rake-compiler gem like this.

$ bundle exec rake compile -- \
  --with-verbose \
  --with-cflags="-Wundef"

The environment variable may be another way to implement this feature. The CONFIGURE_ARGS environment variable is used to modify the configure arguments in the mkmf.rb, and the VERBOSE environment may be the candidate in this feature.

@junaruga
Copy link
Member Author

I don't see why it should be a configure-time option.

As a note, the intent of the ruby/ruby@019cbde was to change the default behavior of the mkmf.rb about the verbose. And the behavior of the default verbose of the mkmf.rb has been applied to the Fedora and the downstream Linux distro Rubies by the downstream patch since Ruby 1.9. And I applied it to the upstream Ruby project by the commit. So, I also plan to keep this feature too.

@eregon
Copy link
Member

eregon commented May 20, 2023

I see, that's fine, I meant it doesn't need to be a configure-time option, it could be a runtime option.

@junaruga
Copy link
Member Author

Okay. By the way, the simple way to enable verbose at runtime in ruby/ruby was found by setting MAKEFLAGS="V=1" below.

$ MAKEFLAGS="V=1" bundle exec rake compile

Here is a PR ruby/openssl#624 using this technique. I saw the MAKEFLAGS="V=1" worked in Linux and macOS. It didn't work in Windows. I don't know why.

So, I canceled to propose and implement the new class method MakeMakefile.with_verbose.

@eregon
Copy link
Member

eregon commented May 24, 2023

I'd guess MAKEFLAGS is gmake-specific

@junaruga
Copy link
Member Author

I see. Do you know which make or a similar tool is used to build a Ruby native extension in Windows?

@eregon
Copy link
Member

eregon commented May 24, 2023

I don't, no. It's probably nmake but potentially other make too

@MSP-Greg
Copy link
Collaborator

Publicly available Windows Rubies (RubyInstaller.org) all use gcc/make.

Windows mswin builds use nmake.

@junaruga
Copy link
Member Author

junaruga commented May 25, 2023

Thanks for the info.

Eventually I was able to implement the feature ruby /path/to/extconf.rb -- --with-verbose (rake compile -- --with-verbose) that I mentioned at #505 (comment). The PR is ruby/ruby#7863.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants