[erlang-questions] reducing size of erlang

Andrew Harris andrew.unit@REDACTED
Sat Jul 19 21:06:00 CEST 2008


Hi everyone,

   I'm still working on getting Erlang cross compiled for the arm
platform.  I had previously been using rev 10, but I decided to go
with R12B-3 so that I could be up to date and maybe get more help.  I
have decided to create a shell script that tries to do the cross
compile starting from just the tar file so that I can make sure I do
the same thing on every attempt.  This script incorporates diffs I got
from Matt as well as another one I found online:

#!/bin/bash -v

RELEASE=otp_src_R12B-3
TARGET=arm-angstrom-linux-gnueabi
INSTALL_DIR=/tmp/cross-compile

export ac_cv_c_bigendian=no
export ac_cv_func_setvbuf_reversed=no
export ac_cv_func_mmap_fixed_mapped=yes
export ac_cv_sizeof_long_long=8
export ac_cv_sizeof_off_t=8
export ac_cv_func_getaddrinfo=no

rm -rf ${INSTALL_DIR}
rm -rf ${RELEASE}
tar xvf "${RELEASE}.tar.gz"
cd ${RELEASE}

# Deal with the make patch
cd make
echo '--- otp.mk.in.orig      2007-01-16 00:05:19.000000000 +0100' > makepatch
echo '+++ otp.mk.in   2007-01-16 00:06:22.000000000 +0100' >> makepatch
echo '@@ -69,21 +69,7 @@' >> makepatch
echo ' #      Erlang language section' >> makepatch
echo ' # ----------------------------------------------------' >> makepatch
echo ' EMULATOR = beam' >> makepatch
echo '-ifeq ($(findstring vxworks,$(TARGET)),vxworks)' >> makepatch
echo '-# VxWorks object files should be compressed.' >> makepatch
echo '-# Other object files should have debug_info.' >> makepatch
echo '-  ERL_COMPILE_FLAGS += +compressed' >> makepatch
echo '-else' >> makepatch
echo '-  ifeq ($(findstring ose_ppc750,$(TARGET)),ose_ppc750)' >> makepatch
echo '-    ERL_COMPILE_FLAGS += +compressed' >> makepatch
echo '-  else' >> makepatch
echo '-    ifdef BOOTSTRAP' >> makepatch
echo '-      ERL_COMPILE_FLAGS += +slim' >> makepatch
echo '-    else' >> makepatch
echo '-      ERL_COMPILE_FLAGS += +debug_info' >> makepatch
echo '-    endif' >> makepatch
echo '-  endif' >> makepatch
echo '-endif' >> makepatch
echo '+ERL_COMPILE_FLAGS += +compressed +slim' >> makepatch
echo ' ERLC_WFLAGS = -W' >> makepatch
echo ' ERLC = erlc $(ERLC_WFLAGS) $(ERLC_FLAGS)' >> makepatch
echo ' ERL = erl -boot start_clean' >> makepatch
cat makepatch | patch -p0
cd ..

# Deal with configure patch
cd erts
echo '--- configure.in.orig   2006-03-17 17:38:39.000000000 +0100' >>
configurepatch
echo '+++ configure.in        2006-03-17 17:29:23.000000000 +0100' >>
configurepatch
echo '@@ -1322,7 +1322,7 @@' >> configurepatch
echo '   exit(0);' >> configurepatch
echo ' #endif' >> configurepatch
echo ' }' >> configurepatch
echo '-], poll_works=true, poll_works=false, poll_works=false)' >>
configurepatch
echo '+], poll_works=true, poll_works=false, poll_works=true)' >> configurepatch
echo ' case $poll_works in' >> configurepatch
echo ' true)' >> configurepatch
echo '        AC_MSG_RESULT(ok)' >> configurepatch
echo '@@ -1365,7 +1365,12 @@' >> configurepatch
echo '     DED_CFLAGS="$DED_CFLAGS -fPIC"' >> configurepatch
echo ' fi' >> configurepatch
echo ' ' >> configurepatch
echo '-DED_LD=ld' >> configurepatch
echo '+if test "x$LD" = x; then' >> configurepatch
echo '+ DED_LD=ld' >> configurepatch
echo '+else' >> configurepatch
echo '+ DED_LD=$LD' >> configurepatch
echo '+fi' >> configurepatch
echo '+' >> configurepatch
echo ' DED_LD_FLAG_RUNTIME_LIBRARY_PATH="-R"' >> configurepatch
echo ' STATIC_CFLAGS=""' >> configurepatch
cat configurepatch | patch -p0
autoconf configure.in > configure
cd ..

./configure --prefix=${INSTALL_DIR} --without-ssl --without-java
--disable-hipe --disable-smp-support --host=${TARGET}
--build=i686-pc-linux-gnu
TARGET=${TARGET} make noboot

   I have read online that one problem in cross compiling involves
hipe_mkliterals, that seems to need to be compiled with the native C
compiler on the build computer.  I don't really know how to modify the
file erts/emulator/Makefile.in to somehow get it to use the native
compiler for that.  I tried some simple stuff, but I couldn't get it
to work.  The output below shows the arm compiler being used to
compile hipe_mkliterals, which seems to be the problem.

arm-angstrom-linux-gnueabi-gcc -g -O2
-I/project/otp_src_R12B-3/erts/arm-angstrom-linux-gnueabi
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -D_GNU_SOURCE
-DHAVE_CONFIG_H -Wall -Wstrict-prototypes -Wmissing-prototypes
-Wdeclaration-after-statement -DUSE_THREADS -D_THREAD_SAFE
-D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS  -Ibeam -Isys/unix
-Isys/common -Iarm-angstrom-linux-gnueabi/opt/plain
-Iarm-angstrom-linux-gnueabi -Izlib -Ipcre -Ihipe
-I../include/internal -I../include/internal/arm-angstrom-linux-gnueabi
-o /project/otp_src_R12B-3/bin/arm-angstrom-linux-gnueabi/hipe_mkliterals
obj/arm-angstrom-linux-gnueabi/opt/plain/hipe_mkliterals.o
/project/otp_src_R12B-3/bin/arm-angstrom-linux-gnueabi/hipe_mkliterals
-c > arm-angstrom-linux-gnueabi/opt/plain/hipe_literals.h
/bin/sh: /project/otp_src_R12B-3/bin/arm-angstrom-linux-gnueabi/hipe_mkliterals:
cannot execute binary file
make[4]: *** [arm-angstrom-linux-gnueabi/opt/plain/hipe_literals.h] Error 126
make[4]: Leaving directory `/project/otp_src_R12B-3/erts/emulator'
make[3]: *** [generate] Error 2
make[3]: Leaving directory `/project/otp_src_R12B-3/erts/emulator'
make[2]: *** [opt] Error 2
make[2]: Leaving directory `/project/otp_src_R12B-3/erts'
make[1]: *** [emulator] Error 2
make[1]: Leaving directory `/project/otp_src_R12B-3'
make: *** [noboot] Error 2
# TARGET=${TARGET} make install
andrewha@REDACTED:/project$

Any help would be appreciated.  In particular if someone has a patch
to solve this hipe_mkliterals problem I'll include it in the script
(and when the script works I'll post it here)

thanks,
-andrew



More information about the erlang-questions mailing list