ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
@ 2024-01-05 10:53 byroot (Jean Boussier) via ruby-core
  2024-01-05 12:58 ` [ruby-core:116029] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-01-05 10:53 UTC (permalink / raw
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20152 has been reported by byroot (Jean Boussier).

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116029] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
@ 2024-01-05 12:58 ` nobu (Nobuyoshi Nakada) via ruby-core
  2024-01-05 13:29 ` [ruby-core:116030] " byroot (Jean Boussier) via ruby-core
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2024-01-05 12:58 UTC (permalink / raw
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #20152 has been updated by nobu (Nobuyoshi Nakada).


byroot (Jean Boussier) wrote:
> It would be very useful to have some proper first class API to skip compiling the extension. 
> 
> Something like:
> 
> ```ruby
> require "mkmf"
> 
> if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
>   skip_compilation
> else
>   # ...
> end
> ```

Where will this be used?

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106024

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116030] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
  2024-01-05 12:58 ` [ruby-core:116029] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2024-01-05 13:29 ` byroot (Jean Boussier) via ruby-core
  2024-01-05 16:03 ` [ruby-core:116032] " byroot (Jean Boussier) via ruby-core
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-01-05 13:29 UTC (permalink / raw
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20152 has been updated by byroot (Jean Boussier).


> Where will this be used?

I'm not sure I understand the question. 

This would be called in `extconf.rb`

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106025

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116032] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
  2024-01-05 12:58 ` [ruby-core:116029] " nobu (Nobuyoshi Nakada) via ruby-core
  2024-01-05 13:29 ` [ruby-core:116030] " byroot (Jean Boussier) via ruby-core
@ 2024-01-05 16:03 ` byroot (Jean Boussier) via ruby-core
  2024-01-05 16:06 ` [ruby-core:116033] " kddnewton (Kevin Newton) via ruby-core
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-01-05 16:03 UTC (permalink / raw
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20152 has been updated by byroot (Jean Boussier).


In case you meant which gems would use this, then I think the 3 I listed as example would make a good use of it, and I'm certain there are some more that are in similar cases.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106029

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116033] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (2 preceding siblings ...)
  2024-01-05 16:03 ` [ruby-core:116032] " byroot (Jean Boussier) via ruby-core
@ 2024-01-05 16:06 ` kddnewton (Kevin Newton) via ruby-core
  2024-01-06  7:43 ` [ruby-core:116051] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2024-01-05 16:06 UTC (permalink / raw
  To: ruby-core; +Cc: kddnewton (Kevin Newton)

Issue #20152 has been updated by kddnewton (Kevin Newton).


Prism would use this as well: https://github.com/ruby/prism/blob/829ac0ed3f449313584aae35db98fd7614eb9d63/ext/prism/extconf.rb#L47-L56

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106030

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116051] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (3 preceding siblings ...)
  2024-01-05 16:06 ` [ruby-core:116033] " kddnewton (Kevin Newton) via ruby-core
@ 2024-01-06  7:43 ` nobu (Nobuyoshi Nakada) via ruby-core
  2024-01-06  8:50 ` [ruby-core:116052] " byroot (Jean Boussier) via ruby-core
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2024-01-06  7:43 UTC (permalink / raw
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #20152 has been updated by nobu (Nobuyoshi Nakada).


byroot (Jean Boussier) wrote in #note-2:
> This would be called in `extconf.rb`

Does `skip_compilation` just make a Makefile does nothing?
Then it won't be able to fix the issue that `make` is needed, since `make` is called outside `extconf.rb`.


----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106048

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116052] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (4 preceding siblings ...)
  2024-01-06  7:43 ` [ruby-core:116051] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2024-01-06  8:50 ` byroot (Jean Boussier) via ruby-core
  2024-01-06 12:00 ` [ruby-core:116054] " Eregon (Benoit Daloze) via ruby-core
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-01-06  8:50 UTC (permalink / raw
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20152 has been updated by byroot (Jean Boussier).


> Does skip_compilation just make a Makefile does nothing?

I don't know, I'm unfamiliar with the internals of `mkmf` and not well versed in all this tooling.

I'm just requesting the capability of skipping compilation from `extconf.rb`, not prescribing an implementation nor a specific API.

If you want a specific implementation plan, I can look into it.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106049

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116054] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (5 preceding siblings ...)
  2024-01-06  8:50 ` [ruby-core:116052] " byroot (Jean Boussier) via ruby-core
