# Cross-compiling 1.9.1-p0 to bfin-uclinux

**URL:** <https://www.ruby-forum.com/t/cross-compiling-1-9-1-p0-to-bfin-uclinux/167156>\
**Category:** Ruby\
**Created:** [May 4, 2009, 9:19pm UTC](https://www.ruby-forum.com/t/cross-compiling-1-9-1-p0-to-bfin-uclinux/167156 "2009-05-04T21:19:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e274bd/32.png) [@abg](https://www.ruby-forum.com/u/abg)\
**Post date:** [May 4, 2009, 9:19pm UTC](https://www.ruby-forum.com/t/cross-compiling-1-9-1-p0-to-bfin-uclinux/167156/1 "2009-05-04T21:19:59Z")

</div>

Greetings –

I am trying to see whether I can build ruby to run on an Analog Devices  
Blackfin processor. The toolchain (with bfin-uclinux-gcc being the  
compiler) is available here:

> **[End of Life for Blackfin Linux - Q&A - Linux Distribution for Blackfin -...](https://ez.analog.com/dsp/software-and-development-tools/linux-blackfin/f/q-a/108907/end-of-life-for-blackfin-linux)**
>
> For the past 14 years Analog Devices has developed and maintained the ports of uCLinux, uBoot, GCC, GDB and Buildroot for the Blackfin BF5xx architecture. 
> We will

…using the latest 2008R1.5\_RC14 release of both the toolchain and  
libraries, where the build machine is an i686 running CentOS 5.3.

This will not cross-compile out of the box, but I’m not sure how much  
help it needs to finish. I am using the following command line to  
configure:

ac\_cv\_func\_getpgrp\_void=no   
ac\_cv\_func\_setpgrp\_void=yes   
./configure --host=bfin-uclinux

configure completes without complaint. Everything seems to compile  
(bfin-uclinux-gcc is used as expected) but it fails when trying to  
create the encdb.so file. It looks to me like this step is using the  
wrong linker (ld instead of bfin-uclinux-ld). The exact error is at the  
bottom of this message.

I tried this with 1.8.7-p72 and it also failed (I had to tweak process.c  
for something that got fixed in 1.9.1-p0 and copy in a config.sub from  
another bfin-uclinux project port) but in a different place  
(extmk.rb:357 undefined method ‘\<\<’ for nil:NilClass).

Some Google searches show that others have had success (1.8.6-p114 and  
-p287 are mentioned). However, I’d like to use the latest and greatest  
if possible – are there any known solutions for 1.9.1?

Error log is below (only the end is shown, I can the full build log if  
it is needed). Any help would be appreciated.

bfin-uclinux-gcc -O2 -g -Wall -Wno-parentheses -I.  
-I.ext/include/bfin-uclinux -I./include -I. -DRUBY\_EXPORT -o tgamma.o  
-c ./missing/tgamma.c  
bfin-uclinux-gcc -O2 -g -Wall -Wno-parentheses -I.  
-I.ext/include/bfin-uclinux -I./include -I. -DRUBY\_EXPORT -o dmyext.o  
-c dmyext.c  
bfin-uclinux-ar rcu libruby-static.a dln.o encoding.o prelude.o array.o  
bignum.o class.o compar.o complex.o dir.o enum.o enumerator.o error.o  
eval.o load.o proc.o file.o gc.o hash.o inits.o io.o marshal.o math.o  
numeric.o object.o pack.o parse.o process.o random.o range.o rational.o  
re.o regcomp.o regenc.o regerror.o regexec.o regparse.o regsyntax.o  
ruby.o safe.o signal.o sprintf.o st.o strftime.o string.o struct.o  
time.o transcode.o util.o variable.o version.o compile.o debug.o iseq.o  
vm.o vm\_dump.o thread.o cont.o ascii.o us\_ascii.o unicode.o utf\_8.o  
newline.o memcmp.o tgamma.o dmyext.o  
ruby -I/tmp/ruby-1.9.1-p0 -rfake ./tool/generic\_erb.rb -c -o encdb.h  
./template/encdb.h.tmpl ./enc enc  
encdb.h unchanged  
make -f enc.mk RUBY="ruby -I/tmp/ruby-1.9.1-p0 -rfake " MINIRUBY="ruby  
-I/tmp/ruby-1.9.1-p0 -rfake " enc  
make[1]: Entering directory `/tmp/ruby-1.9.1-p0’  
bfin-uclinux-gcc -I. -I.ext/include/bfin-uclinux -I./include -I.  
-D\_FILE\_OFFSET\_BITS=64 -DONIG\_ENC\_REGISTER=rb\_enc\_register -fPIC -O2  
-g -Wall -Wno-parentheses -o enc/encdb.o -c ./enc/encdb.c

Here is where I think the problem is (the .o was created with  
bfin-uclinux-gcc, now trying to link with normal ld):

ld -o .ext/bfin-uclinux/enc/encdb.so enc/encdb.o -L. -L. -L.  
-lpthread -lrt -lcrypt -lm  
ld: enc/encdb.o: Relocations in generic ELF (EM: 106)  
ld: enc/encdb.o: Relocations in generic ELF (EM: 106)  
ld: enc/encdb.o: Relocations in generic ELF (EM: 106)  
ld: enc/encdb.o: Relocations in generic ELF (EM: 106)  
ld: enc/encdb.o: Relocations in generic ELF (EM: 106)  
ld: enc/encdb.o: Relocations in generic ELF (EM: 106)  
enc/encdb.o: could not read symbols: File in wrong format  
make[1]: \*\*\* [.ext/bfin-uclinux/enc/encdb.so] Error 1  
make[1]: Leaving directory `/tmp/ruby-1.9.1-p0’  
make: \*\*\* [enc] Error 2

---

<div class="post-metadata">

**Author:** ![abg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e274bd/32.png) [@abg](https://www.ruby-forum.com/u/abg)\
**Post date:** [May 5, 2009, 12:44pm UTC](https://www.ruby-forum.com/t/cross-compiling-1-9-1-p0-to-bfin-uclinux/167156/2 "2009-05-05T12:44:17Z")

</div>

Aaron Gage wrote:

> Some Google searches show that others have had success (1.8.6-p114 and  
> -p287 are mentioned). However, I’d like to use the latest and greatest  
> if possible – are there any known solutions for 1.9.1?

ruby 1.9 is _much_ bigger than ruby 1.8, so for embedded applications,  
I’d stick with 1.8 (pref 1.8.6) unless you really need 1.9 features.

openwrt has a working ruby 1.8.6 port. I don’t know what the status is  
of openwrt with blackfin, but a google search suggests maybe someone is  
working on it:  
[https://dev.openwrt.org/changeset/7306/trunk/tools/mkimage](https://dev.openwrt.org/changeset/7306/trunk/tools/mkimage)

---

<div class="post-metadata">

**Author:** ![abg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e274bd/32.png) [@abg](https://www.ruby-forum.com/u/abg)\
**Post date:** [May 5, 2009, 5:19pm UTC](https://www.ruby-forum.com/t/cross-compiling-1-9-1-p0-to-bfin-uclinux/167156/3 "2009-05-05T17:19:43Z")

</div>

Brian C. wrote:

> ruby 1.9 is _much_ bigger than ruby 1.8, so for embedded applications,  
> I’d stick with 1.8 (pref 1.8.6) unless you really need 1.9 features.
> 
> openwrt has a working ruby 1.8.6 port. I don’t know what the status is  
> of openwrt with blackfin, but a google search suggests maybe someone is  
> working on it:  
> [https://dev.openwrt.org/changeset/7306/trunk/tools/mkimage](https://dev.openwrt.org/changeset/7306/trunk/tools/mkimage)

Thanks for the info about 1.9. I have gone back and tried to build a  
couple of 1.8.6 versions, but I still seem to be getting stuck. I am  
consistently getting this error:

[blackfin@localhost ruby-1.8.6-p368]$ make  
rbconfig.rb unchanged  
./lib/fileutils.rb:1029:in `utime': can't convert NilClass into time (TypeError) from ./lib/fileutils.rb:1029:in `touch’  
from ./lib/fileutils.rb:1026:in `each' from ./lib/fileutils.rb:1026:in `touch’  
from ./mkconfig.rb:188  
make: \*\*\* [.rbconfig.time] Error 1

I checked out p287 (after reading  
[http://groups.google.com/group/ruby-talk-google/browse\_thread/thread/26dadccab34f57bf?fwc=2](http://groups.google.com/group/ruby-talk-google/browse_thread/thread/26dadccab34f57bf?fwc=2))  
and it reports the same error.

Since this build machine is CentOS 5.3, I have an older version of ruby  
(1.8.5) installed. However, I can build 1.8.6-p287 (from Subversion),  
1.8.6-p368, and 1.9.1-p0 on this machine natively without any difficulty  
(./configure && make && make test). This tells me that the above error  
(File.utime returning nil) is not necessarily due to the system’s ruby  
version being out of date (even though it is a ruby script that fails).

I will keep plugging away at it. The link to the OpenWRT project  
doesn’t give me any ideas about this particular error, but I’ll see if I  
can figure out what file mkconfig.rb is failing to find.

---

<div class="post-metadata">

**Author:** ![abg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e274bd/32.png) [@abg](https://www.ruby-forum.com/u/abg)\
**Post date:** [May 5, 2009, 5:59pm UTC](https://www.ruby-forum.com/t/cross-compiling-1-9-1-p0-to-bfin-uclinux/167156/4 "2009-05-05T17:59:44Z")

</div>

Well, I’ve gotten it to build. I have not yet tested this on the target  
processor yet, but first things first.

The steps I had to follow are:

1. Get a copy of ruby-1.8.6-p368 and extract it if necessary

2. cd into the ruby-1.8.6-p368 directory and copy the attached patch  
into it

3. Apply the attached patch by doing this:  
patch -p0 \< ruby-1.8.6-p368-bfin-uclinux.patch

4. configure as follows:

5. make (assuming that bfin-uclinux-gcc is in the PATH and the libraries  
are installed properly)

The resulting executable is about 2.3MB which isn’t too bad. I still  
need to try to convert it to the BFLT format, but I can work on that  
next.

As for the patch, I had to remove three lines from mkconfig.rb  
($timestamp was undefined), copy in the config.sub from the 1.9.1-p0  
distribution, and set all of the extensions to build statically.

Hopefully this will be of use to someone else.

---

<div class="post-metadata">

**Author:** ![abg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e274bd/32.png) [@abg](https://www.ruby-forum.com/u/abg)\
**Post date:** [May 6, 2009, 3:14am UTC](https://www.ruby-forum.com/t/cross-compiling-1-9-1-p0-to-bfin-uclinux/167156/5 "2009-05-06T03:14:26Z")

</div>

Hi,

At Wed, 6 May 2009 00:19:45 +0900,  
Aaron Gage wrote in [ruby-talk:335822]:

> [blackfin@localhost ruby-1.8.6-p368]$ make  
> rbconfig.rb unchanged  
> ./lib/fileutils.rb:1029:in `utime': can't convert NilClass into time (TypeError) from ./lib/fileutils.rb:1029:in`touch’  
> from ./lib/fileutils.rb:1026:in `each' from ./lib/fileutils.rb:1026:in`touch’  
> from ./mkconfig.rb:188  
> make: \*\*\* [.rbconfig.time] Error 1

r14741 needs to get backported to 1.8.6.
