Date.today problem on linux with Ruby 1.8.6

J

Jarmo Pertman

Hello.

I just installed Ruby 1.8.6 from source and then stumbled upon the
following problem. Any ideas what might be causing this incorrect
behaviour?

jarmo@jarmo-laptop:~$ uname -a
Linux jarmo-laptop 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:27:30
UTC 2010 i686 GNU/Linux
jarmo@jarmo-laptop:~$ date
Sat May 29 18:46:18 EEST 2010
jarmo@jarmo-laptop:~$ ruby -v
ruby 1.8.6 (2010-02-05 patchlevel 399) [i686-linux]
jarmo@jarmo-laptop:~$ ruby -e "require 'date'; puts Date.today"
2060--1-9785

Jarmo
 
J

Jarmo Pertman

Time.now works correctly
jarmo@jarmo-laptop:~/Downloads/ruby-1.8.6-p287$ ruby -e "require 'date';
puts Date.today; puts Time.now"
2060--1-9785
Sat May 29 21:59:11 +0300 2010

Jarmo

Jarmo said:
Hello.

I just installed Ruby 1.8.6 from source and then stumbled upon the
following problem. Any ideas what might be causing this incorrect
behaviour?

jarmo@jarmo-laptop:~$ uname -a
Linux jarmo-laptop 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:27:30
UTC 2010 i686 GNU/Linux
jarmo@jarmo-laptop:~$ date
Sat May 29 18:46:18 EEST 2010
jarmo@jarmo-laptop:~$ ruby -v
ruby 1.8.6 (2010-02-05 patchlevel 399) [i686-linux]
jarmo@jarmo-laptop:~$ ruby -e "require 'date'; puts Date.today"
2060--1-9785

Jarmo
 
J

Jarmo Pertman

jarmo@jarmo-laptop:~/Downloads$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --enable-multiarch --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4
--program-suffix=-4.4 --enable-nls --enable-clocale=gnu
--enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i486
--with-tune=generic --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)

And i compiled Ruby with ./configure && make && sudo make install

Jarmo
 
J

Jarmo Pertman

i executed make test and it seems that some of the tests are also
failing:
jarmo@jarmo-laptop:~/Downloads/ruby-1.8.6-p399$ make test
not ok float 1 -- ./sample/test.rb:1172
not ok float 2 -- ./sample/test.rb:1173
not ok float 3 -- ./sample/test.rb:1174
not ok float 4 -- ./sample/test.rb:1175
not ok float 5 -- ./sample/test.rb:1176
not ok float 6 -- ./sample/test.rb:1177
not ok float 7 -- ./sample/test.rb:1178
not ok float 8 -- ./sample/test.rb:1179
not ok float 9 -- ./sample/test.rb:1180
test failed
make: *** [test] Error 1


# test.rb
1172 test_ok(2.6.floor == 2)
1173 test_ok((-2.6).floor == -3)
1174 test_ok(2.6.ceil == 3)
1175 test_ok((-2.6).ceil == -2)
1176 test_ok(2.6.truncate == 2)
1177 test_ok((-2.6).truncate == -2)
1178 test_ok(2.6.round == 3)
1179 test_ok((-2.4).truncate == -2)
1180 test_ok((13.4 % 1 - 0.4).abs < 0.0001)

Is there any special switches or commands i should use while compiling?

Jarmo
 
R

Robert Klemme

i executed make test and it seems that some of the tests are also
failing:
jarmo@jarmo-laptop:~/Downloads/ruby-1.8.6-p399$ make test
not ok float 1 -- ./sample/test.rb:1172
not ok float 2 -- ./sample/test.rb:1173
not ok float 3 -- ./sample/test.rb:1174
not ok float 4 -- ./sample/test.rb:1175
not ok float 5 -- ./sample/test.rb:1176
not ok float 6 -- ./sample/test.rb:1177
not ok float 7 -- ./sample/test.rb:1178
not ok float 8 -- ./sample/test.rb:1179
not ok float 9 -- ./sample/test.rb:1180
test failed
make: *** [test] Error 1


