Cross-Compiling Ruby using LTIB

Linux Target Image Builder (LTIB) is a tool used to develop and deploy board support packages for an embedded target platform. I used LTIB on my last project to create the kernel image and root file system for an “i.MX28 freescale”:http://www.freescale.com/webapp/sps/site/taxonomy.jsp?code=IMX28_FAMILY processor running on a custom board.

During development I found I could use Ruby on target to aid development and testing but was unable to find a suitable Ruby package available in LTIB’s Global Package Pool (GPP). I created my own installation package for Ruby 1.8.7 p334 starting from Fedora’s 14 Ruby source RPM and cross-compiled the package from LTIB’s Private Package Pool (PPP). Eventually I’d like to publish the Ruby package to the GPP once it has been verified on several other platforms. That is where you come in: if you’d like to try the package, please follow the instructions below. All of the steps below are based on “LTIB’s documentation”:http://ltib.org/pages/LTIB_generic_v1.4_-_version_6.4.1.pdf.

h2. Overview

You will need to install the Ruby source code in LTIB’s PPP. The PPP is just a local directory on your system that LTIB puts the archives of your source code. After adding the Ruby source code, you need to add the LTIB spec file which is LTIB’s makefile equivalent. Finally, run LTIB’s commands to build the package.

Disclaimer: The package has only been cross-compiled and tested for a single target platform so far.

h2. Setup

  • Download the Ruby source code configured for LTIB: ruby-1.8.7-p334-ltib.tar.gz
  • Copy the file to your PPP (for Freescale LTIB installations, this is located at /opt/freescale/pkgs)
  • Download the LTIB spec file: ruby.spec
  • Create a directory ltib/dist/lfs-5.1/ruby to put the Ruby LTIB spec file in
  • Copy the LTIB spec file into the created directory

h2. Building

Run LTIB package prep command specifying the Ruby spec file: ./ltib -m prep -p ruby.spec

h2. Configuring LTIB’s User Interface to Recognize the Package

  • Add PKG_RUBY = ruby to the ltib/config/userspace/pkg_map file
  • Add the below configuration to ltib/config/userspace/packages.lkc file (maintain alphabetical order of file by config name when adding)

config PKG_RUBY
    depends CAP_HAS_MMU
    bool "ruby"
    help
      An interpreter of object-oriented scripting language

Rebuild LTIB ensuring you select the Ruby package for installation in your rootfs, install your image and power up your board. Please leave me a comment letting me know how it worked and what platform you installed it on.

