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

Compile on Windows XP (32-bit) fails #36

Closed
MarkDBlackwell opened this issue Dec 24, 2013 · 14 comments
Closed

Compile on Windows XP (32-bit) fails #36

MarkDBlackwell opened this issue Dec 24, 2013 · 14 comments
Milestone

Comments

@MarkDBlackwell
Copy link

Compiling on Windows 7 works (for me). However, on Windows XP, I get 'internal compiler error: Illegal instruction'. The latest version (atomic gem) that installs (for me) is 0.0.4. On the Windows command line:

$ gem install atomic -v '1.1.14' --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing atomic:
ERROR: Failed to build gem native extension.
Check the mkmf.log file for more details.

$ copy C:\progra\ruby\200\p353\lib\ruby\gems\2.0.0\gems\atomic-1.1.14\ext\mkmf.log con:
"gcc -o conftest.exe -IC:/progra/ruby/200/p353/include/ruby-2.0.0/i386-mingw32 -IC:/progra/ruby/200/p353/include/ruby-2.0.0/ruby/backward -IC:/progra/ruby/200/p353/include/ruby-2.0.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -march=native conftest.c -L. -LC:/progra/ruby/200/p353/lib -L. -lmsvcrt-ruby200 -lshell32 -lws2_32 -limagehlp -lshlwapi "
conftest.c:1:0: internal compiler error: Illegal instruction
Please submit a full bug report,
with preprocessed source if appropriate.
See [email protected] for instructions.
checked program was:
/* begin _/
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char *_argv)
6: {
7: return 0;
8: }
/* end */

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.8.2/lto-wrapper.exe
Target: i686-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc4/gcc-4.8.2-2/src/gcc-4.8.2/configure
--srcdir=/cygdrive/i/szsz/tmpp/gcc4/gcc-4.8.2-2/src/gcc-4.8.2 --prefix=/usr --ex
ec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/libexec -
-datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --libdir=/usr/lib --d
atarootdir=/usr/share --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/h
tml -C --build=i686-pc-cygwin --host=i686-pc-cygwin --target=i686-pc-cygwin --wi
thout-libiconv-prefix --without-libintl-prefix --enable-shared --enable-shared-l
ibgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap
--disable-__cxa_atexit --with-dwarf2 --with-arch=i686 --with-tune=generic --disa
ble-sjlj-exceptions --enable-languages=ada,c,c++,fortran,java,lto,objc,obj-c++ -
-enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --di
sable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp -
-enable-libada --enable-libjava --enable-libgcj-sublibs --disable-java-awt --dis
able-symvers --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as
--with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-
libintl-prefix --with-system-zlib --libexecdir=/usr/lib
Thread model: posix
gcc version 4.8.2 (GCC)

$ ruby -v
ruby 2.0.0p353 (2013-11-22) [i386-mingw32]

$ gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 2.1.11
  • RUBY VERSION: 2.0.0 (2013-11-22 patchlevel 353) [i386-mingw32]
  • INSTALLATION DIRECTORY: C:/progra/ruby/200/p353/lib/ruby/gems/2.0.0
  • RUBY EXECUTABLE: C:/progra/ruby/200/p353/bin/ruby.exe
  • EXECUTABLE DIRECTORY: C:/progra/ruby/200/p353/bin
  • SPEC CACHE DIRECTORY: C:/Documents and Settings/Mark/.gem/specs
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86-mingw32
  • GEM PATHS:
    • C:/progra/ruby/200/p353/lib/ruby/gems/2.0.0
    • C:/Documents and Settings/Mark/.gem/ruby/2.0.0
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :backtrace => false
    • :bulk_threshold => 1000
    • "gem" => "--conservative --no-rdoc --no-ri --run-tests"
    • "rdoc" => "--all --inline-source --line-numbers"
  • REMOTE SOURCES:
  • SHELL PATH:
    • C:\WINDOWS\system32
    • C:\WINDOWS
    • C:\WINDOWS\System32\Wbem
    • C:\Program Files\Common Files\Adaptec Shared\System
    • C:\Program Files\Common Files\Adobe\AGL
    • C:\Program Files\Common Files\Teleca Shared
    • C:\Program Files\GTK2-Runtime\lib
    • C:\Program Files\Intel\DMIX
    • C:\Program Files\Medialink\MWN-USB54G
    • C:\Program Files\VDMSound
    • C:\progra\Python32
    • C:\progra\Python32\Lib\site-packages\PyQt4
    • C:\progra\lilypond\current\usr\bin
    • C:\Program Files\git\bin
    • C:\Program Files\git\cmd
    • C:\Program Files\7-Zip
    • C:\Program Files\QuickTime\QTSystem\
    • C:\Program Files\GNU_Denemo\usr\bin
    • C:\progra\ruby\200\p353\bin
    • C:\progra\pik
    • C:\cygwin\bin
