Why Build From Source?
You might want to modify one of the ELLCC components or a run-time library. Or you just might like your installed software built from source for security or philosophical reasons. No matter the reason, building all or part of ELLCC from source is easy.
You can build ELLCC from source in a couple of ways. The easiest way is to install a binary release from the Download page and use that to build itself. The second way is bootstrap ELLCC using the C/C++ compilers that you already have on your system. Both methods are described below.
You’ll need a few other tools installed on your system to build the entire ELLCC tool chain.
Here is the list that I’ve found. If I missed any, please leave a message in the forum.
- bash – The scripts assume /bin/bash is available. If it is installed somewhere else on your system, you need to make a symbolic link in /bin.
- subversion (Unless you download the source tarball, see below)
- git (Unless you download the source tarball, see below)
Getting the Source
Before you build you need to decide how to get the source files. Again, there are two methods you can use. The first is to just start the build. The build system will download the appropriate versions of the ELLCC components from their home repositories and apply any ELLCC specific patches that might be required.
Getting the sources from the repositories directly might be a problem if you are behind a firewall because you might not be allowed to do git clones, for example. There is another way which is to run ellcc install src (See Installation for more information on the ellcc command). This command will download a tarball of all the sources used to build the version of ELLCC that was used to build your binary distribution or the latest release sources if you choose to bootstrap ELLCC entirely from source.
Building ELLCC with Itself
If you choose to go this route, building ELLCC is a simple as running ellcc build. This will build everything: The compiler, assemblers, linker, debugger, libraries, and other tools for your host system. See below for information on building selected components and for other hosts.
Bootstrapping ELLCC with the Host Compiler
Bootstrapping from source is only slightly more complicated. The first thing you need to do is to get ELLCC from the source repository like this:
[test@main ~]$ svn co http://ellcc.org/svn/ellcc/trunk ellcc A ellcc/libecc A ellcc/libecc/patches A ellcc/libecc/patches/clang ... A ellcc/scripts/build-compiler-rt A ellcc/scripts/build-libcxx A ellcc/scripts/build-llvm A ellcc/scripts/build-zlib A ellcc/scripts/make-ellcc A ellcc/scripts/release-branch A ellcc/LICENSE.TXT U ellcc Checked out revision 7582. [test@main ~]$
There aren’t too many files in the repository so the check out will be quick. You’ll get a directory like this:
[test@main ~]$ cd ellcc [test@main ellcc]$ ls ChangeLog ellcc libecc LICENSE.TXT scripts [test@main ellcc]$
You can look around if you want but the files consist of shell scripts, configuration files and patches.
Now you can run ./ellcc build and wait. The build system will use your host compiler to build clang from the LLVM sources as well as binutils. When that build is finished clang will be used to build itself, binutils, and the run-time libraries needed for building ELLCC. This build will produce ecc and ecc++ that will be used to build ELLCC again to produce the final ELLCC package.
The build system will look for installed compilers named ecc, clang, cc, and gcc in that order to to do the first bootstrap build. After that, the newly build compiler will be used.
Building Other Components
You can build components of ELLCC similarly. For example, ellcc libraries can be used to build one or more libraries for cross targets:
[test@main ellcc]$ ellcc libraries usage: /home/test/ellcc/bin/ellcc libraries [all|
...] Build libraries for all or selected targets. targets: arm64v8-linux arm32v6-linux arm32v6sf-linux arm32v7-linux arm32v7sf-linux mips32r2el-linux mips32r2elsf-linux mips32r2-linux mips32r2sf-linux mips64r2-linux ppc32-linux ppc64el-linux x86_64-linux [test@main ellcc]$
So a command like ellcc libraries arm32v7-linux will build the run-time libraries needed for a Raspberry Pi 2.
Building for Other Hosts
You can use ELLCC to build itself to run on another host easily. The command ellcc build arm32v7-linux will build a set of tools that will run on the Raspberry Pi 2 or other 32 bit ARM Linux system.