<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://elinux.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://elinux.org/index.php?title=CELF_Project_Proposal/Combine_tcg_with_tcc&amp;feed=atom&amp;action=history</id>
		<title>CELF Project Proposal/Combine tcg with tcc - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://elinux.org/index.php?title=CELF_Project_Proposal/Combine_tcg_with_tcc&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=CELF_Project_Proposal/Combine_tcg_with_tcc&amp;action=history"/>
		<updated>2013-05-25T17:06:31Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.22alpha</generator>

	<entry>
		<id>http://elinux.org/index.php?title=CELF_Project_Proposal/Combine_tcg_with_tcc&amp;diff=15895&amp;oldid=prev</id>
		<title>Tim Bird: add proposal</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=CELF_Project_Proposal/Combine_tcg_with_tcc&amp;diff=15895&amp;oldid=prev"/>
				<updated>2009-12-22T01:20:36Z</updated>
		
		<summary type="html">&lt;p&gt;add proposal&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;; Summary : Combine qemu's tcg with tcc to create a new embedded compiler&lt;br /&gt;
&lt;br /&gt;
; Proposer : Rob Landley&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
The QEMU project has a fairly general purpose &amp;quot;Tiny Code Generator&amp;quot; which is &lt;br /&gt;
capable of producing machine code for every target QEMU supports.  This code &lt;br /&gt;
generator is well maintained (by the qemu development community), operates &lt;br /&gt;
extremely rapidly (producing code &amp;quot;on the fly&amp;quot;), and supports a large and &lt;br /&gt;
increasing number of platforms, even distinguishing many specific variants &lt;br /&gt;
within each platform (the qemu -cpu options).&lt;br /&gt;
&lt;br /&gt;
Before QEMU, Fabrice Bellard's previous open source project was the Tiny C &lt;br /&gt;
Compiler (tcc), which was notable for its small size (approximately 100k for a &lt;br /&gt;
combined compiler/assembler/linker), its self-contained nature (not requiring &lt;br /&gt;
external packages such as binutils), its speed of compilation (millions of &lt;br /&gt;
lines of source code per second even on low-end hardware), and its &amp;quot;-run&amp;quot; mode &lt;br /&gt;
(allowing use of C as a scripting language by starting a source file with &lt;br /&gt;
&amp;quot;#!/usr/bin/tcc -run&amp;quot; and setting the executable bit on the source file).&lt;br /&gt;
&lt;br /&gt;
Tinycc provides almost full c99 support (most notably missing complex number &lt;br /&gt;
support and variable extent arrays).  In 2004, tinycc became the only open &lt;br /&gt;
source compiler other than gcc to compile a working LInux kernel (albeit in &lt;br /&gt;
limited circumstances).  Fabrice Bellard created &amp;quot;tccboot&amp;quot;, a proof-of-concept &lt;br /&gt;
project in which tcc was used to boot a Linux kernel directly from source &lt;br /&gt;
code.  The tccboot ISO image booted directly into a modified tcc binary bundled &lt;br /&gt;
with a modified subset of the 2.4 Linux kernel source.  It compiled this source &lt;br /&gt;
to create a vmlinux, which it then executed.&lt;br /&gt;
&lt;br /&gt;
QEMU actually started as an offshoot of tcc.  When fabrice looked into &lt;br /&gt;
providing multiple output formats for tcc (to support targets other than 32-&lt;br /&gt;
bit x86), he started playing with multiple input formats as well, such as &lt;br /&gt;
pages of existing machine code.  The result was qemu, which is actually a &lt;br /&gt;
&amp;quot;dynamic recompiler&amp;quot; rather than an emulator.&lt;br /&gt;
&lt;br /&gt;
The TCC project stalled when QEMU expanded to take up all Fabrice's time, and &lt;br /&gt;
the project remained moribund for several years.  (Recently the original tcc &lt;br /&gt;
has been relaunched as a windows-centric project, but its current maintainer &lt;br /&gt;
has shown little to no interest in Linux or non-x86 targets.)&lt;br /&gt;
&lt;br /&gt;
The tcc codebase as Fabrice left it provides an almost complete c99 compiler.  &lt;br /&gt;
Combined with qemu's code generator, this could provide a small fast compiler &lt;br /&gt;
capable of running on and producing output for a wide range of embedded &lt;br /&gt;
hardware.&lt;br /&gt;
&lt;br /&gt;
Creating a &amp;quot;qcc&amp;quot; from tcc and tcg would involve:&lt;br /&gt;
&lt;br /&gt;
1) Turn tcc into a &amp;quot;swiss army knife&amp;quot; executable (like busybox) so it its &lt;br /&gt;
individual functions could be called as cc, ld, as, strip, cpp, and so on.&lt;br /&gt;
&lt;br /&gt;
1A) optional - use the Firmware Linux ccwrap.c code to increase understanding &lt;br /&gt;
of gcc command line options.&lt;br /&gt;
&lt;br /&gt;
1B) optional - add missing utilities such as readelf, objdump, objcopy...&lt;br /&gt;
&lt;br /&gt;
2) Refactor the code to untangle preprocessor, compiler, assembler, and linker &lt;br /&gt;
functions.&lt;br /&gt;
&lt;br /&gt;
3) Replace existing target code generation with qemu's tcg.&lt;br /&gt;
&lt;br /&gt;
4) Add support infrastructure for targets supported by tcg (assembly code &lt;br /&gt;
parser, ELF header information) &lt;br /&gt;
&lt;br /&gt;
5) Add missing functionality needed to build unmodified Linux 2.6, BusyBox, and &lt;br /&gt;
uClibc.  (The linux kernel needs variable extent arrays, simple dead code &lt;br /&gt;
elimination, assembly output (at least via objdump) to generate&lt;br /&gt;
asm-offsets.h...)&lt;br /&gt;
&lt;br /&gt;
== Related Work ==&lt;br /&gt;
&lt;br /&gt;
== Comments ==&lt;br /&gt;
&lt;br /&gt;
[[Category:Project proposals]]&lt;/div&gt;</summary>
		<author><name>Tim Bird</name></author>	</entry>

	</feed>