[ruby-core:88318] [Ruby trunk Bug#14964] [MJIT] missing builtin methods

From: takashikkbn@...
Date: 2018-08-06 23:54:20 UTC
List: ruby-core #88318
Issue #14964 has been updated by k0kubun (Takashi Kokubun).


> ARCH_FLAG="-march=barcelona" works, but it isn't propagated to CFLAGS, so it doesn't have the desired effect. I think setting CFLAGS directly shouln't be a problem.
> maybe march option should be ignored when building the mjit header and for some reason MSYS1 used it?

See also: https://github.com/ruby/ruby/blob/24daf1400b5336eb22c50f4e4b4915345b6b4283/Makefile.in#L67-L68
While unfortunately I actually don't know well about Ruby's build system and I may be giving wrong instructions to you, but ARCH_FLAG should be propagated to CFLAGS according to that part.
And, since current MJIT's build pipeline deals with arch flags specially, using it in a wrong way may result in a build failure.

Could you try `./configure --with-arch="barcelona"` as well? As far as I can see from `./configure --help`, "--with-arch" looks the correct way to specify architecture. Also, could you share the output of `env` command and the full exact commands you're using for `./configure ...` and `mingw32-make ...`?

> MSYS1 isn't supported anymore and if it works properly on MSYS2, this can be closed.

I'm trying to support platforms in https://github.com/ruby/ruby/blob/trunk/doc/contributing.rdoc#platform-maintainers, and I believe your environment is included in mingw32.

Since I have only x86_64 Linux, x86_64 macOS and x86_64 Windows (msys2/MinGW and VC++) machines, only these platforms have a direct support by me. I debug other platforms indirectly by mailing list like this. So whether msys1 is supported or not will be effectively decided by this thread.

----------------------------------------
Bug #14964: [MJIT] missing builtin methods
https://bugs.ruby-lang.org/issues/14964#change-73348

* Author: ahorek (Pavel Rosick箪)
* Status: Open
* Priority: Normal
* Assignee: k0kubun (Takashi Kokubun)
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I'm having trouble building Ruby 2.6 on Windows.

this is the first error:
```
building rb_mjit_header.h
rb_mjit_header.h updated
building .ext/include/x64-mingw32/rb_mjit_min_header-2.6.0.h
./miniruby.exe -I../ruby_2_6/lib -I. -I.ext/common  ../ruby_2_6/tool/transform_mjit_header.rb "x86_64-w64-mingw32-gcc " rb_mjit_header.h .ext/include/x64-mingw32/rb_mjit_min_header-2.6.0.h
error in initial header file:
C:/Users/pdaho/AppData/Local/Temp/20180805-10076-12b1zho.c:1: warning: "__STDC__" redefined
 #define __STDC__ 1

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-10076-12b1zho.c:2: warning: "__STDC_VERSION__" redefined
 #define __STDC_VERSION__ 201710L

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-10076-12b1zho.c:3: warning: "__STDC_UTF_16__" redefined
 #define __STDC_UTF_16__ 1

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-10076-12b1zho.c:4: warning: "__STDC_UTF_32__" redefined
 #define __STDC_UTF_32__ 1

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-10076-12b1zho.c:5: warning: "__STDC_HOSTED__" redefined
 #define __STDC_HOSTED__ 1

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-10076-12b1zho.c:29: warning: "__BIGGEST_ALIGNMENT__" redefined
 #define __BIGGEST_ALIGNMENT__ 32

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-10076-12b1zho.c: In function '__crc32b':
C:/Users/pdaho/AppData/Local/Temp/20180805-10076-12b1zho.c:6216:10: error: implicit declaration of function '__builtin_ia32_crc32qi'; did you mean '__builtin_ia32_rolqi'? [-Werror=implicit-function-declaration]
   return __builtin_ia32_crc32qi (__C, __V);
          ^~~~~~~~~~~~~~~~~~~~~~
          __builtin_ia32_rolqi
compilation terminated due to -Wfatal-errors.
cc1.exe: some warnings being treated as errors
make: *** [.ext/include/x64-mingw32/rb_mjit_min_header-2.6.0.h] Error 1
rm x64-msvcrt-ruby260.rc
rake aborted!
```

I tried various CFLAGS, it looks like -mcrc32 helped
```
building rb_mjit_header.h
rb_mjit_header.h updated
building .ext/include/x64-mingw32/rb_mjit_min_header-2.6.0.h
./miniruby.exe -I../ruby_2_6/lib -I. -I.ext/common  ../ruby_2_6/tool/transform_mjit_header.rb "x86_64-w64-mingw32-gcc " rb_mjit_header.h .ext/include/x64-mingw32/rb_mjit_min_header-2.6.0.h
error in initial header file:
C:/Users/pdaho/AppData/Local/Temp/20180805-1196-12y4d1j.c:1: warning: "__STDC__" redefined
 #define __STDC__ 1

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-1196-12y4d1j.c:2: warning: "__STDC_VERSION__" redefined
 #define __STDC_VERSION__ 201710L

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-1196-12y4d1j.c:3: warning: "__STDC_UTF_16__" redefined
 #define __STDC_UTF_16__ 1

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-1196-12y4d1j.c:4: warning: "__STDC_UTF_32__" redefined
 #define __STDC_UTF_32__ 1

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-1196-12y4d1j.c:5: warning: "__STDC_HOSTED__" redefined
 #define __STDC_HOSTED__ 1

<built-in>: note: this is the location of the previous definition
C:/Users/pdaho/AppData/Local/Temp/20180805-1196-12y4d1j.c: In function '_mm_stream_sd':
C:/Users/pdaho/AppData/Local/Temp/20180805-1196-12y4d1j.c:9317:3: error: implicit declaration of function '__builtin_ia32_movntsd'; did you mean '__builtin_ia32_movntpd'? [-Werror=implicit-function-declaration]
   __builtin_ia32_movntsd (__P, (__v2df) __Y);
   ^~~~~~~~~~~~~~~~~~~~~~
   __builtin_ia32_movntpd
compilation terminated due to -Wfatal-errors.
cc1.exe: some warnings being treated as errors
make: *** [.ext/include/x64-mingw32/rb_mjit_min_header-2.6.0.h] Error 1
rm x64-msvcrt-ruby260.rc
rake aborted!
```
I tried to add -march=barcelona -mtune=barcelona -msse4a as the gcc documentation says, but it didn't help. It looks like these instruction are SSE4a specific and some headers are missing.

rev. https://github.com/ruby/ruby/commit/88975c821c99b852959958e2934de68a45be15e6
Windows 10 64bit, x86_64-w64-mingw32
GCC 7.2.0 - http://downloads.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.2.0/threads-win32/seh
AMD FX-8300 8C

I can compile the lastest Ruby 2.5.1 with the same options.

Is it a known problem? Maybe GCC isn't supported on Windows yet?

---Files--------------------------------
mjitheaders.zip (1.31 MB)
diff.diff (3.65 KB)
rb_mjit_header_msys2.zip (673 KB)
diff_msys2.diff (1.75 MB)


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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next