|Line 1:||Line 1:|
|−|== Author == |+|
| || |
Revision as of 15:23, 15 June 2007
order viagra lorazepam online ultram online kyocera ringtones order alprazolam alltel ringtones ambien online cheap vicodin motorola ringtones sony ericsson ringtones punk ringtones buy viagra phentermine xanax online buy ultram valium online cingular ringtones buy adipex cyclobenzaprine online propecia online tenuate online cheap carisoprodol cheap ultracet pharmacy online online wwe ringtones diazepam online xenical online nokia ringtones free qwest ringtones zanaflex online diazepam online free verizon ringtones motorola ringtones lortab online prozac online free ericsson ringtones cheap ortho cheap cyclobenzaprine celexa online free ringtones online phentermine free cool ringtones cheap prozac qwest ringtones cheap cialis sprint ringtones cheap nexium real ringtones free sagem ringtones tracfone ringtones free nokia ringtones punk ringtones free mp3 ringtones free sony ringtones ativan online hgh midi ringtones alltel ringtones cheap flexeril sony ericsson ringtones motorola ringtones cheap vicodin tracfone ringtones soma online levitra online free motorola ringtones cheap didrex cheap sildenafil pharmacy online online zoloft online hydrocodone online sony ringtones free cingular ringtones online viagra buy paxil ambien online lortab online order hydrocodone vigrx online cheap ativan hgh online cheap sildenafil viagra online buy ortho nextel ringtones lisinopril online free funny ringtones free sony ericsson ringtones vicodin online but hydrocodone ativan online free mono ringtones clonazepam online online levitra sprint ringtones cialis online sony ringtones levitra online cheap zanaflex but phentermine order celexa cheap ultracet wwe ringtones sharp ringtones norco online soma cheap ultracet free cingular ringtones cheap adipex cheap xenical order albuterol tenuate online ortho online music ringtones sagem ringtones lisinopril online cheap meridia propecia online cheap vigrx diethylpropion online cheap albuterol free mp3 ringtones meridia online free free ringtones cheap ultram soma online cheap lortab sildenafil online nextel ringtones cheap lorazepam funny ringtones buy diethylpropion free free ringtones funny ringtones free cingular ringtones soma online free nokia ringtones cheap clonazepam cheap zyban cheap clomid prozac online online valium lisinopril online meridia online buy tramadol sharp ringtones midi ringtones cheap flexeril real ringtones celexa online cheap zoloft nextel ringtones free ericsson ringtones music ringtones mtv ringtones cheap ultram buy valium cheap viagra cheap lorazepam cialis online phentermine online buy nexium samsung ringtones cheap norco cheap meridia sprint ringtones rivotril online cheap carisoprodol cheap carisoprodol buy cyclobenzaprine qwest ringtones free qwest ringtones fioricet online free verizon ringtones punk ringtones cheap hoodia pharmacy online online tracfone ringtones online tramadol rivotril online cheap tramadol didrex online cheap fioricet music ringtones albuterol online free nokia ringtones viagra online alprazolam online buy xenical buy pharmacy online funny ringtones order zanaflex free ericsson ringtones cyclobenzaprine online cheap adipex cheap xanax free alltel ringtones free qwest ringtones ultram online free sonyericsson ringtones == Author ==
Why Cross Compile
Cross compiling means using one type of system to compile the Erlang runtime system for a different type of system. A typical example would
be using an x86-based linux system to compile Erlang for an embedded MIPS CPU.
You usually cross compile when you want to run Erlang on a system which doesn't have its own development environment, i.e. no C compiler, libraries and make system.
In this howto, the term target means the system you want to run Erlang on when you're finished. The term build platform means the system you're using to compile the Erlang runtime system.
- A working C compiler and C libraries. Verify that it generates object files which run on the target, for instance by writing hello world. This howto assumes that your build platform is a unix or unix-like system.
- The autoconf tools.
- The Erlang/OTP source code, from erlang.org. The examples assume R10B-10.
- Some cross-compiling experience. If you've never cross-compiled before, it's probably worth starting with something a bit simpler than Erlang, just to get a feeling for how it's meant to work. One suggestion: busybox.
- Experience with native compiling Erlang. If you haven't built the Erlang runtime from source before, do that first, to get a feeling for how it's meant to work.
- A generous serving of gumption.
Unpack the source
Make a directory for the cross compiling work, say /usr/local/src/mips_erlang/ and untar the source distribution there.
Patch the configure script
A couple of small changes to the configure script supplied with the Erlang source makes cross compiling much easier. Take this patch:
--- configure.in.orig 2006-03-17 17:38:39.000000000 0100
configure.in 2006-03-17 17:29:23.000000000 0100
@@ -1322,7 1322,7 @@
-], poll_works=true, poll_works=false, poll_works=false)
], poll_works=true, poll_works=false, poll_works=true)
case $poll_works in
@@ -1365,7 1365,12 @@
if test "x$LD" = x; then
and apply it in the erts/ directory in the source tree you just unpacked.
After applying the patch, you need to re-run autoconf to update the configure script:
autoconf configure.in > configure
Set environment variables for non-detectable features
In a native compile, the 'configure' script autodetects many settings by compiling and running small C programs. When cross compiling, this isn't possible, so you need to do some manual setup to override the autodetection:
The values of the variables above are correct for an AU1000 MIPS CPU running linux 2.4.x. They're probably not correct for your particular system. You need to manually figure out the right settings, i.e. is your system bigendian? How large is a long_long on your system? If you're not sure, write a short C program to find out, and run the C program on your target.
Set environment variables to set up the C compiler
Next, we need to set up the environment so that we use the right C compiler and related tools:
The above settings are correct for an Au1000 MIPS on linux target. Your settings are likely to be different.
Manually disable parts of HiPE
Some HiPE-related code attempts to run during the build process in spite of the --disable-hipe flag. The code fails because it expects the build host and target system to be the same.
A quick and dirty way to disable that is to manually edit erts/emulator/Makefile.in and kill HIPE_GENERATE. In addition, edit lib/Makefile and remove hipe from the OTHER_SUB_DIRECTORIES list.
Run the configure script
./configure --prefix=/tmp/cross_compiled --without-ssl --without-java --disable-hipe --host=mips-linux --build=i686-pc-linux-gnu
Assuming configure ran all the way through without failing, we're now ready to compile. At this point, it's worth spending five minutes manually browsing through 'config.h' and checking that everything looks reasonable. For instance, you can check that the endianness settings are correct for your system.
TARGET=mips-linux make noboot | cat > buildlog
The above will take a while. After it's done, you probably want to install the Erlang runtime somewhere. Become root, and then:
TARGET=mips-linux make install
Correct the bin/erl path
There's one thing left to manually fix: the installed copy of the Erlang runtime will have some incorrect paths in it. Edit 'bin/erl' by hand to fix that.
Slim the system
Disk space is often limited on embedded systems. By deleting parts of OTP you don't use, stripping binaries and recompiling all .beams without debug information and with the compressed flag, it's
possible to get the entire Erlang system down to less than 3MB.
The build system in Open Source Erlang includes some relatively unappetising support for cross compiling to a VxWorks target.
Matthias Lang realised that for "similar build and target systems", it was possible to run 'configure' natively on the build system, hack the resulting makefiles to take into account differences between the build and target and then compile using a cross compiler.
Brian Zhou then pointed out how to use manual overrides through environment variables to avoid much of the hacking.
The methods described in this article are used to cross-compile Erlang for Motorola MPC 860 PPC systems, Au1000 MIPS systems, NSLU2, and most optware platforms.