blob: ef377ccab426d20c964f7837c86b67e385ff93d6 [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.
Kevinbc8e50f2007-10-05 21:18:52 +000072 <li>change clang/Driver/clang.cpp:606 to include that path
73 </ul>
Ted Kremenek27226222007-10-31 15:31:24 +000074 <li>Build clang</li>
Kevinbc8e50f2007-10-05 21:18:52 +000075 <ul>
Ted Kremenek27226222007-10-31 15:31:24 +000076 <li><tt>cd clang</tt> (assuming that you are in <tt>llvm/tools</tt>)</li>
77 <li><tt>make</tt></li>
Kevinbc8e50f2007-10-05 21:18:52 +000078 </ul>
79</ol>
Ted Kremenek27226222007-10-31 15:31:24 +000080<br>
81
82<p>Note that the C front-end uses LLVM, but does not depend on
83 llvm-gcc. If you encounter problems with building clang, make
84 sure you have the latest SVN version of LLVM. LLVM contains
85 support libraries for clang that will be updated as well as
86 development on clang progresses.</p><br>
Chris Lattnera08ee282007-10-06 05:42:47 +000087
Kevinbc8e50f2007-10-05 21:18:52 +000088<p>We will eventually integrate this better as a sub-project, but for now it builds a single tool named 'clang'.<br>
89Once llvm is built in this way, you can compile C code.
90<h3>Examples of using clang</h3>
91The clang driver takes a lot of GCC compatible options, which you can see with 'clang --help'. Here are a few examples:
92<!-- Thanks to http://shiflett.org/blog/2006/oct/formatting-and-highlighting-php-code-listings
93 Site suggested using pre in CSS, but doesn't work in IE, so went for the <pre> tag.
94-->
95<pre class="code">
96$ cat ~/t.c
97
98typedef float V __attribute__((vector_size(16)));
99V foo(V a, V b) { return a+b*a; }
100
Kevinbc8e50f2007-10-05 21:18:52 +0000101Preprocessing:
102$ clang ~/t.c -E
103# 1 "/Users/sabre/t.c" 1
104
105typedef float V __attribute__((vector_size(16)));
106
107V foo(V a, V b) { return a+b*a; }
108
109
110Type checking:
111$ clang -fsyntax-only ~/t.c
112
113
114GCC options:
115$ clang -fsyntax-only ~/t.c -pedantic
116/Users/sabre/t.c:2:17: warning: extension used
117typedef float V __attribute__((vector_size(16)));
Chris Lattnera08ee282007-10-06 05:42:47 +0000118 ^
Kevinbc8e50f2007-10-05 21:18:52 +00001191 diagnostic generated.
120
121
122
123Pretty printing from the AST:
Chris Lattnerae3758d2007-10-11 00:38:03 +0000124$ clang ~/t.c -ast-print
Kevinbc8e50f2007-10-05 21:18:52 +0000125typedef float V __attribute__(( vector_size(16) ));
126
127V foo(V a, V b) {
128 return a + b * a;
129}
130
131
132LLVM code generation:
133$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llvm-dis
134define <4 x float> @foo(<4 x float> %a, <4 x float> %b) {
135entry:
136 %mul = mul <4 x float> %b, %a ; <<4 x float>>
137[#uses=1]
138 %add = add <4 x float> %mul, %a ; <<4 x float>>
139[#uses=1]
140 ret <4 x float> %add
141}
142$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc -
143march=ppc32 -mcpu=g5
144..
145_foo:
146 vmaddfp v2, v3, v2, v2
147 blr
148$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc -
149march=x86 -mcpu=yonah
150..
151_foo:
152 mulps %xmm0, %xmm1
153 addps %xmm0, %xmm1
154 movaps %xmm1, %xmm0
155 ret
156</pre>
157<h2>Available tasks</h2>
158Here are a few tasks that are currently available for newcomers to work on:
159
Chris Lattnera08ee282007-10-06 05:42:47 +0000160<ul>
161<li>None yet, ask on cfe-dev</li>
162</ul>
Kevinbc8e50f2007-10-05 21:18:52 +0000163</div>
164</body>
Chris Lattnerae3758d2007-10-11 00:38:03 +0000165</html>