Conversation
  • Senthil says:

    Hi Greg:

    I am trying to compile for iMX287 board and I have followed your steps on Ubuntu 9.04 host Linux System, the rmp build failed with the following error:
    configure: WARNING: unrecognized options: –disable-ipv6, –without-X11, –without-tk, –without-tcl
    + pwd
    + export LD_LIBRARY_PATH=/home/xl840/ltib_mx28/ltib/rpm/BUILD/ruby-1.8.7/ruby-1.8.7-p334
    + make RUBY_INSTALL_NAME=ruby COPY=cp -p
    make: ruby: Command not found
    make: *** [.rbconfig.time] Error 127
    error: Bad exit status from /home/xl840/ltib_mx28/ltib/tmp/rpm-tmp.93005 (%build)

    Here is the full trace of the ltib build, please help me in resolving this error.

    Processing: ruby
    ==================
    Build path taken because: directory build, no prebuilt rpm,
    scbuild/scdeploy already unpacked package

    Processing: ruby
    ==================
    Build path taken because: directory build, build key set, no prebuilt rpm,

    rpmbuild –dbpath /home/xl840/ltib_mx28/ltib/rootfs//var/lib/rpm –target arm –define ‘_unpackaged_files_terminate_build 0’ –define ‘_target_cpu arm’ –define ‘__strip strip’ –define ‘_topdir /home/xl840/ltib_mx28/ltib/rpm’ –define ‘_prefix /usr’ –define ‘_tmppath /home/xl840/ltib_mx28/ltib/tmp’ –define ‘_rpmdir /home/xl840/ltib_mx28/ltib/rpm/RPMS’ –define ‘_mandir /usr/share/man’ –define ‘_sysconfdir /etc’ –define ‘_localstatedir /var’ -bc –short-circuit /home/xl840/ltib_mx28/ltib/dist/lfs-5.1/ruby/ruby.spec
    Building target platforms: arm
    Building for target arm
    Executing(%build): /bin/sh -e /home/xl840/ltib_mx28/ltib/tmp/rpm-tmp.93005
    + umask 022
    + cd /home/xl840/ltib_mx28/ltib/rpm/BUILD
    + cd ruby-1.8.7
    + cd ruby-1.8.7-p334
    + pwd
    + CURRENT1=/home/xl840/ltib_mx28/ltib/rpm/BUILD/ruby-1.8.7/ruby-1.8.7-p334
    + test -f /usr/share/libtool/config.sub
    + test -f /usr/share/libtool/config.guess
    + rb_cv_func_strtod=no
    + export rb_cv_func_strtod
    + CFLAGS=-O2 -fno-strict-aliasing
    + export CFLAGS
    + CFLAGS=-O2 -fno-strict-aliasing
    + export CFLAGS
    + CXXFLAGS=-O2
    + export CXXFLAGS
    + FFLAGS=-O2
    + export FFLAGS
    + [ -f configure.in ]
    + libtoolize –copy –force
    Remember to add `AC_PROG_LIBTOOL’ to `configure.in’.
    You should add the contents of `//opt/freescale/ltib/usr/share/aclocal/libtool.m4′ to `aclocal.m4′.
    + ./configure –host=i686-pc-linux-gnu –target=arm-rpm-linux-gnu –prefix=/usr –exec-prefix=/usr –bindir=/usr/bin –sbindir=/usr/sbin –sysconfdir=/etc –datadir=/usr/share –includedir=/usr/include –libdir=/usr/lib –libexecdir=/usr/libexec –localstatedir=/var –sharedstatedir=/usr/com –mandir=/usr/share/man –infodir=/usr/info –host=arm-linux –build=i686-gnu-linux –prefix=/usr –enable-shared –disable-ipv6 –without-X11 –without-tk –without-tcl –with-sitedir=/usr/lib/ruby/site_ruby –with-sitearchdir=/usr/lib/ruby/site_ruby –with-vendordir=/usr/lib/ruby/vendor_ruby –with-vendorarchdir=/usr/lib/ruby/vendor_ruby
    configure: WARNING: unrecognized options: –disable-ipv6, –without-X11, –without-tk, –without-tcl
    checking build system type… i686-gnu-linux-gnu
    checking host system type… arm-unknown-linux-gnu
    checking target system type… arm-rpm-linux-gnu
    checking for arm-linux-gcc… (cached) gcc
    checking for arm-linux-gcc… (cached) gcc
    checking whether the C compiler works… yes
    checking for C compiler default output file name… a.out
    checking for suffix of executables…
    checking whether we are cross compiling… yes
    checking for suffix of object files… o
    checking whether we are using the GNU C compiler… yes
    checking whether gcc accepts -g… yes
    checking for gcc option to accept ISO C89… none needed
    checking how to run the C preprocessor… gcc -E
    checking for grep that handles long lines and -e… /bin/grep
    checking for egrep… /bin/grep -E
    checking whether gcc needs -traditional… no
    checking whether the linker is GNU ld… yes
    checking whether gcc -E accepts -o… yes
    checking for bison… bison -y
    checking for arm-linux-ranlib… arm-linux-ranlib
    checking for arm-linux-ar… ar
    checking for arm-linux-as… arm-linux-as
    checking whether ln -s works… yes
    checking whether make sets $(MAKE)… yes
    checking for a BSD-compatible install… /usr/bin/install -c
    checking for ANSI C header files… yes
    checking for sys/types.h… yes
    checking for sys/stat.h… yes
    checking for stdlib.h… yes
    checking for string.h… yes
    checking for memory.h… yes
    checking for strings.h… yes
    checking for inttypes.h… yes
    checking for stdint.h… yes
    checking for unistd.h… yes
    checking minix/config.h usability… no
    checking minix/config.h presence… no
    checking for minix/config.h… no
    checking whether it is safe to define __EXTENSIONS__… yes
    checking for special C compiler options needed for large files… no
    checking for _FILE_OFFSET_BITS value needed for large files… 64
    checking for long long… yes
    checking for off_t… yes
    checking size of int… 4
    checking size of short… 2
    checking size of long… 4
    checking size of long long… 8
    checking size of __int64… 0
    checking size of off_t… 8
    checking size of void*… 4
    checking size of float… 4
    checking size of double… 8
    checking size of time_t… 4
    checking for pid_t… yes
    checking for gid_t… yes
    checking for uid_t… yes
    checking for prototypes… yes
    checking token paste string… ansi
    checking for variable length prototypes and stdarg.h… yes
    checking for noreturn function attribute… __attribute__ ((noreturn)) x
    checking for noinline function attribute… __attribute__ ((noinline)) x
    checking for RUBY_EXTERN… no
    checking whether sys_nerr is declared… yes
    checking for crypt in -lcrypt… yes
    checking for dlopen in -ldl… yes
    checking for shl_load in -ldld… no
    checking for clock_gettime in -lrt… yes
    checking for dirent.h that defines DIR… yes
    checking for library containing opendir… none required
    checking for ANSI C header files… (cached) yes
    checking for sys/wait.h that is POSIX.1 compatible… yes
    checking for stdlib.h… (cached) yes
    checking for string.h… (cached) yes
    checking for unistd.h… (cached) yes
    checking limits.h usability… yes
    checking limits.h presence… yes
    checking for limits.h… yes
    checking sys/file.h usability… yes
    checking sys/file.h presence… yes
    checking for sys/file.h… yes
    checking sys/ioctl.h usability… yes
    checking sys/ioctl.h presence… yes
    checking for sys/ioctl.h… yes
    checking sys/syscall.h usability… yes
    checking sys/syscall.h presence… yes
    checking for sys/syscall.h… yes
    checking fcntl.h usability… yes
    checking fcntl.h presence… yes
    checking for fcntl.h… yes
    checking sys/fcntl.h usability… yes
    checking sys/fcntl.h presence… yes
    checking for sys/fcntl.h… yes
    checking sys/select.h usability… yes
    checking sys/select.h presence… yes
    checking for sys/select.h… yes
    checking sys/time.h usability… yes
    checking sys/time.h presence… yes
    checking for sys/time.h… yes
    checking sys/times.h usability… yes
    checking sys/times.h presence… yes
    checking for sys/times.h… yes
    checking sys/param.h usability… yes
    checking sys/param.h presence… yes
    checking for sys/param.h… yes
    checking syscall.h usability… yes
    checking syscall.h presence… yes
    checking for syscall.h… yes
    checking pwd.h usability… yes
    checking pwd.h presence… yes
    checking for pwd.h… yes
    checking grp.h usability… yes
    checking grp.h presence… yes
    checking for grp.h… yes
    checking a.out.h usability… yes
    checking a.out.h presence… yes
    checking for a.out.h… yes
    checking utime.h usability… yes
    checking utime.h presence… yes
    checking for utime.h… yes
    checking for memory.h… (cached) yes
    checking direct.h usability… no
    checking direct.h presence… no
    checking for direct.h… no
    checking sys/resource.h usability… yes
    checking sys/resource.h presence… yes
    checking for sys/resource.h… yes
    checking sys/mkdev.h usability… no
    checking sys/mkdev.h presence… no
    checking for sys/mkdev.h… no
    checking sys/utime.h usability… no
    checking sys/utime.h presence… no
    checking for sys/utime.h… no
    checking netinet/in_systm.h usability… yes
    checking netinet/in_systm.h presence… yes
    checking for netinet/in_systm.h… yes
    checking float.h usability… yes
    checking float.h presence… yes
    checking for float.h… yes
    checking ieeefp.h usability… no
    checking ieeefp.h presence… no
    checking for ieeefp.h… no
    checking pthread.h usability… yes
    checking pthread.h presence… yes
    checking for pthread.h… yes
    checking ucontext.h usability… yes
    checking ucontext.h presence… yes
    checking for ucontext.h… yes
    checking intrinsics.h usability… no
    checking intrinsics.h presence… no
    checking for intrinsics.h… no
    checking time.h usability… yes
    checking time.h presence… yes
    checking for time.h… yes
    checking size of rlim_t… 8
    checking for size_t… yes
    checking for struct stat.st_blksize… yes
    checking for struct stat.st_blocks… yes
    checking for struct stat.st_rdev… yes
    checking for int8_t… yes
    checking size of int8_t… 1
    checking for uint8_t… yes
    checking size of uint8_t… 1
    checking for int16_t… yes
    checking size of int16_t… 2
    checking for uint16_t… yes
    checking size of uint16_t… 2
    checking for int32_t… yes
    checking size of int32_t… 4
    checking for uint32_t… yes
    checking size of uint32_t… 4
    checking for int64_t… yes
    checking size of int64_t… 8
    checking for uint64_t… yes
    checking size of uint64_t… 8
    checking for int128_t… no
    checking for uint128_t… no
    checking for struct timezone… yes
    checking for uid_t in sys/types.h… (cached) yes
    checking type of array argument to getgroups… gid_t
    checking return type of signal handlers… void
    checking for working alloca.h… yes
    checking for alloca… yes
    checking for working memcmp… no
    checking for _LARGEFILE_SOURCE value needed for large files… no
    checking for ftello… yes
    checking for broken erfc of glibc-2.3.6 on IA64… no
    checking for dup2… yes
    checking for memmove… yes
    checking for strcasecmp… yes
    checking for strncasecmp… yes
    checking for strerror… yes
    checking for strftime… yes
    checking for strchr… yes
    checking for strstr… yes
    checking for strtoul… yes
    checking for crypt… yes
    checking for flock… yes
    checking for vsnprintf… yes
    checking for isnan… yes
    checking for finite… yes
    checking for isinf… yes
    checking for hypot… yes
    checking for acosh… yes
    checking for erf… yes
    checking for fmod… yes
    checking for killpg… yes
    checking for wait4… yes
    checking for waitpid… yes
    checking for syscall… yes
    checking for chroot… yes
    checking for fsync… yes
    checking for getcwd… yes
    checking for eaccess… yes
    checking for truncate… yes
    checking for ftruncate… yes
    checking for chsize… no
    checking for times… yes
    checking for utimes… yes
    checking for fcntl… yes
    checking for lockf… yes
    checking for lstat… yes
    checking for symlink… yes
    checking for link… yes
    checking for readlink… yes
    checking for setitimer… yes
    checking for setruid… no
    checking for seteuid… yes
    checking for setreuid… yes
    checking for setresuid… yes
    checking for setproctitle… no
    checking for setrgid… no
    checking for setegid… yes
    checking for setregid… yes
    checking for setresgid… yes
    checking for issetugid… no
    checking for pause… yes
    checking for lchown… yes
    checking for lchmod… no
    checking for getpgrp… yes
    checking for setpgrp… yes
    checking for getpgid… yes
    checking for setpgid… yes
    checking for initgroups… yes
    checking for getgroups… yes
    checking for setgroups… yes
    checking for getpriority… yes
    checking for getrlimit… yes
    checking for setrlimit… yes
    checking for sysconf… yes
    checking for group_member… yes
    checking for dlopen… yes
    checking for sigprocmask… yes
    checking for sigaction… yes
    checking for sigsetjmp… no
    checking for _setjmp… yes
    checking for _longjmp… yes
    checking for setsid… yes
    checking for telldir… yes
    checking for seekdir… yes
    checking for fchmod… yes
    checking for mktime… yes
    checking for timegm… yes
    checking for gettimeofday… yes
    checking for cosh… yes
    checking for sinh… yes
    checking for tanh… yes
    checking for round… yes
    checking for setuid… yes
    checking for setgid… yes
    checking for setenv… yes
    checking for unsetenv… yes
    checking for __builtin_setjmp… no
    checking for setjmp type… _setjmp
    checking whether struct tm is in sys/time.h or time.h… time.h
    checking for struct tm.tm_zone… yes
    checking for struct tm.tm_gmtoff… yes
    checking for external int daylight… yes
    checking for external timezone… long
    checking for external altzone… no
    checking for negative time_t for gmtime(3)… yes
    checking whether getpgrp requires zero arguments… yes
    checking whether setpgrp takes no argument… yes
    checking whether byte ordering is bigendian… no
    checking for an ANSI C-conforming const… yes
    checking whether char is unsigned… yes
    checking for inline… inline
    checking for working volatile… yes
    checking whether right shift preserve sign bit… yes
    checking read count field in FILE structures… not found(OK if using GNU libc)
    checking read buffer ptr field in FILE structures… _IO_read_ptr
    checking read buffer end field in FILE structures… _IO_read_end
    checking whether need to seek between R/W… yes
    checking whether st_ino is huge… yes
    checking whether _SC_CLK_TCK is supported… yes
    checking stack growing direction… 0
    checking whether ELF binaries are produced… yes
    checking whether OS depend dynamic link works… yes
    checking for nroff… /usr/bin/nroff
    config.h unchanged
    configure: creating ./config.status
    config.status: creating Makefile
    configure: WARNING: unrecognized options: –disable-ipv6, –without-X11, –without-tk, –without-tcl
    + pwd
    + export LD_LIBRARY_PATH=/home/xl840/ltib_mx28/ltib/rpm/BUILD/ruby-1.8.7/ruby-1.8.7-p334
    + make RUBY_INSTALL_NAME=ruby COPY=cp -p
    make: ruby: Command not found
    make: *** [.rbconfig.time] Error 127
    error: Bad exit status from /home/xl840/ltib_mx28/ltib/tmp/rpm-tmp.93005 (%build)

    RPM build errors:
    Bad exit status from /home/xl840/ltib_mx28/ltib/tmp/rpm-tmp.93005 (%build)
    Build time for ruby: 32 seconds

    Failed building ruby

    f_buildrpms() returned an error, exiting
    traceback:
    main:560

    Started: Fri Aug 17 21:11:43 2012
    Ended: Fri Aug 17 21:12:16 2012
    Elapsed: 33 seconds

    These packages failed to build:
    ruby

    Build Failed

    Exiting on error or interrupt

    Thanks,
    Senthil.

  • Senthil says:

    Please ignore my previous comment, I have fixed this issue. My Host Ruby environment was not set properly.

    Thanks,
    Senthil.

  • Comments are closed.