[erlang-questions] reducing size of erlang

Matthias Lang <>
Tue Jul 15 19:47:33 CEST 2008


On Tuesday, July 15, Andrew Harris wrote:

>    I'm new to erlang, but not new to functional programming.  I am
> trying to compile erlang for the gumstix platform.  I think I've got
> it compiled OK, but the bin/ and lib/ directories that are generated
> from make install are really big.  I have read a few things on
> removing debugging info by adding an argument to each makefile in
> lib/, but this seems really tedious and I'm not sure how or where in
> the makefile to do this.  I'm wondering if there is a command I can
> pass to configure or something that will remove the debugging info
> from the erlang build.  Also, I'm building R10B-10 because this is the
> version I see some info on the web about how to build for a new
> platform.

Getting a basic, small Erlang down to 3MB is fairly straightforward.
Is 3MB "really big". I don't know, you didn't give me any clues about
what you were aiming for.

  1. Add the +compressed and +slim flags to the build
  2. Throw out all libraries you don't need.
  3. Throw out all binaries you don't need.
  4. Strip the remaining binaries.

#1 is easily done by applying the attached patch (for R11, but the idea
is the same) to a clean source tree. Clean means "before you run 'configure'".

#2 is a bit more of a chore. "Really tedious", maybe. If you can muster
   the will to do it, a quick way is to zap all libraries _apart_ from:

     erlang/lib/erlang/lib/stdlib
     erlang/lib/erlang/lib/kernel
     erlang/lib/erlang/lib/sasl

#3 is up to you. Chances are you don't need the dialyzer, epmd, erlc,
   beam.hybrid

#4 should be obvious.

You can, of course, do more for a bit more effort. But it sounded like
you were struggling to make it from the couch to the fridge ;-)

Matt
-------------- next part --------------
--- otp.mk.in.orig	2007-01-16 00:05:19.000000000 +0100
+++ otp.mk.in	2007-01-16 00:06:22.000000000 +0100
@@ -69,21 +69,7 @@
 #	Erlang language section
 # ----------------------------------------------------
 EMULATOR = beam
-ifeq ($(findstring vxworks,$(TARGET)),vxworks)
-# VxWorks object files should be compressed.
-# Other object files should have debug_info.
-  ERL_COMPILE_FLAGS += +compressed
-else
-  ifeq ($(findstring ose_ppc750,$(TARGET)),ose_ppc750)
-    ERL_COMPILE_FLAGS += +compressed
-  else
-    ifdef BOOTSTRAP
-      ERL_COMPILE_FLAGS += +slim
-    else
-      ERL_COMPILE_FLAGS += +debug_info
-    endif
-  endif
-endif
+ERL_COMPILE_FLAGS += +compressed +slim
 ERLC_WFLAGS = -W
 ERLC = erlc $(ERLC_WFLAGS) $(ERLC_FLAGS)
 ERL = erl -boot start_clean


More information about the erlang-questions mailing list