# test.rb
1172 test_ok(2.6.floor == 2)
1173 test_ok((-2.6).floor == -3)
1174 test_ok(2.6.ceil == 3)
1175 test_ok((-2.6).ceil == -2)
1176 test_ok(2.6.truncate == 2)
1177 test_ok((-2.6).truncate == -2)
1178 test_ok(2.6.round == 3)
1179 test_ok((-2.4).truncate == -2)
1180 test_ok((13.4 % 1 - 0.4).abs< 0.0001)

Is there any special switches or commands i should use while compiling?

Jarmo

If you are compiling from source anyway I'd probably switch to 1.8.7.
You could also check [1] to see whether it's a known bug already.

Cheers

robert

[1] http://redmine.ruby-lang.org/projects/show/ruby-186
 
K

KUBO Takehiro

i executed make test and it seems that some of the tests are also
failing:
jarmo@jarmo-laptop:~/Downloads/ruby-1.8.6-p399$ make test
not ok float 1 -- ./sample/test.rb:1172
not ok float 2 -- ./sample/test.rb:1173
not ok float 3 -- ./sample/test.rb:1174
not ok float 4 -- ./sample/test.rb:1175
not ok float 5 -- ./sample/test.rb:1176
not ok float 6 -- ./sample/test.rb:1177
not ok float 7 -- ./sample/test.rb:1178
not ok float 8 -- ./sample/test.rb:1179
not ok float 9 -- ./sample/test.rb:1180
test failed
make: *** [test] Error 1


# test.rb
1172 test_ok(2.6.floor == 2)
1173 test_ok((-2.6).floor == -3)
1174 test_ok(2.6.ceil == 3)
1175 test_ok((-2.6).ceil == -2)
1176 test_ok(2.6.truncate == 2)
1177 test_ok((-2.6).truncate == -2)
1178 test_ok(2.6.round == 3)
1179 test_ok((-2.4).truncate == -2)
1180 test_ok((13.4 % 1 - 0.4).abs < 0.0001)

Is there any special switches or commands i should use while compiling?

As far as I checked, ruby_strtod() in util.c is broken by gcc 4.4's
optimization.

1. disable optimization.

./configure
make
vi Makefile # replace -O2 to -O0.
touch util.c # update the timestamp to recompile util.c.
make
sudo make install

2. use gcc-4.3.

sudo apt-get install gcc-4.3
./configure CC=gcc-4.3
make
sudo make install

3. configure with -fno-strict-aliasing and --enable-pthread.
(I don't know why it dismisses the problem...)

./configure CFLAGS='-g -O2 -fno-strict-aliasing' --enable-pthread
make
sudo make install
 
J

Jarmo Pertman

By the way, doing every same move with 1.8.7 as i did with 1.8.6 works
indeed:
jarmo@jarmo-laptop:~/Downloads/ruby-1.8.7-p249$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]
jarmo@jarmo-laptop:~/Downloads/ruby-1.8.7-p249$ ruby -e "require 'date';
puts Date.today"
2010-05-30

But my problem was that i really-really needed 1.8.6, thus trying to
make it work.
But thanks for the tip.

Jarmo

Robert said:
If you are compiling from source anyway I'd probably switch to 1.8.7.
You could also check [1] to see whether it's a known bug already.

Cheers

robert

[1] http://redmine.ruby-lang.org/projects/show/ruby-186
 
J

Jarmo Pertman

Thank you for this (insight|help)ful reply!

I tried your first suggestion which worked as you said! Then i decided
to downgrade gcc completely and tried your second suggestion which also
worked!

Also make test succeeded (although i tried with latest patchlevel, so
i'm not sure if it was even related with my problem).

But why does 1.8.7 work with gcc 4.4? Is util.c there somehow changed?
So in the end it is a incompatibility problem with Ruby 1.8.6 and gcc
4.4 (which comes by default with latest Ubuntu)?

Anyway, thank You again!

Jarmo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,692
Latest member
JenniferTi

Latest Threads

Top