@ 2024-01-06 12:00 ` Eregon (Benoit Daloze) via ruby-core
  2024-01-06 13:51 ` [ruby-core:116055] " byroot (Jean Boussier) via ruby-core
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2024-01-06 12:00 UTC (permalink / raw
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #20152 has been updated by Eregon (Benoit Daloze).


This is not something mkmf can do on its own, it would need changes in RubyGems, and it seems not so easy for RubyGems to know.

When one uses `spec.extensions  = ["ext/mygem/extconf.rb"]` in a `.gemspec` file, RubyGems will:
1. Run `ruby -rmkmf ext/mygem/extconf.rb`.
2. Run `make` in `ext/mygem`.

Maybe RubyGems could recognize dummy Makefiles like the one created with `File.write("Makefile", dummy_makefile($srcdir).join(""))` which is the most common pattern?
A bit hacky, but it would address the problem with very few changes.

`File.write("Makefile", dummy_makefile($srcdir).join(""))` is already used in many gems: https://github.com/search?q=language%3ARuby+dummy_makefile%28%24srcdir%29.join&type=code
But a shorter variant could be nice, e.g. `create_dummy_makefile` that does the same as `File.write("Makefile", dummy_makefile($srcdir).join(""))`.

OTOH, IMO it's not a big ask for devs/users to install `make` when they are installing gems.
If devs/users really want to cut dependencies in production they can and should install gems in a separate Docker image than the runtime one (already necessary e.g. for CRuby & TruffleRuby if ones wants to not ship a `cc` in the final image, [example](https://github.com/graalvm/container/blob/2a8e138fe0b0200a80a7addddedf186b5ff74192/truffleruby-community/README.md#multi-stage-build-for-the-no-toolchain-images)).
Also one might need `make` anyway, e.g. for gems used via FFI like sassc and prism, where make is used to build the C code (which does not include `ruby.h`).
So trying to avoid needing make on JRuby seems very niche to me.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106051

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116055] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (6 preceding siblings ...)
  2024-01-06 12:00 ` [ruby-core:116054] " Eregon (Benoit Daloze) via ruby-core
@ 2024-01-06 13:51 ` byroot (Jean Boussier) via ruby-core
  2024-01-06 21:38 ` [ruby-core:116057] " kou (Kouhei Sutou) via ruby-core
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-01-06 13:51 UTC (permalink / raw
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20152 has been updated by byroot (Jean Boussier).


> This is not something mkmf can do on its own, it would need changes in RubyGems

Thanks for the info, as I said, I'm quite unfamiliar with how these pieces fit together.

> Maybe RubyGems could recognize dummy Makefiles

Or look for a specially named file? This way `mkmf` could just create that file and move on?

> OTOH, IMO it's not a big ask for devs/users to install make when they are installing gems.

On UNIX systems it's not, but on Windows it start to be a bit more complicated.

> So trying to avoid needing make on JRuby seems very niche to me.

I honestly don't mind it that much, but it's true that if the end the Makefile does nothing, we might as well not require make, would be nicer.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106052

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116057] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (7 preceding siblings ...)
  2024-01-06 13:51 ` [ruby-core:116055] " byroot (Jean Boussier) via ruby-core
@ 2024-01-06 21:38 ` kou (Kouhei Sutou) via ruby-core
  2024-01-07  0:10 ` [ruby-core:116058] " jeremyevans0 (Jeremy Evans) via ruby-core
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: kou (Kouhei Sutou) via ruby-core @ 2024-01-06 21:38 UTC (permalink / raw
  To: ruby-core; +Cc: kou (Kouhei Sutou)

Issue #20152 has been updated by kou (Kouhei Sutou).


byroot (Jean Boussier) wrote in #note-8:

> > OTOH, IMO it's not a big ask for devs/users to install make when they are installing gems.
> 
> On UNIX systems it's not, but on Windows it start to be a bit more complicated.

Really? https://rubyinstaller.org/ provides MSYS2 integration by "Devkit". It provides `make`.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106055

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116058] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (8 preceding siblings ...)
  2024-01-06 21:38 ` [ruby-core:116057] " kou (Kouhei Sutou) via ruby-core
@ 2024-01-07  0:10 ` jeremyevans0 (Jeremy Evans) via ruby-core
  2024-01-08 13:30 ` [ruby-core:116064] " Eregon (Benoit Daloze) via ruby-core
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2024-01-07  0:10 UTC (permalink / raw
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #20152 has been updated by jeremyevans0 (Jeremy Evans).


nobu (Nobuyoshi Nakada) wrote in #note-5:
> byroot (Jean Boussier) wrote in #note-2:
> > This would be called in `extconf.rb`
> 
> Does `skip_compilation` just make a Makefile does nothing?
> Then it won't be able to fix the issue that `make` is needed, since `make` is called outside `extconf.rb`.

I agree that this isn't a `mkmf`/`extconf.rb` issue.  This is a rubygems issue.  I think the easiest way to fix this would be for rubygems to check for a `skip-compilation-RUBY_ENGINE` file in the same directory as `extconf.rb`.  If it exists, do not run `extconf.rb` or `make`.  If it exists after calling `extconf.rb`, do not call `make`.  This fixes cases where an extension is not needed for a certain engine, as well as cases where an extension is not needed in certain configurations, such as when a pure-ruby implementation is also shipped in the same gem, and a native library necessary for the native extension is not available.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106056

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116064] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (9 preceding siblings ...)
  2024-01-07  0:10 ` [ruby-core:116058] " jeremyevans0 (Jeremy Evans) via ruby-core
@ 2024-01-08 13:30 ` Eregon (Benoit Daloze) via ruby-core
  2024-01-08 14:11 ` [ruby-core:116066] " byroot (Jean Boussier) via ruby-core
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2024-01-08 13:30 UTC (permalink / raw
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #20152 has been updated by Eregon (Benoit Daloze).


jeremyevans0 (Jeremy Evans) wrote in #note-10:
> I agree that this isn't a `mkmf`/`extconf.rb` issue.  This is a rubygems issue.  I think the easiest way to fix this would be for rubygems to check for a `skip-compilation-RUBY_ENGINE` file in the same directory as `extconf.rb`.  If it exists, do not run `extconf.rb` or `make`.  If it exists after calling `extconf.rb`, do not call `make`.  This fixes cases where an extension is not needed for a certain engine, as well as cases where an extension is not needed in certain configurations, such as when a pure-ruby implementation is also shipped in the same gem, and a native library necessary for the native extension is not available.

I think `skip-compilation-RUBY_ENGINE` is going too far and counter-productive.
For instance I have seen some C extensions in gems which realistically will only work on CRuby (e.g. depends on CRuby deep internals, on CRuby bytecode, optimization only profitable on CRuby, etc), in that case we'd want to avoid the extension on any `RUBY_ENGINE != "ruby"`, so a `skip-compilation-RUBY_ENGINE` would not help.

There could be a `skip-make`/`skip-compilation` or so file which does not include `RUBY_ENGINE` in the filename and is created dynamically by the `extconf.rb`, but this will take a lot longer to get adopted, as it means each gem skipping compilation would need to use that.
But it is error-prone, because e.g. then if one builds (e.g. `rake compile`) a gem locally on JRuby and then on CRuby then compilation will be unexpectedly skipped on CRuby, unless the code also takes care of removing that file (I guess mkmf create_makefile could remove it, it seems too annoying if `extconf.rb` or `Rakefile` needs to remove it manually).

OTOH if we detect the `dummy_makefile` pattern, it's immediately picked up as soon as that RubyGems change is in, and JRuby could even cherry-pick it sooner if they care enough about it.
That is why I think this is the best solution as it solves it with very few changes and faster.

Another possibility would be if there is no Makefile created by extconf.rb, then RubyGems would not call `make` (`make` in a dir with no Makefile is an error so we cannot just use that).
It's very simple and I think rather intuitive.
And extconf.rb could just e.g. `return if RUBY_ENGINE == "jruby"/RUBY_ENGINE != "ruby"/...` at the top.
A concern is if one builds (e.g. `rake compile`) a gem locally on CRuby and then on JRuby.
But `rake clean` should already remove the Makefile and so that seems no problem.
It is already expected and necessary that one needs to `rake clean` when switching Rubies before `rake compile`.

kou (Kouhei Sutou) wrote in #note-9:
> Really? https://rubyinstaller.org/ provides MSYS2 integration by "Devkit". It provides `make`.

It's mostly relevant for JRuby, it's basically not relevant for CRuby (where it's very common to have non-precompiled native extensions, like `erb`).

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106062

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116066] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (10 preceding siblings ...)
  2024-01-08 13:30 ` [ruby-core:116064] " Eregon (Benoit Daloze) via ruby-core
@ 2024-01-08 14:11 ` byroot (Jean Boussier) via ruby-core
  2024-01-09 14:40 ` [ruby-core:116119] " vo.x (Vit Ondruch) via ruby-core
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-01-08 14:11 UTC (permalink / raw
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20152 has been updated by byroot (Jean Boussier).


> Another possibility would be if there is no Makefile created by extconf.rb, then RubyGems would not call make 

I quite like that one.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106063

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116119] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (11 preceding siblings ...)
  2024-01-08 14:11 ` [ruby-core:116066] " byroot (Jean Boussier) via ruby-core
@ 2024-01-09 14:40 ` vo.x (Vit Ondruch) via ruby-core
  2024-01-10  9:22 ` [ruby-core:116137] " lloeki (Loic Nageleisen) via ruby-core
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: vo.x (Vit Ondruch) via ruby-core @ 2024-01-09 14:40 UTC (permalink / raw
  To: ruby-core; +Cc: vo.x (Vit Ondruch)

Issue #20152 has been updated by vo.x (Vit Ondruch).


I believe that if something complex is needed, `RakeBuilder` could be used instead:

https://github.com/rubygems/rubygems/blob/master/lib/rubygems/ext/rake_builder.rb

Just FTR, these are currently supported builders:

https://github.com/rubygems/rubygems/blob/8ffa73df3a250623b13c5bf7ab48ed8b8e84e46f/lib/rubygems/ext/builder.rb#L145-L161

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106117

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116137] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (12 preceding siblings ...)
  2024-01-09 14:40 ` [ruby-core:116119] " vo.x (Vit Ondruch) via ruby-core
@ 2024-01-10  9:22 ` lloeki (Loic Nageleisen) via ruby-core
  2024-01-10  9:26 ` [ruby-core:116138] " ivoanjo (Ivo Anjo) via ruby-core
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: lloeki (Loic Nageleisen) via ruby-core @ 2024-01-10  9:22 UTC (permalink / raw
  To: ruby-core; +Cc: lloeki (Loic Nageleisen)

Issue #20152 has been updated by lloeki (Loic Nageleisen).


> I agree that this isn't a mkmf/extconf.rb issue. This is a rubygems issue.

Sounds like so to me as well.

> Maybe RubyGems could recognize dummy Makefiles

Not too fond of that.

>> Another possibility would be if there is no Makefile created by extconf.rb, then RubyGems would not call make

> I quite like that one.

I too, sounds better than the one above.

> Also one might need make anyway, e.g. for gems used via FFI like sassc and prism, where make is used to build the C code

Not necessarily, when platform specific binary gems are available (e.g mini_racer / libv8-node).

The solutions we found in our case was:

- dependent gem has a hard add_runtime_dependency on the dependency. This is a prerequisite of being able to specify the dependency version requirement at gem install/bundle install time.
- provide binary gems, which then inform of feature availability at runtime (something like `MyNamespace.available?` returning `true`)
- the `ruby` platform gem is either one of:
  - a shim, and provides no implementation whatsoever, thus `MyNamespace.available?` returns `false`, which is a bit of a lie since the `ruby` platform is actually not supported
  - sidestep rubygems platform resolution and attempt fetching binary for that binary platform at `gem install` time. if it succeeds `MyNamespace.available?` returns `true` and succeeds `MyNamespace.available?` returns `false`, which is sad as it breaks the common "install does network but does not execute" and "build executes but does not do network" expectation.
  - able to compile from C/Rust source, but limit to a set list of platforms in `extconf.rb` and otherwise produce a dummy Makefile
  - able to compile from C/Rust source, if compilation succeeds `MyNamespace.available?` will return `true` but if compilation fails the result is swallowed, a warning is printed, and `MyNamespace.available?` will return `false`

This is all mandated by ruby gems being unable to declare optional dependencies in gemspecs:

```
  s.add_runtime_dependency, foo, '~> 1.1', optional: true
```

Which would mean that if `foo` is present in the bundle it must be `['>= 1.1', '< 2.0.a']` but if it's not in GEM_HOME / in Gemfile / does not resolve that's okay, for which there are two sides to the coin: dependency is not installed at all or dependency failed to install.

The only way to work around that is at runtime, well after dependency resolution / gem install time:

- have the hard dependency as above, ignore compilation failure / have a ruby platform shim gem, and check for availability at runtime
- not have the hard dependency, and hopefully do the optional gem version check at runtime, duplicating rubygems/bundler dependency resolution (badly)

Note that I'm not positing the above as a solution, merely that it seems to me that it hints at the requirement on creating dummy Makefiles that do nothing might indeed be a deeper rubygems limitation moving a dependency resolution problem to be solved by either build time or runtime hacks.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106143

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116138] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (13 preceding siblings ...)
  2024-01-10  9:22 ` [ruby-core:116137] " lloeki (Loic Nageleisen) via ruby-core
@ 2024-01-10  9:26 ` ivoanjo (Ivo Anjo) via ruby-core
  2024-01-10 10:04 ` [ruby-core:116141] " byroot (Jean Boussier) via ruby-core
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: ivoanjo (Ivo Anjo) via ruby-core @ 2024-01-10  9:26 UTC (permalink / raw
  To: ruby-core; +Cc: ivoanjo (Ivo Anjo)

Issue #20152 has been updated by ivoanjo (Ivo Anjo).


+1 this would be useful for the ddtrace gem as well, we also do the "if (a bunch of conditions) generate an empty makefile" [dance](https://github.com/DataDog/dd-trace-rb/blob/fd56a11a252f5887b31b783f96fc8505b74b703c/ext/ddtrace_profiling_native_extension/extconf.rb#L10).

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106144

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116141] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (14 preceding siblings ...)
  2024-01-10  9:26 ` [ruby-core:116138] " ivoanjo (Ivo Anjo) via ruby-core
@ 2024-01-10 10:04 ` byroot (Jean Boussier) via ruby-core
  2024-01-10 10:19 ` [ruby-core:116144] " Eregon (Benoit Daloze) via ruby-core
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-01-10 10:04 UTC (permalink / raw
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20152 has been updated by byroot (Jean Boussier).


I tried implementing this idea in `rubygems` https://github.com/rubygems/rubygems/pull/7372.

I still think it would be nice for `mkmf` to provide a `skip_compilation` helper that would generate the dummy makefile (for backward compatibility?) and create the skip file.



----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106146

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116144] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (15 preceding siblings ...)
  2024-01-10 10:04 ` [ruby-core:116141] " byroot (Jean Boussier) via ruby-core
@ 2024-01-10 10:19 ` Eregon (Benoit Daloze) via ruby-core
  2024-01-10 11:39 ` [ruby-core:116149] " byroot (Jean Boussier) via ruby-core
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2024-01-10 10:19 UTC (permalink / raw
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #20152 has been updated by Eregon (Benoit Daloze).


> Another possibility would be if there is no Makefile created by extconf.rb, then RubyGems would not call make

One problem with that though is it would not work on older RubyGems, so if any gem uses that it would fail on existing Ruby releases, which kinda makes it useless unfortunately (at least short term).

That's why I like detecting the dummy makefile approach so much, because it's harmless on existing Ruby releases, it helps immediately for newer Ruby releases/newer RubyGems and even requires no changes in gems (which takes a while and might not work for older RubyGems).

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106149

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116149] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (16 preceding siblings ...)
  2024-01-10 10:19 ` [ruby-core:116144] " Eregon (Benoit Daloze) via ruby-core
@ 2024-01-10 11:39 ` byroot (Jean Boussier) via ruby-core
  2024-01-10 12:04 ` [ruby-core:116150] " lloeki (Loic Nageleisen) via ruby-core
  2024-01-24  6:18 ` [ruby-core:116392] " headius (Charles Nutter) via ruby-core
  19 siblings, 0 replies; 21+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-01-10 11:39 UTC (permalink / raw
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20152 has been updated by byroot (Jean Boussier).


I don't think it makes it useless. For now gems can do both (dummy makefile and `skip-build` file).

And in a few years, as older versions become deprecated, we'll be able to only do the `skip-build`.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106154

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116150] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (17 preceding siblings ...)
  2024-01-10 11:39 ` [ruby-core:116149] " byroot (Jean Boussier) via ruby-core
@ 2024-01-10 12:04 ` lloeki (Loic Nageleisen) via ruby-core
  2024-01-24  6:18 ` [ruby-core:116392] " headius (Charles Nutter) via ruby-core
  19 siblings, 0 replies; 21+ messages in thread
From: lloeki (Loic Nageleisen) via ruby-core @ 2024-01-10 12:04 UTC (permalink / raw
  To: ruby-core; +Cc: lloeki (Loic Nageleisen)

Issue #20152 has been updated by lloeki (Loic Nageleisen).


There's [`spec.required_rubygems_version`](https://guides.rubygems.org/specification-reference/#required_rubygems_version) to enforce compatibility. On rubygems versions before the feature a dependency would then resolve to the last one non-compatible with compilation skipping.

Agreed that Benoit's approach could be a transitional solution to maintain backwards compatibility while introducing the feature in short order.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106155

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:116392] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension
  2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
                   ` (18 preceding siblings ...)
  2024-01-10 12:04 ` [ruby-core:116150] " lloeki (Loic Nageleisen) via ruby-core
@ 2024-01-24  6:18 ` headius (Charles Nutter) via ruby-core
  19 siblings, 0 replies; 21+ messages in thread
From: headius (Charles Nutter) via ruby-core @ 2024-01-24  6:18 UTC (permalink / raw
  To: ruby-core; +Cc: headius (Charles Nutter)

Issue #20152 has been updated by headius (Charles Nutter).


Finally jumping in here. I think this was initiated by me filing an issue on erb to move the C extension out to a separate gem.

Background: JRuby users traditionally have not needed any build tools **whatsoever** to install JRuby and build and run Rails applications. Everything is pre-built for JVM (though that has changed a bit with sassc).

As it existed a few versions ago, the erb gem would unconditionally try to build the C extension it ships with, which meant that JRuby users could not install it. The first fix was to just emit a dummy Makefile on JRuby, which only half fixes it; JRuby users would still have to have `make` installed, even though the build would produce **nothing at all**. 

Let's be honest, the empty-Makefile trick is a hack at best. There should be a way in RubyGems to indicate that the current OS, OS version, ARCH, RUBY_ENGINE, RUBY_VERSION, etc does not need an extension built, so don't try to build it. That obviously applies in this case (Ruby fallback works fine), but it also applies to any gems that want to ship pre-built native libraries with more customization than just OS and ARCH.

I don't have a strong opinion on "skip dummy makefiles" vs "don't try to build" but the former would integrate more easily. There *are* places where we accept that `make` will be needed, like sassc (to build the native library bound in Ruby using FFI), and we would not want to disable `make` for all gems. We just want to fix the ones that really don't need to build, like erb.

----------------------------------------
Feature #20152: mkmf / extconf: Add a proper way to not compile the extension
https://bugs.ruby-lang.org/issues/20152#change-106415

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
### Context

There are various gems that ship with a native extension as a way to speedup part of the gem, but also ship with a pure Ruby version of these methods as a fallback. So they only want to compile the extension if the platform supports it, and if not, just fallback to the slightly slower Ruby version.

Right now users rely on one of two hacks to do this. Either they create an empty Makefile, but then still depend on `make` being available, or publish platform specific packages without any extension in them.

Examples:

  - [`bootsnap` skip compilation if not on MRI or TruffleRuby](https://github.com/Shopify/bootsnap/blob/070151f1305f23102365d6b4476a91c02dead35a/ext/bootsnap/extconf.rb)
  - [`erb` has an extension for MRI but then need to publish a `java` version of the gem that doesn't actually contain Java code, just to skip compilation on JRuby](https://github.com/ruby/erb/issues/52)
  - [`hiredis-client` skips the compilation for Windows and non-MRI rubies](https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/hiredis-client/ext/redis_client/hiredis/extconf.rb#L10-L17)

### Feature

It would be very useful to have some proper first class API to skip compiling the extension. 

Something like:

```ruby
require "mkmf"

if RUBY_ENGINE != "ruby" || RUBY_PLATFORM.match?(/mswin/)
  skip_compilation
else
  # ...
end
```

cc @k0kubun @headius 




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2024-01-24  6:18 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-05 10:53 [ruby-core:116028] [Ruby master Feature#20152] mkmf / extconf: Add a proper way to not compile the extension byroot (Jean Boussier) via ruby-core
2024-01-05 12:58 ` [ruby-core:116029] " nobu (Nobuyoshi Nakada) via ruby-core
2024-01-05 13:29 ` [ruby-core:116030] " byroot (Jean Boussier) via ruby-core
2024-01-05 16:03 ` [ruby-core:116032] " byroot (Jean Boussier) via ruby-core
2024-01-05 16:06 ` [ruby-core:116033] " kddnewton (Kevin Newton) via ruby-core
2024-01-06  7:43 ` [ruby-core:116051] " nobu (Nobuyoshi Nakada) via ruby-core
2024-01-06  8:50 ` [ruby-core:116052] " byroot (Jean Boussier) via ruby-core
2024-01-06 12:00 ` [ruby-core:116054] " Eregon (Benoit Daloze) via ruby-core
2024-01-06 13:51 ` [ruby-core:116055] " byroot (Jean Boussier) via ruby-core
2024-01-06 21:38 ` [ruby-core:116057] " kou (Kouhei Sutou) via ruby-core
2024-01-07  0:10 ` [ruby-core:116058] " jeremyevans0 (Jeremy Evans) via ruby-core
2024-01-08 13:30 ` [ruby-core:116064] " Eregon (Benoit Daloze) via ruby-core
2024-01-08 14:11 ` [ruby-core:116066] " byroot (Jean Boussier) via ruby-core
2024-01-09 14:40 ` [ruby-core:116119] " vo.x (Vit Ondruch) via ruby-core
2024-01-10  9:22 ` [ruby-core:116137] " lloeki (Loic Nageleisen) via ruby-core
2024-01-10  9:26 ` [ruby-core:116138] " ivoanjo (Ivo Anjo) via ruby-core
2024-01-10 10:04 ` [ruby-core:116141] " byroot (Jean Boussier) via ruby-core
2024-01-10 10:19 ` [ruby-core:116144] " Eregon (Benoit Daloze) via ruby-core
2024-01-10 11:39 ` [ruby-core:116149] " byroot (Jean Boussier) via ruby-core
2024-01-10 12:04 ` [ruby-core:116150] " lloeki (Loic Nageleisen) via ruby-core
2024-01-24  6:18 ` [ruby-core:116392] " headius (Charles Nutter) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).