[MacRuby-devel] Building MacRuby r2765 with llvm r82747 failed on core duo macbook, Leopard

Laurent Sansonetti lsansonetti at apple.com
Sun Oct 11 22:10:40 PDT 2009


Hi Hiroshi-san,

On Oct 11, 2009, at 7:11 PM, hiroshi saito wrote:

> Hi Laurent,
>
>> Strange. Could you try the following in the same directory and  
>> paste us the
>> output?
>>
>> $ ./miniruby -I. -I./lib bin/rubyc --internal -C "rbconfig.rb" -o
>> "./rbconfig.rbo" -V
>
> MacRuby - Laurent にコマンド実行結果を送る
>
> Hi Laurent,
>
>
>
> $ ./miniruby -I. -I./lib bin/rubyc --internal -C "rbconfig.rb" -o
> "./rbconfig.rbo" -V
>
> $ PATH=$PATH:~/Desktop/wc/MacRuby/llvm-trunk/Release/bin ./miniruby
> -I. -I./lib bin/rubyc --internal -C "rbconfig.rb" -o "./rbconfig.rbo"
> -V
> ./miniruby --emit-llvm
> "/var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/rbconfig.bc"
> MREP_-107041289 "rbconfig.rb"
> /Users/hiroshi/Desktop/wc/MacRuby/llvm-trunk/Release/bin/llc -f
> /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/rbconfig.bc
> -o=/var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/rbconfig.s
> -march=x86-64 -enable-eh
> /usr/bin/gcc -c -arch x86_64
> /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/rbconfig.s -o
> /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/rbconfig.o
> /usr/bin/g++ /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/main.c
> -dynamic -bundle -undefined suppress -flat_namespace -arch x86_64 -L.
> -lmacruby /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/rbconfig.o
> -o ./rbconfig.rbo
> /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/main.c:2: error:
> expected initializer before ‘-’ token
> /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/main.c: In function
> ‘void __init__()’:
> /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/main.c:5: error:
> ‘MREP_’ was not declared in this scope
> /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/main.c:5: error:
> ‘107041289’ cannot be used as a function
> Error when executing `/usr/bin/g++
> /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/main.c -dynamic
> -bundle -undefined suppress -flat_namespace -arch x86_64 -L. -lmacruby
> /var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/rbconfig.o -o
> ./rbconfig.rbo'
>
> At the line around 100 of bin/rubyc:
>
>    init_func = "MREP_#{File.read(path).hash}"
>
> I extracted this line and execute it with -e option
>
> $ ./miniruby -I. -I./lib -e "p File.read('rbconfig.rb').hash"
> -107041289
>
> I suppose that String#hash method will return an integer, that could
> be nagative value. I don't know why on other environments
> the method return positive value everytime...

Indeed, it's weird that nobody reported that problem, yet.

> Anyway, I hack the line of code to continue like that:
>
> Index: bin/rubyc
> ===================================================================
> --- bin/rubyc   (revision 2779)
> +++ bin/rubyc   (working copy)
> @@ -96,7 +96,7 @@
>     output ||= File.join(File.dirname(path), base + '.o')
>
>     # Generate init function (must be unique).
> -    init_func = "MREP_#{File.read(path).hash}"
> +    init_func = "MREP_#{File.read(path).hash.abs}"
>
>     # Compile the file into LLVM bitcode.
>     bc = gen_tmpfile(base, 'bc')

I committed this change in r2781.

> It passed, but I got another error.
>
> $ ./miniruby -I. -I./lib bin/rubyc --internal -C "lib/date.rb" -o  
> "lib/date.rbo"
> Error when executing `./miniruby --emit-llvm
> "/var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/date.bc"
> MREP_146681552 "lib/date.rb"'
> rake aborted!
>
> The exact error of the executed subcommand is:
>
> $ ./miniruby --emit-llvm
> "/var/folders/HQ/HQYJapbxHKW7ieZsqEt5-++++TI/-Tmp-/date.bc"
> MREP_146681552 "lib/date.rb"
> unrecognized literal `86400000000000' (class `Bignum' type 10)
> zsh: abort      ./miniruby --emit-llvm  MREP_146681552 "lib/date.rb"
>
> I doubt that numeric or integer part of my llvm or macruby went wrong,
> it possibly caused by something bad in my environment.
> If it is true, farther investigation will be waste of time to you and
> me, I'm sorry, but I'll give up for now.

In fact, this crash is because of a limitation in the AOT compiler, I  
forgot to handle literal bignums.

$ ./miniruby --emit-llvm foo omg -e "p 1267650600228229401496703205376"
unrecognized literal `1267650600228229401496703205376' (class `Bignum'  
type 10)
Abort trap

In any case I will fix it. But I don't know yet why this problem hits  
you when compiling lib/date.rb. The same file appears to compile fine  
for the rest of us.

It's not a waste of time at all because you found legitimate bugs :-)  
ありがとうございます!

Laurent


More information about the MacRuby-devel mailing list