<?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>Jeff Sinclair's Website &#187; openjdk</title>
	<atom:link href="http://www.cooljeff.co.uk/tag/openjdk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cooljeff.co.uk</link>
	<description>my 2 pence to the world</description>
	<lastBuildDate>Sat, 12 Dec 2009 22:17:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Building the OpenJDK on Ubuntu 8.10</title>
		<link>http://www.cooljeff.co.uk/2009/01/03/building-the-openjdk-on-ubuntu-810/</link>
		<comments>http://www.cooljeff.co.uk/2009/01/03/building-the-openjdk-on-ubuntu-810/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 23:54:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[openjdk]]></category>

		<guid isPermaLink="false">http://www.cooljeff.co.uk/?p=79</guid>
		<description><![CDATA[When I asked a colleague at work what I should do during my vacation, he said build the OpenJDK&#8230; so I did!
In hindsight, it would have been easier to have built IcedTea (RedHat&#8217;s OpenJDK hybrid) rather than Sun&#8217;s raw OpenJDK. However since I spent quite a bit of time setting up the environment I was [...]]]></description>
			<content:encoded><![CDATA[<p>When I asked a colleague at work what I should do during my vacation, he said build the OpenJDK&#8230; so I did!</p>
<p>In hindsight, it would have been easier to have built IcedTea (RedHat&#8217;s OpenJDK hybrid) rather than Sun&#8217;s raw OpenJDK. However since I spent quite a bit of time setting up the environment I was determined to get it to build.</p>
<p>At a high level I did the following:</p>
<ul>
<li>Downloaded the source (~ 85Mb): <a title="OpenJDK download" href="http://download.java.net/openjdk/jdk7/" target="_blank">http://download.java.net/openjdk/jdk7/</a>.</li>
<li>Downloaded the binary plugins (the bits of the OpenJDK that are yet to be open sourced).</li>
<li>Downloaded the dependencies.</li>
<li>Modified some environment variables.</li>
<li>Checked the environment is ok via the sanity script.</li>
<li>Made 1 change to the source code.</li>
<li>Made 1 change to the make compiler flags.</li>
<li>Ran the build.</li>
</ul>
<p>The README file did not cover all of the dependencies needed to build the OpenJDK on Ubuntu, here is what worked for me:</p>
<ul>
<li>sudo apt-get install build-essential</li>
<li>sudo apt-get install gawk</li>
<li>sudo apt-get install m4</li>
<li>sudo apt-get install libasound2-dev</li>
<li>sudo apt-get install libcupsys2-dev</li>
<li>sudo apt-get install sun-java6-jdk</li>
<li>sudo apt-get install x11proto-print-dev</li>
<li>sudo apt-get install libxp-dev</li>
<li>sudo apt-get install libfreetype6-dev</li>
<li>sudo apt-get install libxt-dev</li>
<li>sudo apt-get install libxtst-dev</li>
</ul>
<p>The OpenJDK comes with a script (<em>jdk/make/jdk_generic_profile.sh</em>) to help set up your environment. The main updates I needed to make were:</p>
<ul>
<li>The <em>bootjdk </em>variable which holds the folder name of your Java 6 install.</li>
<li>The <em>jdk_instances</em> variable which holds the parent directory of your <em>bootjdk</em>.</li>
<li>The <em>binplugs</em> variable which holds the location of the non open source bits of the OpenJDK.</li>
<li>Ensure <em>ANT_HOME</em> was exported.</li>
<li>Ensusre <em>ANT_HOME/bin</em> was on the <em>PATH</em>.</li>
</ul>
<p>You can see my full environment here: <a title="jdk_generic_profile" href="http://www.cooljeff.co.uk/wp-content/uploads/2009/01/jdk_generic_profile.sh" target="_blank">jdk_generic_profile</a>.</p>
<p>The environment was then verified using the <em>sanity</em> make target:</p>
<pre class="bash" style="font-family:monospace;">&nbsp;
$ . jdk<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">make</span><span style="color: #000000; font-weight: bold;">/</span>jdk_generic_profile.sh
$ <span style="color: #c20cb9; font-weight: bold;">make</span> sanity</pre>
<p>Once this passed I tried building but got a couple of errors.</p>
<p>The first error was:</p>
<pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>openjdk<span style="color: #000000; font-weight: bold;">/</span>hotspot<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>libadt<span style="color: #000000; font-weight: bold;">/</span>port.hpp:
In <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #ff0000;">'void bcopy(const void*, void*, size_t)'</span>:
<span style="color: #000000; font-weight: bold;">/</span>openjdk<span style="color: #000000; font-weight: bold;">/</span>hotspot<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>libadt<span style="color: #000000; font-weight: bold;">/</span>port.hpp:<span style="color: #000000;">40</span>:
error: <span style="color: #ff0000;">'void bcopy(const void*, void*, size_t)'</span> redeclared inline
without <span style="color: #ff0000;">'gnu_inline'</span> attribute
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>bits<span style="color: #000000; font-weight: bold;">/</span>string3.h:<span style="color: #000000;">90</span>:
error: <span style="color: #ff0000;">'void bcopy(const void*, void*, size_t)'</span> previously defined here
<span style="color: #c20cb9; font-weight: bold;">make</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: <span style="color: #000000; font-weight: bold;">***</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>incls<span style="color: #000000; font-weight: bold;">/</span>_precompiled.incl.gch<span style="color: #7a0874; font-weight: bold;">&#93;</span> Error <span style="color: #000000;">1</span></pre>
<p>I understand what the error means but I could not work out why the error occurs because after looking through <em>/usr/include/string.h</em>, the include of <em>/usr/include/bits/string3.h</em> is only done if the user specifies <em>_FORTIFY_SOURCE</em> which as far as I can tell is not done in the OpenJDK. My workaround is quite simple, I commented out the redeclaration of<em> inline void bcopy(const void*, void*, size_t)</em> since it appears to already be inlined somehow.</p>
<p>The second error was:</p>
<pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>openjdk<span style="color: #000000; font-weight: bold;">/</span>hotspot<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>runtime<span style="color: #000000; font-weight: bold;">/</span>arguments.cpp:
In static member <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #ff0000;">'static void Arguments::set_aggressive_opts_flags()'</span>:
<span style="color: #000000; font-weight: bold;">/</span>openjdk<span style="color: #000000; font-weight: bold;">/</span>hotspot<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>runtime<span style="color: #000000; font-weight: bold;">/</span>arguments.cpp:<span style="color: #000000;">1359</span>:
error: format <span style="color: #ff0000;">'%d'</span> expects <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #ff0000;">'int'</span>, but argument <span style="color: #000000;">3</span> has <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #ff0000;">'intx'</span></pre>
<p>This occurs because of a flag that treats WARNINGS as ERRORS. The correct approach would have been to go and fix the warnings, instead I disabled the flag <em>WARNINGS_ARE_ERRORS = -Werror</em> which can be found in <em>hotspot/make/linux/makefiles/gcc.make</em>.</p>
<p>After making these changes I was able to run the build (just typed make) and saw the following output in the end:</p>
<pre class="bash" style="font-family:monospace;">&nbsp;
Control linux amd64 1.7.0-internal build_product_image build finished:
Control linux amd64 1.7.0-internal all_product_build build finished:
Control linux amd64 1.7.0-internal all build finished:</pre>
<p>I had a working JDK which could be found in <em>build/linux-amd64/j2sdk-image/bin</em>.</p>
<pre class="bash" style="font-family:monospace;">&nbsp;
$ .<span style="color: #000000; font-weight: bold;">/</span>java <span style="color: #660033;">-version</span>
openjdk version <span style="color: #ff0000;">&quot;1.7.0-internal&quot;</span>
OpenJDK Runtime Environment <span style="color: #7a0874; font-weight: bold;">&#40;</span>build 1.7.0-internal-jeffsinc_2009_01_03_10_52-b00<span style="color: #7a0874; font-weight: bold;">&#41;</span>
OpenJDK <span style="color: #000000;">64</span>-Bit Server VM <span style="color: #7a0874; font-weight: bold;">&#40;</span>build <span style="color: #000000;">14.0</span>-b09, mixed mode<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cooljeff.co.uk/2009/01/03/building-the-openjdk-on-ubuntu-810/feed/</wfw:commentRss>
		<slash:comments>410</slash:comments>
		</item>
	</channel>
</rss>

