ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: nobu@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:103365] [Ruby master Bug#16651] Extensions Do Not Compile on Mingw64 with mingw64-make
Date: Sat, 10 Apr 2021 06:18:10 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-91456.20210410061809.91@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16651.20200224065537.91@ruby-lang.org

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


Building io-console with 2.7.2 from RubyInstaller:
```
$ ruby -v ../src/ext/io/console/extconf.rb
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32]
checking for HAVE_RUBY_FIBER_SCHEDULER_H... no
checking for rb_scheduler_timeout()... no
creating Makefile

$ grep -e ^topdir -e ^arch_hdrdir Makefile
topdir = /C/Ruby27-x64/include/ruby-2.7.0
arch_hdrdir = C:/Ruby27-x64/include/ruby-2.7.0/x64-mingw32

$ make
compiling ../src/ext/io/console/console.c
linking shared-object io/console.so
```
It succeeds with no problem.

`/C/` is not wrong in msys make, I'm not sure why the first description had the wrong path without the leading slash.

----------------------------------------
Bug #16651: Extensions Do Not Compile on Mingw64 with mingw64-make
https://bugs.ruby-lang.org/issues/16651#change-91456

* Author: cfis (Charlie Savage)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
When mkmf.rb creates a Makefile for an extension, it will generate something that looks like this:

```makefile
srcdir = .
topdir = C/MSYS64/USR/LOCAL/ruby-2.7.0/include/ruby-2.7.0
hdrdir = $(topdir)
arch_hdrdir = C:/MSYS64/USR/LOCAL/ruby-2.7.0/include/ruby-2.7.0/x64-mingw32
```

Notice the topdir path is c/ without the ":" Its only the topdir that does this, all other paths in the makefile use the "c:/" style.

mkmf.rb intentionally does that, see line 1098:

```ruby
      def mkintpath(path)
        # mingw uses make from msys and it needs special care
        # converts from C:\some\path to /C/some/path
        path = path.dup
        path.tr!('\\', '/')
        path.sub!(/\A([A-Za-z]):(?=\/)/, '/\1') <-------- This line
        path
      end
```

But this is wrong, and causes errors like this (this is compiling the debase gem but it doesn't matter what c extension you use):

```
make: *** No rule to make target 'C/MSYS64/USR/LOCAL/ruby-2.7.0/include/ruby-2.7.0/ruby.h', needed by 'breakpoint.o'.  Stop.
```

The fix is simple, just delete that line. The makefile should look like this:

```makefile
srcdir = .
topdir = C:/MSYS64/USR/LOCAL/ruby-2.7.0/include/ruby-2.7.0
hdrdir = $(topdir)
arch_hdrdir = C:/MSYS64/USR/LOCAL/ruby-2.7.0/include/ruby-2.7.0/x64-mingw32
```

Note I'm not the first person to see this, but I've just been manually fixing it over the years. Would be good to really fix it.

https://github.com/oneclick/rubyinstaller2/issues/105
https://github.com/oneclick/rubyinstaller2/issues/47
https://github.com/tmm1/http_parser.rb/issues/55

Note some of those tickets put the blame on using mingw-make versus msys make. But on my system, neither work with the "c/" style path but both work with the "c:/" style path.




-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2021-04-10  6:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-24  6:55 [ruby-core:97248] [Ruby master Bug#16651] Extensions Do Not Compile on Mingw64 cfis
2020-09-04  8:25 ` [ruby-core:99919] " cfis
2020-10-29  6:34 ` [ruby-core:100639] " cfis
2020-10-29  9:48 ` [ruby-core:100640] " nobu
2021-02-06  8:27 ` [ruby-core:102408] " cfis
2021-02-15 21:07 ` [ruby-core:102509] " cfis
2021-04-02  8:45 ` [ruby-core:103174] " cfis
2021-04-02 10:55 ` [ruby-core:103177] " xtkoba+ruby
2021-04-08  6:28 ` [ruby-core:103294] " cfis
2021-04-08 20:31 ` [ruby-core:103316] [Ruby master Bug#16651] Extensions Do Not Compile on Mingw64 with mingw64-make xtkoba+ruby
2021-04-09  7:35 ` [ruby-core:103335] " cfis
2021-04-09 10:05 ` [ruby-core:103340] " nobu
2021-04-09 22:18 ` [ruby-core:103359] " xtkoba+ruby
2021-04-10  6:18 ` nobu [this message]
2021-04-11 13:02 ` [ruby-core:103385] [Ruby master Bug#16651] Extensions Do Not Compile on Mingw64 with mingw32-make nobu
2021-04-23  4:23 ` [ruby-core:103570] " cfis
2021-05-22  7:28 ` [ruby-core:103969] " nagachika00

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-91456.20210410061809.91@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).