blob: 68ffe9e720497ecb993136aa94db4bb185999756 [file] [log] [blame]
Kevinbc8e50f2007-10-05 21:18:52 +00001<!-- Consulted: http://www.w3.org/TR/CSS1 & http://www.w3.org/TR/CSS21/ & http://www.w3.org/TR/html401/ -->
Kevinaef89fc2007-10-06 01:28:23 +00002<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
3<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4<html>
Kevinbc8e50f2007-10-05 21:18:52 +00005<head>
Kevinaef89fc2007-10-06 01:28:23 +00006 <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
Kevinbc8e50f2007-10-05 21:18:52 +00007 <title>Clang - Get Involved</title>
8 <link type="text/css" rel="stylesheet" href="menu.css" />
9 <link type="text/css" rel="stylesheet" href="content.css" />
10</head>
11<body>
12<!--#include virtual="menu.html.incl"-->
13<div id="content">
14<h1>Getting Involved</h1>
15There are many tasks that are open to new developers who want to get involved with the Clang project. Below, you will find details on how to get started with Clang, plus a few tasks that we need help with.<br>
16<br>
17Please note that the information provided here is not completely thorough. This is intentional. If you plan to work on Clang, we would like you to get involved with the other developers. This will allow us to work together better and will give you a better feel for how things are done.
Chris Lattnera08ee282007-10-06 05:42:47 +000018You can talk with other developers at the following mailing list: <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev mailing list</a>.
19The clang mailing list is a very friendly place. You can see the archives for records of past discussion. Note that a significant amount of design discussion takes place on the <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits mailing list</a>.
Kevinbc8e50f2007-10-05 21:18:52 +000020
21<h2>Getting Started</h2>
22<h3>A word of warning</h3>
Chris Lattnera08ee282007-10-06 05:42:47 +000023While this work aims to provide a fully functional C/C++/ObjC front-end, it is <em>still very early work</em> and is under heavy development. In particular, there is no real C++ support yet (this is obviously a big project), and C/ObjC support is still missing some features. Some of the more notable missing pieces of C support are:
Kevinbc8e50f2007-10-05 21:18:52 +000024<ol>
25 <li>The semantic analyzer does not produce all of the warnings and errors it should.
Chris Lattnera08ee282007-10-06 05:42:47 +000026 <li>The LLVM code generator is still very early on. It does not support many important things, like any support for structs and unions. That said, it does handle scalar operations and vectors. clang is not ready to be used as a general purpose C code generator yet.
Kevinbc8e50f2007-10-05 21:18:52 +000027 <li>We don't consider the API to be stable yet, and reserve the right to change fundamental things :)
28</ol>
29Our plan is to continue chipping away at these issues until C works really well, but we'd love help from other interested contributors.
Chris Lattnera08ee282007-10-06 05:42:47 +000030
Kevinbc8e50f2007-10-05 21:18:52 +000031<h3>Follow what's going on</h3>
Chris Lattnera08ee282007-10-06 05:42:47 +000032
33Clang is a subproject of the <a href="http://llvm.org">LLVM Project</a>, but has
34its own mailing lists because the communities have people with different
35interests. If you are interested in clang only, these two lists should be all
36you need. If you are interested in the LLVM optimizer and code generator,
37please consider signing up for <a
38href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">llvmdev</a> and <a
39href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">llvm-commits</a>
40as well.<br>
Kevinbc8e50f2007-10-05 21:18:52 +000041<ul>
42<li><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a> - This list is for patch submission/discussion.
43<li><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a> - This list is for everything else clang related.
44</ul>
Kevin13043a42007-10-05 21:44:03 +000045<h3>Building clang / working with the code<a name="build">&nbsp;</a></h3>
Ted Kremenek27226222007-10-31 15:31:24 +000046If you would like to check out and build the project, the current scheme is:<br><br>
47
Kevinbc8e50f2007-10-05 21:18:52 +000048<ol>
Ted Kremenek27226222007-10-31 15:31:24 +000049 <li>Checkout and build LLVM
50 (<a href="http://www.llvm.org/docs/GettingStarted.html#checkout">latest
51 instructions for SVN access</a>)</li>
Kevinbc8e50f2007-10-05 21:18:52 +000052 <ul>
Ted Kremenek27226222007-10-31 15:31:24 +000053 <li><tt>svn co http://llvm.org/svn/llvm-project/llvm/trunk
54 llvm</tt></li>
55 <li><tt>cd llvm</tt></li>
56 <li><tt>./configure; make</tt></li>
57 </ul>
58 <li>Checkout clang</li>
59 <ul>
60 <li>From within the <tt>llvm</tt> directory (where you
61 built llvm):</li>
62 <li><tt>cd llvm/tools</tt>
63 <li><tt>svn co
64 http://llvm.org/svn/llvm-project/cfe/trunk clang</tt></li>
65
Kevinbc8e50f2007-10-05 21:18:52 +000066 </ul>
Chris Lattnera08ee282007-10-06 05:42:47 +000067 <li>Non-mac users: Paths to system header files are currently hard coded
Ted Kremenek27226222007-10-31 15:31:24 +000068 into clang; as a result, if clang can't find your system headers,
Chris Lattnera08ee282007-10-06 05:42:47 +000069 please follow these instructions:
Kevinbc8e50f2007-10-05 21:18:52 +000070 <ul>
Ted Kremenek27226222007-10-31 15:31:24 +000071 <li>'<tt>touch empty.c; gcc -v empty.c -fsyntax-only</tt>' to get the path.
Ted Kremenek2d8a8302007-10-31 17:57:30 +000072 <li>Look for the comment "FIXME: temporary hack:
Ted Kremenek3cf47462007-10-31 17:58:51 +000073 hard-coded paths" in <tt>clang/Driver/clang.cpp</tt> and
Ted Kremenek2d8a8302007-10-31 17:57:30 +000074 change the lines below to include that path.
Kevinbc8e50f2007-10-05 21:18:52 +000075 </ul>
Ted Kremenek27226222007-10-31 15:31:24 +000076 <li>Build clang</li>
Kevinbc8e50f2007-10-05 21:18:52 +000077 <ul>
Ted Kremenek27226222007-10-31 15:31:24 +000078 <li><tt>cd clang</tt> (assuming that you are in <tt>llvm/tools</tt>)</li>
79 <li><tt>make</tt></li>
Kevinbc8e50f2007-10-05 21:18:52 +000080 </ul>
81</ol>
Ted Kremenek27226222007-10-31 15:31:24 +000082<br>
83
84<p>Note that the C front-end uses LLVM, but does not depend on
85 llvm-gcc. If you encounter problems with building clang, make
86 sure you have the latest SVN version of LLVM. LLVM contains
87 support libraries for clang that will be updated as well as
88 development on clang progresses.</p><br>
Chris Lattnera08ee282007-10-06 05:42:47 +000089
Kevinbc8e50f2007-10-05 21:18:52 +000090<p>We will eventually integrate this better as a sub-project, but for now it builds a single tool named 'clang'.<br>
91Once llvm is built in this way, you can compile C code.
92<h3>Examples of using clang</h3>
93The clang driver takes a lot of GCC compatible options, which you can see with 'clang --help'. Here are a few examples:
94<!-- Thanks to http://shiflett.org/blog/2006/oct/formatting-and-highlighting-php-code-listings
95 Site suggested using pre in CSS, but doesn't work in IE, so went for the <pre> tag.
96-->
97<pre class="code">
98$ cat ~/t.c
99
100typedef float V __attribute__((vector_size(16)));
101V foo(V a, V b) { return a+b*a; }
102
Kevinbc8e50f2007-10-05 21:18:52 +0000103Preprocessing:
104$ clang ~/t.c -E
105# 1 "/Users/sabre/t.c" 1
106
107typedef float V __attribute__((vector_size(16)));
108
109V foo(V a, V b) { return a+b*a; }
110
111
112Type checking:
113$ clang -fsyntax-only ~/t.c
114
115
116GCC options:
117$ clang -fsyntax-only ~/t.c -pedantic
118/Users/sabre/t.c:2:17: warning: extension used
119typedef float V __attribute__((vector_size(16)));
Chris Lattnera08ee282007-10-06 05:42:47 +0000120 ^
Kevinbc8e50f2007-10-05 21:18:52 +00001211 diagnostic generated.
122
123
124
125Pretty printing from the AST:
Chris Lattnerae3758d2007-10-11 00:38:03 +0000126$ clang ~/t.c -ast-print
Kevinbc8e50f2007-10-05 21:18:52 +0000127typedef float V __attribute__(( vector_size(16) ));
128
129V foo(V a, V b) {
130 return a + b * a;
131}
132
133
134LLVM code generation:
135$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llvm-dis
136define <4 x float> @foo(<4 x float> %a, <4 x float> %b) {
137entry:
138 %mul = mul <4 x float> %b, %a ; <<4 x float>>
139[#uses=1]
140 %add = add <4 x float> %mul, %a ; <<4 x float>>
141[#uses=1]
142 ret <4 x float> %add
143}
144$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc -
145march=ppc32 -mcpu=g5
146..
147_foo:
148 vmaddfp v2, v3, v2, v2
149 blr
150$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc -
151march=x86 -mcpu=yonah
152..
153_foo:
154 mulps %xmm0, %xmm1
155 addps %xmm0, %xmm1
156 movaps %xmm1, %xmm0
157 ret
158</pre>
159<h2>Available tasks</h2>
160Here are a few tasks that are currently available for newcomers to work on:
161
Chris Lattnera08ee282007-10-06 05:42:47 +0000162<ul>
163<li>None yet, ask on cfe-dev</li>
164</ul>
Kevinbc8e50f2007-10-05 21:18:52 +0000165</div>
166</body>
Chris Lattnerae3758d2007-10-11 00:38:03 +0000167</html>