blob: 76b862b125c6fce66688c052c3cfb1ff67dd0d73 [file] [log] [blame]
Chris Lattnerde9a4f52007-12-13 05:42:27 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
Kevinaef89fc2007-10-06 01:28:23 +00003<html>
Kevinbc8e50f2007-10-05 21:18:52 +00004<head>
Chris Lattnerde9a4f52007-12-13 05:42:27 +00005 <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
6 <title>Clang - Get Involved</title>
7 <link type="text/css" rel="stylesheet" href="menu.css" />
8 <link type="text/css" rel="stylesheet" href="content.css" />
Kevinbc8e50f2007-10-05 21:18:52 +00009</head>
10<body>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000011
Kevinbc8e50f2007-10-05 21:18:52 +000012<!--#include virtual="menu.html.incl"-->
Chris Lattnerde9a4f52007-12-13 05:42:27 +000013
Kevinbc8e50f2007-10-05 21:18:52 +000014<div id="content">
Chris Lattnerde9a4f52007-12-13 05:42:27 +000015
Kevinbc8e50f2007-10-05 21:18:52 +000016<h1>Getting Involved</h1>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000017
18<p>There are many tasks that are open to new developers who want to get involved
19with the Clang project. Below, you will find details on how to get started with
20Clang, plus a few tasks that we need help with.</p>
21
22<p>Please note that the information provided here is not completely thorough.
23This is intentional. If you plan to work on Clang, we would like you to get
24involved with the other developers. This will allow us to work together better
25and will give you a better feel for how things are done.</p>
26
27<p>You can talk with other developers at the following mailing list: <a
28href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev mailing
29list</a>. The clang mailing list is a very friendly place. You can see the
30archives for records of past discussion. Note that a significant amount of
31design discussion takes place on the <a
32href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits mailing
33list</a>. </p>
Kevinbc8e50f2007-10-05 21:18:52 +000034
35<h2>Getting Started</h2>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000036
Kevinbc8e50f2007-10-05 21:18:52 +000037<h3>A word of warning</h3>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000038
39<p>While this work aims to provide a fully functional C/C++/ObjC front-end, it
40is <em>still very early work</em> and is under heavy development. In particular,
41there is no real C++ support yet (this is obviously a big project), and C/ObjC
42support is still missing some features. Some of the more notable missing pieces
43of C support are:</p>
44
Kevinbc8e50f2007-10-05 21:18:52 +000045<ol>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000046 <li>The semantic analyzer does not produce all of the warnings and errors it
47 should.</li>
48 <li>The LLVM code generator is still very early on. It does not support many
49 important things, like any support for structs and unions. That said, it
50 does handle scalar operations and vectors. clang is not ready to be used
51 as a general purpose C code generator yet.</li>
52 <li>We don't consider the API to be stable yet, and reserve the right to
53 change fundamental things. :)</li>
Kevinbc8e50f2007-10-05 21:18:52 +000054</ol>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000055
56<p>Our plan is to continue chipping away at these issues until C works really
57well, but we'd love help from other interested contributors.</p>
Chris Lattnera08ee282007-10-06 05:42:47 +000058
Kevinbc8e50f2007-10-05 21:18:52 +000059<h3>Follow what's going on</h3>
Chris Lattnera08ee282007-10-06 05:42:47 +000060
Chris Lattnerde9a4f52007-12-13 05:42:27 +000061<p>Clang is a subproject of the <a href="http://llvm.org">LLVM Project</a>, but
62has its own mailing lists because the communities have people with different
Chris Lattnera08ee282007-10-06 05:42:47 +000063interests. If you are interested in clang only, these two lists should be all
64you need. If you are interested in the LLVM optimizer and code generator,
65please consider signing up for <a
66href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">llvmdev</a> and <a
67href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">llvm-commits</a>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000068as well.</p>
69
Kevinbc8e50f2007-10-05 21:18:52 +000070<ul>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000071<li><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits
72</a> - This list is for patch submission/discussion.</li>
73
74<li><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a> -
75This list is for everything else clang related.</li>
Kevinbc8e50f2007-10-05 21:18:52 +000076</ul>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000077
78<h3><a name="build">Building clang / working with the code</a></h3>
79
80<p>If you would like to check out and build the project, the current scheme
81is:</p>
Ted Kremenek27226222007-10-31 15:31:24 +000082
Kevinbc8e50f2007-10-05 21:18:52 +000083<ol>
Chris Lattnerde9a4f52007-12-13 05:42:27 +000084 <li><a href="http://www.llvm.org/docs/GettingStarted.html#checkout">Checkout
85 and build LLVM</a> from SVN head:</li>
86
87 <ul>
88 <li><tt>svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</tt></li>
89 <li><tt>cd llvm</tt></li>
90 <li><tt>./configure; make</tt></li>
91 </ul>
92 <li>Checkout clang:</li>
93 <ul>
94 <li>From within the <tt>llvm</tt> directory (where you
95 built llvm):</li>
96 <li><tt>cd llvm/tools</tt>
97 <li><tt>svn co
98 http://llvm.org/svn/llvm-project/cfe/trunk clang</tt></li>
99
100 </ul>
101 <li>Non-mac users: Paths to system header files are currently hard coded
102 into clang; as a result, if clang can't find your system headers,
103 please follow these instructions:</li>
104
105 <ul>
106 <li>'<tt>touch empty.c; gcc -v empty.c -fsyntax-only</tt>' to get the
107 path.</li>
108 <li>Look for the comment "FIXME: temporary hack:
109 hard-coded paths" in <tt>clang/Driver/clang.cpp</tt> and
110 change the lines below to include that path.</li>
111 </ul>
112
113 <li>Build clang:</li>
114 <ul>
115 <li><tt>cd clang</tt> (assuming that you are in <tt>llvm/tools</tt>)</li>
116 <li><tt>make</tt></li>
117 </ul>
118
119 <li>Try it out (assuming you add llvm/Debug/bin to your path):</li>
120 <ul>
121 <li><tt>clang --help</tt></li>
122 <li><tt>clang file.c -fsyntax-only</tt> (check for correctness)</li>
123 <li><tt>clang file.c -ast-dump</tt> (internal debug dump of ast)</li>
124 <li><tt>clang file.c -ast-view</tt> (<a
125 href="http://llvm.org/docs/ProgrammersManual.html#ViewGraph">set up graphviz
126 and rebuild llvm first</a>)</li>
127 <li><tt>clang file.c -emit-llvm</tt> (print out unoptimized llvm code)</li>
128 <li><tt>clang file.c -emit-llvm | llvm-as | opt -std-compile-opts |
129 llvm-dis</tt> (print out optimized llvm code)</li>
130 <li><tt>clang file.c -emit-llvm | llvm-as | opt -std-compile-opts | llc
131 &gt; file.s</tt> (output native machine code)</li>
132 </ul>
Kevinbc8e50f2007-10-05 21:18:52 +0000133</ol>
Ted Kremenek27226222007-10-31 15:31:24 +0000134
135<p>Note that the C front-end uses LLVM, but does not depend on
136 llvm-gcc. If you encounter problems with building clang, make
137 sure you have the latest SVN version of LLVM. LLVM contains
138 support libraries for clang that will be updated as well as
Chris Lattnerde9a4f52007-12-13 05:42:27 +0000139 development on clang progresses.</p>
140
Kevinbc8e50f2007-10-05 21:18:52 +0000141<h3>Examples of using clang</h3>
Chris Lattnerde9a4f52007-12-13 05:42:27 +0000142
143<p>The clang driver takes a lot of GCC compatible options, which you can see
144with 'clang --help'. Here are a few examples:</p>
145<!-- Thanks to
146 http://shiflett.org/blog/2006/oct/formatting-and-highlighting-php-code-listings
147Site suggested using pre in CSS, but doesn't work in IE, so went for the <pre>
148tag. -->
149
Kevinbc8e50f2007-10-05 21:18:52 +0000150<pre class="code">
151$ cat ~/t.c
152
153typedef float V __attribute__((vector_size(16)));
154V foo(V a, V b) { return a+b*a; }
155
Kevinbc8e50f2007-10-05 21:18:52 +0000156Preprocessing:
157$ clang ~/t.c -E
158# 1 "/Users/sabre/t.c" 1
159
160typedef float V __attribute__((vector_size(16)));
161
162V foo(V a, V b) { return a+b*a; }
163
164
165Type checking:
166$ clang -fsyntax-only ~/t.c
167
168
169GCC options:
170$ clang -fsyntax-only ~/t.c -pedantic
171/Users/sabre/t.c:2:17: warning: extension used
172typedef float V __attribute__((vector_size(16)));
Chris Lattnera08ee282007-10-06 05:42:47 +0000173 ^
Kevinbc8e50f2007-10-05 21:18:52 +00001741 diagnostic generated.
175
176
177
178Pretty printing from the AST:
Chris Lattnerae3758d2007-10-11 00:38:03 +0000179$ clang ~/t.c -ast-print
Kevinbc8e50f2007-10-05 21:18:52 +0000180typedef float V __attribute__(( vector_size(16) ));
181
182V foo(V a, V b) {
183 return a + b * a;
184}
185
186
187LLVM code generation:
188$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llvm-dis
Chris Lattnerde9a4f52007-12-13 05:42:27 +0000189define &lt;4 x float&gt; @foo(&lt;4 x float&gt; %a, &lt;4 x float&gt; %b) {
Kevinbc8e50f2007-10-05 21:18:52 +0000190entry:
Chris Lattnerde9a4f52007-12-13 05:42:27 +0000191 %mul = mul &lt;4 x float&gt; %b, %a
192 %add = add &lt;4 x float&gt; %mul, %a
193 ret &lt;4 x float&gt; %add
Kevinbc8e50f2007-10-05 21:18:52 +0000194}
195$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc -
196march=ppc32 -mcpu=g5
197..
198_foo:
199 vmaddfp v2, v3, v2, v2
200 blr
201$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc -
202march=x86 -mcpu=yonah
203..
204_foo:
205 mulps %xmm0, %xmm1
206 addps %xmm0, %xmm1
207 movaps %xmm1, %xmm0
208 ret
209</pre>
210<h2>Available tasks</h2>
211Here are a few tasks that are currently available for newcomers to work on:
212
Chris Lattnera08ee282007-10-06 05:42:47 +0000213<ul>
214<li>None yet, ask on cfe-dev</li>
215</ul>
Kevinbc8e50f2007-10-05 21:18:52 +0000216</div>
217</body>
Chris Lattnerae3758d2007-10-11 00:38:03 +0000218</html>