mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
17487f9ebe
- This should actually be a merge but we made a mistake on the initial repo creation and a merge was not possible. - Below there is a resumed log of the commit messages for the few steps, just for the record. - The merged commit messages for this work are: - Removing Portuguese doc content - Ignore folder names fixed on .gitignore - Removed doc files which content migrated to the CMS - docdata.lua updated accordingly - Doc build checked ok - Overall doc structure and contents still being refined - Removing folder cache from git versioning - Removing folder dist from git versioning. The folders above are generated by the buildall.lua script and are not part of the sources - Adding .gitignore file with objects info to inform git what to ignore - Removed file - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - Moving all files and folders to a working doc folder - Css updated - Index page added and CSS adjusts - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com> - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - files deleted - Changed function that creates functions submenus. - Menu inserted with árvore, CSS adjusts, google search - Changed past design to new design - CSS updated - initial import - The commit ids were also preserved but they are related to this "other" work done on Led Lab. We'll keep the repo just in case. 4dce3f77c47b0c3001a2075a946e80ee52759b49 - Removing Portuguese doc content 78d8847525cacf045fe7e672cff6bd1e058a6a4b Ignore folder names fixed on .gitignore 48dee6b7962168ab1098bf709ead6f3cfe6b7964 - Removed doc files which content migrated to the CMS - docdata.lua updated accordingly - Doc build checked ok - Overall doc structure and contents still being refined 2aa2fe0c554db03dbc7029c34d0f4500fe625b37 - Removing folder cache from git versioning - Removing folder dist from git versioning The folders above are generated by the buildall.lua script and are not part of the sources - Adding .gitignore file with objects info to inform git what to ignore af6cc2890edf1855af319dc999a03feee5f9bee0 Removed file 6a180e72eb4f4860620cafc0685000e9f2174cfe Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git eb430112e78ae537459ab315e228ebca84bdf2d4 Moving all files and folders to a working doc folder d28a7c99489915630bd2625f3756fecf0d08ce37 Css updated 32836ffe382f04ab07c3e6f018c7b449a20d7a8d Index page added and CSS adjusts 1461d9957d9d25a1467cb57ab8717aa213a37e8d Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git ae1934c04f35a29e25bb4495ae8a31cd9c000b5b Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com> b5f31d70f1fac8d3fba325c9867a03f976775698 Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git ec9ad8446b7ea38b252c6a416e70774349835e45 files deleted bd7a80151b2030720ba8d8a303467d8c25a4b4b2 Changed function that creates functions submenus. 6a7494acaec694fadbb13520bcbccc51a6b95dfe Inserido menu com árvore, ajustes no CSS, busca do google e979f1c259d425c9a3be83f9cda20eddffe073bb Changed past design to new design. 381459e95286886b052103a0253e60b29e064d7a CSS updated 4f81d2f1195efe733fe5f97517be325d75937bc3 initial import
125 lines
6.0 KiB
HTML
125 lines
6.0 KiB
HTML
$$HEADER$$
|
|
<h3>Building GCC for i386</h3>
|
|
<p>At first, the idea of an i386 "cross" compiler under Linux seems
|
|
strange. After all, you're already running Linux on a i386 compatible
|
|
architecture. But the compiler is sometimes tied in mysterious ways
|
|
with the operating system it's running on (see for example <a href="http://wiki.osdev.org/GCC_Cross-Compiler">this page</a>
|
|
for some possible symptoms). And after all, you want to use Newlib, not
|
|
libc, and to customize your development environment as much as
|
|
possible. This tutorial will show you how to do that.</p>
|
|
|
|
<p><span class="warning">DISCLAIMER</span>: I'm by no means a specialist in the
|
|
GCC/newlib/binutils compilation process. I'm sure that there are better
|
|
ways to accomplish what I'm describing here, however I just wanted a
|
|
quick and dirty way to build a toolchain, I have no intention in
|
|
becoming too intimate with the build process. If you think that what I
|
|
did is wrong, inaccurate, or simply outrageously ugly, feel free to
|
|
<a href="overview.html#contacts">contact us</a> and I'll make the necessary corrections.
|
|
And of course, this tutorial comes without any guarantees whatsoever.</p>
|
|
|
|
<h2>Prerequisites</h2>
|
|
<p>To build your toolchain you'll need:</p>
|
|
|
|
<ul>
|
|
<li><b>GNU binutils</b>: as I'm writing this, the latest binutils version is 2.19.1, which
|
|
I'll be using in this tutorial. get it from <a href="http://ftp.gnu.org/gnu/binutils/">here</a>.</li>
|
|
<li><b>GCC</b>:as I'm writing this, the latest GCC version is
|
|
4.3.3, which I'll be using for this tutorial. Download it from <a href="http://gcc.gnu.org/mirrors.html">here</a> after choosing a suitable mirror.</li>
|
|
<li><b>Newlib</b>: as I'm writing this, the latest official Newlib version is 1.17.0, which I'll be using for this tutorial.
|
|
Download it from <a href="ftp://sources.redhat.com/pub/newlib/index.html">here</a>.</li>
|
|
<li>The tutorial assumes that you're using bash as your shell. If you use
|
|
something else, you might need to adjust some shell-specific commands. </li></ul>
|
|
|
|
<p>You need some support programs/libraries in order to compile the toolchain. To install them:</p>
|
|
<pre><code>$ sudo apt-get install flex bison libgmp3-dev libmpfr-dev autoconf texinfo build-essential</code></pre>
|
|
<p>Next, decide where you want to install your toolchain. They
|
|
generally go in <i>/usr/local/</i>, so I'm going to assume
|
|
<i>/usr/local/cross-i686</i> for this tutorial. To save yourself some
|
|
typing, set this path into a shell variable:</p>
|
|
<pre><code>$ export TOOLPATH=/usr/local/cross-i686</code></pre>
|
|
|
|
<h2>Step 1: binutils</h2>
|
|
|
|
<p>This is the easiest step: unpack, configure, build.</p>
|
|
|
|
<pre><code>$ tar -xvjf binutils-2.19.1.tar.bz2
|
|
$ cd binutils-2.19.1
|
|
$ mkdir build
|
|
$ cd build
|
|
$ ../configure --target=i686-elf --prefix=$TOOLPATH --with-gnu-as --with-gnu-ld --disable-nls
|
|
$ make all
|
|
$ sudo make install
|
|
$ export PATH=${TOOLPATH}/bin:$PATH
|
|
$ cd ../..</code></pre>
|
|
|
|
<p>Now you have your i386 "binutils" (assembler, linker, disassembler ...) in your PATH. </p>
|
|
|
|
<h2>Step 2: basic GCC</h2>
|
|
|
|
<p>In this step we build a "basic" GCC (that is, a GCC without any
|
|
support libs, which we'll use in order to build all the libraries for
|
|
our target). Let's compile it (and note that the install step is
|
|
a bit different from Newlib's):</p>
|
|
|
|
<pre><code>$ tar -xvjf gcc-4.3.3.tar.bz2
|
|
$ cd gcc-4.3.3
|
|
$ mkdir build
|
|
$ cd build
|
|
$ ../configure --target=i686-elf --prefix=$TOOLPATH --enable-languages="c,c++" --with-newlib --without-headers --disable-shared --with-gnu-as --with-gnu-ld
|
|
$ make all-gcc
|
|
$ sudo -s -H
|
|
# export PATH=/usr/local/cross-i686/bin:$PATH
|
|
# make install-gcc
|
|
# exit
|
|
$ cd ../..</code></pre>
|
|
|
|
<h2>Step 3: Newlib</h2>
|
|
|
|
<p>Once again, Newlib is as easy as unpack, configure, build. But I
|
|
wanted my library to be as small as possible (as opposed to as fast as
|
|
possible) and I only wanted to keep what's needed from it in the final
|
|
executable, so I added the "-ffunction-sections -fdata-sections" flags
|
|
to allow the linker to perform dead code stripping:</p>
|
|
|
|
<pre><code>$ tar -xvzf newlib-1.17.0.tar.gz
|
|
$ cd newlib-1.17.0
|
|
$ mkdir build
|
|
$ cd build
|
|
$ ../configure --target=i686-elf --prefix=$TOOLPATH --disable-newlib-supplied-syscalls --with-gnu-ld --with-gnu-as --disable-shared
|
|
$ make CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -Os -fomit-frame-pointer -D__BUFSIZ__=256"
|
|
$ sudo -s -H
|
|
# export PATH=/usr/local/cross-i686/bin:$PATH
|
|
# make install
|
|
# exit
|
|
$ cd ../..</code></pre>
|
|
|
|
<p>Some notes about the flags used in the above sequence:</p>
|
|
|
|
<ul>
|
|
<li><code>--disable-newlib-supplied-syscalls</code>: this deserves a page of its own, but I won't cover it here. For an explanation, see for example
|
|
<a href="http://openhardware.net/Embedded_ARM/NewLib_Stubs/">this page</a></li>
|
|
<li><code>-DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__</code>: compile Newlib for size, not for speed (these are Newlib specific).</li>
|
|
<li><code>-Os -fomit-frame-pointer</code>: tell GCC to optimize for size, not for speed.</li>
|
|
<li><code>-D__BUFSIZ__=256</code>: again Newlib specific, this is the buffer size allocated by default for files opened via fopen(). The default is 1024, which I find too much
|
|
for <b>eLua</b>, so I'm using 256 here. Of course, you can change this value.</li></ul>
|
|
|
|
<h2>Step 4: full GCC</h2>
|
|
|
|
<p>Finally, in the last step of our tutorial, we complete the GCC
|
|
build. In this stage, a number of compiler support libraries are built
|
|
(most notably libgcc.a). Fortunately this is simpler that the Newlib
|
|
compilation step:</p>
|
|
|
|
<pre><code>$ cd gcc-4.3.3/build
|
|
$ make all
|
|
$ sudo make install
|
|
</code></pre>
|
|
|
|
<h2>Step 5: all done!</h2>
|
|
|
|
<p>Now you can finally enjoy your i386 toolchain, and compile <b>eLua</b> with
|
|
it :) After you do, you'll be able to boot <b>eLua</b> directly on your PC, as
|
|
described <a href="tut_bootpc.html">here</a>, but you won't need to download the ELF file from the <b>eLua</b> project page, since you just generated it using your own toolchain!
|
|
If you need further clarification, or if the above instructions didn't work for you, feel free to <a href="overview.html#contacts">contact us</a>.</p>
|
|
$$FOOTER$$
|