@headius headius added this to the atomic-1.1.15 milestone Feb 26, 2014
@headius
Copy link
Owner

headius commented Feb 26, 2014

This may be fixed with #39. Reopen if it is not.

@headius headius closed this as completed Feb 26, 2014
@MarkDBlackwell
Copy link
Author

Reopen if it is not [fixed].

Thanks, but GitHub doesn't seem to have provided me with the ability to reopen it. :)

Version 1.1.15 (on my 32-bit Windows XP) still results in "internal compiler error: Illegal instruction".

I suspect the -D_FILE_OFFSET_BITS=64 compiler option (from mkmf.log, below) may be illegal on my 32-bit machine.

Suggestively, web searching "D_FILE_OFFSET_BITS" produced this StackOverflow answer:

"Compile your programs with "gcc -D_FILE_OFFSET_BITS=64". This forces all file access calls to use the 64 bit variants...For portability with other platforms you should use getconf LFS_CFLAGS which will return -D_FILE_OFFSET_BITS=64 on Linux platforms but might return something else on e.g. Solaris":

If this is the problem (although I'm not a gcc expert), I suspect some way could be found (for atomic) to work on 32-bit machines as well, by providing gcc compiler options which work on both 64 and 32-bit machines. Does this make sense for atomic?

$ gem install atomic -v '1.1.15' --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing atomic:
ERROR: Failed to build gem native extension.
C:/progra/ruby/200/p353/bin/ruby.exe extconf.rb
checking for libkern/OSAtomic.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/progra/ruby/200/p353/bin/ruby
        --with-atomic_reference-dir
        --without-atomic_reference-dir
        --with-atomic_reference-include
        --without-atomic_reference-include=${atomic_reference-dir}/include
        --with-atomic_reference-lib
        --without-atomic_reference-lib=${atomic_reference-dir}/

$ copy C:\progra\ruby\200\p353\lib\ruby\gems\2.0.0\gems\atomic-1.1.15\ext\mkmf.log con:
"gcc -o conftest.exe -IC:/progra/ruby/200/p353/include/ruby-2.0.0/i386-mingw32
-IC:/progra/ruby/200/p353/include/ruby-2.0.0/ruby/backward
-IC:/progra/ruby/200/p353/include/ruby-2.0.0 -I. -DFD_SETSIZE=2048
-D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer
-fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses
-Wno-long-long -Wno-missing-field-initializers -Wunused-variable
-Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement
-Wimplicit-function-declaration conftest.c  -L. -LC:/progra/ruby/200/p353/lib -L.
     -lmsvcrt-ruby200  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
conftest.c:1:0: internal compiler error: Illegal instruction
Please submit a full bug report,
with preprocessed source if appropriate.
See <[email protected]> for instructions.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

@headius
Copy link
Owner

headius commented Feb 27, 2014

That does indeed sound possible, but I'm not very good with Makefiles on Windows. Perhaps @unak knows what we need to do?

@unak
Copy link
Contributor

unak commented Feb 27, 2014

I'm not an expert of gcc, but it seems the problem of mingw's gcc.
Please report it to [email protected].

@MarkDBlackwell
Copy link
Author

it seems the problem of mingw's gcc.
Please report it to [email protected].

Now I have reported it on the RubyInstaller mailing list.

I'll document here what I've learned so far. The command in question (which I'm using on a 32-bit Windows XP) is gem install atomic -v '1.1.15' --platform=ruby.

Interestingly, it worked fine using Ruby 1.9.3 and the 1.9.3 Ruby development kit (for Windows).

At first, after a fresh install (without setting up the Ruby development kit), a minimal example:

$ ruby -v
ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
$ ruby -e"require 'mkmf'; p MakeMakefile::CONFIG['DEFS']"
"-D_FILE_OFFSET_BITS=64"

seemed to reveal a problem involving Ruby 2.0.0 Standard Library's mkmf (for 32-bit machines).

However, on my 32-bit Linux machine with Ruby 2.0.0-p247, the same commands also output "-D_FILE_OFFSET_BITS=64", yet the 1.1.15 gem installed just fine. Therefore that gcc option seems unlikely to be the problem.

@headius headius reopened this Feb 27, 2014
@luislavena
Copy link

@MarkDBlackwell @unak if the problem appears in Ruby 2.0.0, then is a problem with mingw-w64 and not MinGW's version of GCC.

Usage of -D_FILE_OFFSET_BITS=64 shouldn't produce that particular failure.

To my bad I don't have a Windows XP installation handy, but will have one this weekend.

Will take a look then and get back to you guys.

@headius
Copy link
Owner

headius commented Feb 28, 2014

@luislavena Great, thank you! I will wait to see if there's anything we need to do in atomic.

@luislavena
Copy link

@MarkDBlackwell hello,

I believe I see your problem: you have a cygwin-based or cygwin installed version of GCC that is not the one compatible with RubyInstaller.

From your backtrace:

Configured with: /cygdrive/i/szsz/tmpp/gcc4/gcc-4.8.2-2/src/gcc-4.8.2/configure
--srcdir=/cygdrive/i/szsz/tmpp/gcc4/gcc-4.8.2-2/src/gcc-4.8.2 --prefix=/usr 

RubyInstaller requires the exact version of GCC that was used to compile it, and is distributed as a DevKit that contains all the necessary pieces to properly work.

You can see from the target information:

Target: i686-pc-cygwin

That the cygwin provided compiler is not compatible with RubyInstaller, as the target platform of RubyInstaller is i686-w64-mingw32 or i386-mingw32 (as shown by ruby -v)

Even if you had version 4.7.2 (the one used by RubyInstaller), you need to target the exact same platform/architecture, which is not the case of the GCC you have installed.

In RubyInstaller troubleshooting page:

https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#wiki-cygwin

It clearly mentions to avoid mixing up Cygwin with RubyInstaller.

At RubyInstaller downloads page:

http://rubyinstaller.org/downloads/

You will see a list of versions of Ruby and the indication of the matching DevKit.

The following is the output of a clean installation of Ruby 2.0.0-p451 with mingw-w64-4.7.2 DevKit installing atomic gem:

C:\Users\Luis>ruby -v
ruby 2.0.0p451 (2014-02-24) [i386-mingw32]

C:\Users\Luis>gem -v
2.0.14

C:\Users\Luis>gem list atomic

*** LOCAL GEMS ***

C:\Users\Luis>gem install atomic
Fetching: atomic-1.1.15.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed atomic-1.1.15
1 gem installed

@headius we have been having great results cross-compiling gems with rake-compiler and rake-compiler-dev-box

Having pre-compiled binaries will reduce the issues some users experience with mismatched compilers.

Would you like to try that out and let me know if works for you? Just recently @tenderlove released newer sqlite3 and provided Windows binaries using this approach. The binaries included 1.8.7, 1.9.3 and 2.0.0 binaries plus a 64bits version of the gem:

http://rubygems.org/gems/sqlite3/versions

1.3.9 February 25, 2014 x64-mingw32 (406 KB)
1.3.9 February 25, 2014 x86-mswin32-60 (1.05 MB)
1.3.9 February 25, 2014 x86-mingw32 (1.05 MB)
1.3.9 February 25, 2014 (59.5 KB)

Let me know if that helps.

Cheers.

@MarkDBlackwell
Copy link
Author

RubyInstaller requires the exact version of GCC that was used to compile it,
and is distributed as a DevKit
you have a cygwin-based or cygwin installed version of GCC

@luislavena, yes; that's a good tip. I noticed that Cygwin problem also (after my first report) so I corrected it by removing Cygwin from my PATH. Now, when I install the gem from the Windows command line, my PATH includes no gcc. Also, in order to forestall problematic versions of other programs, I removed almost everything from my PATH. (Please see the gist.)

However, gem installation is still failing. I made a gist of the command line output including mkmf.log.

I installed the Devkit from file DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe.

At this point, I don't know how to verify which gcc version my "gem install" command is using. That might be interesting.

The following is the output of a clean installation of Ruby 2.0.0-p451 with
mingw-w64-4.7.2 DevKit installing atomic gem

Is the word length of your (physical) XP machine 64 bits, perhaps? I'm thinking this might make a difference.

@luislavena
Copy link

@MarkDBlackwell

Is the word length of your (physical) XP machine 64 bits, perhaps? I'm thinking this might make a difference.

I'm using a 32bits version of XP, 64bits XP is very rare and highly unlikely RubyInstaller will work on it. All this time we have talk about 32bits Ruby and 32bits XP.

The setting -D_FILE_OFFSET_BITS=64 has nothing to do with 32/64bits of the compiler, but instead 32/64bits to access files (see _wstat and other functions to use 64bits pointers to access 2GB+ files)

From the gist you showed to us:

conftest.c:1:0: internal compiler error: Illegal instruction
Please submit a full bug report, with preprocessed source if appropriate.
See <[email protected]> for instructions.

It is clear something is failing in your system. This could be caused by some DLLs copied in your system folder that might be affecting how GCC works.

You can start try copy the conftest.c example, then use devkitvars.bat to add DevKit to the PATH and try compiling manually to see if the compiler works on your machine (or not).

I also noticed this: C:/progra/ruby/m/200/p451/bin/ruby.exe is progra a real folder, or did you install RubyInstaller into a path with spaces (and just tweaked the output from Program Files to read progra)

Asking this because installation on folder with spaces is discouraged, as some gems and lot of tools do not work properly.

Either way, the problem on your system seems very specific to your Windows XP installation.

I've managed to get a fresh Windows XP SP3 VM (thanks to modern.ie), installed Ruby 2.0.0-p451 and DevKit mingw64-32-4.7.2 in it and got this:

https://gist.github.com/luislavena/9302220

If you need further assistance, we can coordinate a TeamViewer session so I can get into your machine and verify what could be the problem.

But definitely is not RubyInstaller or atomic related.

@MarkDBlackwell
Copy link
Author

You can start try copy the conftest.c example
definitely is not RubyInstaller or atomic related

File conftest.c is auto-generated (per RubyGems Guides, section Gems with Extensions). Of course, gem atomic's file extconf.rb generates conftest.c, perhaps based on various things it finds when probing one's particular system. For this reason, I'm thinking the problem may be atomic related, or Ruby language mkmf related.

I copied the visible code. Running gcc produced "illegal instruction". This gist shows the command line output.

some DLLs copied in your system folder

Actually, passing a completely empty file to gcc produces "illegal instruction" also (for me).

Supposedly, my fresh reinstall of Ruby should have installed all the correct, needed DLLs over any hypothetical bad DLLs. Isn't this right?

is progra a real folder, or did you install RubyInstaller into a path with spaces

It's a real folder.

@luislavena
Copy link

Hello @MarkDBlackwell,

File conftest.c is auto-generated (per RubyGems Guides, section Gems with Extensions). For this reason, I'm thinking the problem may be atomic related, or Ruby language mkmf related.

I really don't understand if my english is the problem, not understanding what I said or you simply play with me.

I stayed up until 3am last night, downloading and testing a Windows XP SP3 machine and test the issue to help you out, and proved you the issue is not Ruby, RubyInstaller or DevKit related, but you keep insisting on that.

I've been building, compiling and solving Ruby and RubyInstaller issues for the past 7 years and pretty much I can detect when the problem is something in system or the problem is something I did wrong with Ruby or RubyInstaller.

Supposedly, my fresh reinstall of Ruby should have installed all the correct, needed DLLs over any hypothetical bad DLLs. Isn't this right?

That has nothing to do if in your machine you already have some DLLs that could affect GCC execution.

Again, see the troubleshooting page of RubyInstaller:

https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#wiki-devkit_dll_conflict

As you can see from there, we had in the past similar experiences and investigated to obtain resolutions, which later where shared in the wiki.

Me testing on a clean XP SP3 box and that it worked is enough for me to say and confirm there is something specific on your environment that is interfering with the compilation.

I've offered assist you over a TeamViewer session to help resolve this, yet you decided not to quote or respond to that.

If you're interested on help me solve your current issue, please reach me out on RubyInstaller mailing list:

https://groups.google.com/forum/#!forum/rubyinstaller

So we can coordinate a TeamViewer session day and time.

Again: the issue you're experiencing, after your testing of GCC against a empty file proves the issue is not Ruby or atomic related.

@MarkDBlackwell
Copy link
Author

@luislavena, you are absolutely right: my particular computer has a problem. (I also confirmed it isn't a 32-bit machine issue (just now), by accessing another 32-bit XP computer.)

I also believe it's not atomic-related (so closing). Everyone: I regret the noise!

I really don't understand if...not understanding what I said or you simply play with me.

No, no! I do appreciate your past time and effort on this problem (and, I regret your spending it). I can only hope that the time you spent setting up a (virtual?) XP box might help other people also (not just me). :)

Me testing on a clean XP SP3 box and that it worked is enough for me to say <snip>
I've been building, compiling and solving Ruby and RubyInstaller issues for the past 7 years
and pretty much I can detect when the problem is something in system
or the problem is something I did wrong with Ruby or RubyInstaller.

I do respect your expertise, wisdom and experience! Previously, from my ignorance on how 32-bit XP works on a 64-bit box, I merely worried that my use of a 32-bit box, and your (possible) use of a 64-bit box, might make some difference.

I am aware that you are expert in resolving any problems which people may experience (due to their own computers' peculiarities) while using RubyInstaller and DevKit (and, presumably, much more). Moreover, I regret I didn't explicitly acknowledging your expertise before now! :)

Particularly, I thank you so much for alerting me to (the existence of) the DLL conflict Wiki page. :)

Furthermore, I personally wish to give you many thanks for all your good efforts in building and maintaining the Windows RubyInstaller and Devkit these many years. I'm sure there are many people who appreciate and (obviously) greatly benefit from them, although you may not have heard from them all. :)

I've offered assist you over a TeamViewer session to help resolve this,
yet you decided not to quote or respond to that.

I thank you; I did listen. Later, I might accept your kind offer. :)

Regarding anything further, I might contact you on the RubyInstaller mailing list. Again, I thank you for all you've done, and for all you do!

@MarkDBlackwell
Copy link
Author

It is clear something is failing in your system...the problem on your system seems very specific to your Windows XP installation.

A peculiarity of my computer indeed caused this particular, preconfigured gcc compiler to generate an illegal instruction fault. The peculiarity was:

My CPU's architecture was older than nocona. And, the particular RubyInstaller DevKit-supplied gcc compiler which I was attempting to use was preconfigured (thus precompiled) for the nocona architecture (with CFLAGS -march=nocona).

A RubyInstaller forum comment provides more information (if desired).

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

No branches or pull requests

4 participants