<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Politreco &#187; compiler</title>
	<atom:link href="http://www.politreco.com/tag/compiler/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.politreco.com</link>
	<description>by Lucas De Marchi</description>
	<lastBuildDate>Fri, 06 Jan 2012 04:50:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Compiler&#8217;s compiler version</title>
		<link>http://www.politreco.com/2009/08/compilers-compiler-version/</link>
		<comments>http://www.politreco.com/2009/08/compilers-compiler-version/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 00:06:22 +0000</pubDate>
		<dc:creator>Lucas De Marchi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[The chicken or the egg causality dilemma]]></category>

		<guid isPermaLink="false">http://www.politreco.com/?p=157</guid>
		<description><![CDATA[Today I was just wondering&#8230; what&#8217;s the version of the compiler which compiled my compiler. Quite a strange question to make myself and I really don&#8217;t know where this curiosity came from. Looking in Wikipedia: Early compilers were written in assembly language. The first self-hosting compiler — capable of compiling its own source code in [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was just wondering&#8230; what&#8217;s the version of the compiler which compiled my compiler. Quite a strange question to make myself and I really don&#8217;t know where this curiosity came from.</p>
<p>Looking in <a title="Compiler" href="http://en.wikipedia.org/wiki/Compiler" target="_blank">Wikipedia</a>:</p>
<blockquote><p>Early compilers were written in assembly language. The first <em><a title="Self-hosting" href="http://en.wikipedia.org/wiki/Self-hosting">self-hosting</a></em> compiler — capable of compiling its own source code in a high-level language — was created for <a title="Lisp programming language" href="http://en.wikipedia.org/wiki/Lisp_programming_language">Lisp</a> by Tim Hart and Mike Levin at <a title="Massachusetts Institute of Technology" href="http://en.wikipedia.org/wiki/Massachusetts_Institute_of_Technology">MIT</a> in 1962.<sup id="cite_ref-1"><a href="http://en.wikipedia.org/wiki/Compiler#cite_note-1"><span>[</span>2<span>]</span></a></sup> Since the 1970s it has become common practice to implement a compiler in the language it compiles, although both <a title="Pascal (programming language)" href="http://en.wikipedia.org/wiki/Pascal_%28programming_language%29">Pascal</a> and <a title="C (programming language)" href="http://en.wikipedia.org/wiki/C_%28programming_language%29">C</a> have been popular choices for implementation language. Building a self-hosting compiler is a <a title="Bootstrapping (compilers)" href="http://en.wikipedia.org/wiki/Bootstrapping_%28compilers%29">bootstrapping</a> problem &#8212; the first such compiler for a language must be compiled either by a compiler written in a different language, or (as in Hart and Levin&#8217;s Lisp compiler) compiled by running the compiler in an <a title="Interpreter (computing)" href="http://en.wikipedia.org/wiki/Interpreter_%28computing%29">interpreter</a>.</p></blockquote>
<p>Interesting, don&#8217;t you think? So let&#8217;s see the version of your compiler&#8217;s compiler. If you use GCC, it will put a comment in section named (surprise!) .comment. Generate the assembly correspondent to a C source code and you are going to see in the end of the file an entry like this:</p>
<blockquote><p>.size   main, .-main<br />
.ident  &#8220;GCC: (GNU) 4.4.1&#8243;<br />
.section        .note.GNU-stack,&#8221;",@progbits</p></blockquote>
<p>So, let&#8217;s play with our already compiled compiler. First we have to check the compiler version:</p>
<blockquote><p>[lucas@skywalker tmp]$ gcc -v<br />
Using built-in specs.<br />
Target: i686-pc-linux-gnu<br />
Configured with: ../configure &#8211;prefix=/usr &#8211;enable-shared &#8211;enable-languages=c,c++,fortran,objc,obj-c++ &#8211;enable-threads=posix &#8211;mandir=/usr/share/man &#8211;infodir=/usr/share/info &#8211;enable-__cxa_atexit &#8211;disable-multilib &#8211;libdir=/usr/lib &#8211;libexecdir=/usr/lib &#8211;enable-clocale=gnu &#8211;disable-libstdcxx-pch &#8211;with-tune=generic<br />
Thread model: posix<br />
gcc version 4.4.1 (GCC)</p></blockquote>
<p>Ok! Version 4.4.1. Let&#8217;s use the readelf command to see the content of .comment section:</p>
<blockquote><p>[lucas@skywalker tmp]$ readelf -p .comment /usr/bin/gcc</p>
<p>String dump of section &#8216;.comment&#8217;:<br />
[     1]  GCC: (GNU) 4.4.0 20090630 (prerelease)<br />
[    29]  GCC: (GNU) 4.4.0 20090630 (prerelease)<br />
[    51]  GCC: (GNU) 4.4.1</p></blockquote>
<blockquote><p>[    63]  GCC: (GNU) 4.4.1</p></blockquote>
<blockquote><p>(&#8230;)</p></blockquote>
<blockquote><p>[   237]  GCC: (GNU) 4.4.1<br />
[   249]  GCC: (GNU) 4.4.1<br />
[   25b]  GCC: (GNU) 4.4.0 20090630 (prerelease)<br />
[   283]  GCC: (GNU) 4.4.1<br />
[   295]  GCC: (GNU) 4.4.0 20090630 (prerelease)</p></blockquote>
<p>I didn&#8217;t understand if it&#8217;s 4.4.1 or 4.4.0, i.e. if it was used a prior version to compile the current version or if current was recompiled afterwards with this new compiler produced.  Testing random binaries in /usr/bin seems to produce similar effects, having more than one version.</p>
<p>So&#8230; no answers yet. Any clues?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.politreco.com/2009/08/compilers-compiler-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

