cross compiling howto for mips-openwrt-linux

Attila Lendvai attila at lendvai.name
Thu Sep 24 15:18:28 UTC 2015


hi!

with the invaluable help of jackdaniel on #ecl, i've managed to
cross compile ecl for mips-openwrt-linux.

unfortunately i cannot edit the wiki at, so i'll write it up here. (if
anyone reads it an can give me rights, my user is attila.lendvai)

FTR, https://gitlab.com/embeddable-common-lisp/ecl/wikis/home


the bird's eye view:

 - first you need to compile ecl on the host, but making sure that
   some important variables are the same as on the target (e.g. 32/64
   bit; long long support; what else?).

 - then make clean, and configure the source tree for the target

   - ./configure will fail when run for the first time. you'll then
     need to edit 'build/cross_config' to set some variables regarding
     the target that cannot be detected automatically from the host.

 - then build it once again using a cross-compiling gcc

 - if you are not planning to have a gcc on the target, then configure
   the target with --with-bytecmp=builtin --with-cmp=no


compile for the host:

 - you may need 32 bit support: sudo apt-get install gcc-multilib

 - CFLAGS=-m32 LDFLAGS=-m32 ABI=32 ./configure --prefix=/opt/ecl-host
--enable-longdouble=no

 - make -j2

 - make install


compile for the target:

make clean

export STAGING_DIR=/home/alendvai/workspace/OpenWrt-SDK-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir

export TOOLCHAIN=${STAGING_DIR}/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/

export TARGETROOT=${STAGING_DIR}/target-mips_34kc_uClibc-0.9.33.2/

PATH=/opt/ecl-host/bin/:${TOOLCHAIN}/bin:${PATH} \
 CFLAGS="-I${TOOLCHAIN}/include -I${TARGETROOT}/usr/include" \
 LDFLAGS="--sysroot=${TARGETROOT}" ./configure \
 --prefix=/opt/ecl-mips --disable-longdouble \
 --with-libffi-prefix=${TARGETROOT} \
 --host=mips-openwrt-linux --with-system-gmp

optionally add: --with-bytecmp=builtin --with-cmp=no

edit 'build/cross_config' and restart the above once again. (in this
specific case i had to ECL_BIGENDIAN=yes)

PATH=/opt/ecl-host/bin/:${TOOLCHAIN}/bin:${PATH} make -j2

copy /opt/ecl-mips to your openwrt and don't forget to:
opkg install libgmp
opkg install libffi

i will try to put together an openwrt package, too.

-- 
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“People get used to anything. The less you think about your
oppression, the more your tolerance for it grows. After a while,
people just think oppression is the normal state of things. But to
become free, you have to be acutely aware of being a slave.”
	— Assata Shakur (1947–), 'Assata: An Autobiography'



More information about the ecl-devel mailing list