blob: 391b43a3a2bbad6fad26885594bcb797a2a64b54 [file] [log] [blame]
Bill Wendlingbbc3be52012-06-20 11:20:07 +00001.. _developer_policy:
2
3=====================
4LLVM Developer Policy
5=====================
6
7.. contents::
8 :local:
9
10Introduction
11============
12
13This document contains the LLVM Developer Policy which defines the project's
14policy towards developers and their contributions. The intent of this policy is
15to eliminate miscommunication, rework, and confusion that might arise from the
16distributed nature of LLVM's development. By stating the policy in clear terms,
17we hope each developer can know ahead of time what to expect when making LLVM
18contributions. This policy covers all llvm.org subprojects, including Clang,
19LLDB, libc++, etc.
20
21This policy is also designed to accomplish the following objectives:
22
23#. Attract both users and developers to the LLVM project.
24
25#. Make life as simple and easy for contributors as possible.
26
27#. Keep the top of Subversion trees as stable as possible.
28
29#. Establish awareness of the project's `copyright, license, and patent
30 policies`_ with contributors to the project.
31
32This policy is aimed at frequent contributors to LLVM. People interested in
33contributing one-off patches can do so in an informal way by sending them to the
34`llvm-commits mailing list
35<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>`_ and engaging another
36developer to see it through the process.
37
38Developer Policies
39==================
40
41This section contains policies that pertain to frequent LLVM developers. We
42always welcome `one-off patches`_ from people who do not routinely contribute to
43LLVM, but we expect more from frequent contributors to keep the system as
44efficient as possible for everyone. Frequent LLVM contributors are expected to
45meet the following requirements in order for LLVM to maintain a high standard of
46quality.
47
48Stay Informed
49-------------
50
51Developers should stay informed by reading at least the "dev" mailing list for
52the projects you are interested in, such as `llvmdev
53<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>`_ for LLVM, `cfe-dev
54<http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>`_ for Clang, or `lldb-dev
55<http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev>`_ for LLDB. If you are
56doing anything more than just casual work on LLVM, it is suggested that you also
57subscribe to the "commits" mailing list for the subproject you're interested in,
58such as `llvm-commits
59<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>`_, `cfe-commits
60<http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits>`_, or `lldb-commits
61<http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits>`_. Reading the
62"commits" list and paying attention to changes being made by others is a good
63way to see what other people are interested in and watching the flow of the
64project as a whole.
65
66We recommend that active developers register an email account with `LLVM
67Bugzilla <http://llvm.org/bugs/>`_ and preferably subscribe to the `llvm-bugs
68<http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs>`_ email list to keep track
69of bugs and enhancements occurring in LLVM. We really appreciate people who are
70proactive at catching incoming bugs in their components and dealing with them
71promptly.
72
73.. _patch:
74.. _one-off patches:
75
76Making a Patch
77--------------
78
79When making a patch for review, the goal is to make it as easy for the reviewer
80to read it as possible. As such, we recommend that you:
81
82#. Make your patch against the Subversion trunk, not a branch, and not an old
83 version of LLVM. This makes it easy to apply the patch. For information on
84 how to check out SVN trunk, please see the `Getting Started
85 Guide <GettingStarted.html#checkout>`_.
86
87#. Similarly, patches should be submitted soon after they are generated. Old
88 patches may not apply correctly if the underlying code changes between the
89 time the patch was created and the time it is applied.
90
91#. Patches should be made with ``svn diff``, or similar. If you use a
92 different tool, make sure it uses the ``diff -u`` format and that it
93 doesn't contain clutter which makes it hard to read.
94
95#. If you are modifying generated files, such as the top-level ``configure``
96 script, please separate out those changes into a separate patch from the rest
97 of your changes.
98
99When sending a patch to a mailing list, it is a good idea to send it as an
100*attachment* to the message, not embedded into the text of the message. This
101ensures that your mailer will not mangle the patch when it sends it (e.g. by
102making whitespace changes or by wrapping lines).
103
104*For Thunderbird users:* Before submitting a patch, please open *Preferences >
105Advanced > General > Config Editor*, find the key
106``mail.content_disposition_type``, and set its value to ``1``. Without this
107setting, Thunderbird sends your attachment using ``Content-Disposition: inline``
108rather than ``Content-Disposition: attachment``. Apple Mail gamely displays such
109a file inline, making it difficult to work with for reviewers using that
110program.
111
112.. _code review:
113
114Code Reviews
115------------
116
117LLVM has a code review policy. Code review is one way to increase the quality of
118software. We generally follow these policies:
119
120#. All developers are required to have significant changes reviewed before they
121 are committed to the repository.
122
123#. Code reviews are conducted by email, usually on the llvm-commits list.
124
125#. Code can be reviewed either before it is committed or after. We expect major
126 changes to be reviewed before being committed, but smaller changes (or
127 changes where the developer owns the component) can be reviewed after commit.
128
129#. The developer responsible for a code change is also responsible for making
130 all necessary review-related changes.
131
132#. Code review can be an iterative process, which continues until the patch is
133 ready to be committed.
134
135Developers should participate in code reviews as both reviewers and
136reviewees. If someone is kind enough to review your code, you should return the
137favor for someone else. Note that anyone is welcome to review and give feedback
138on a patch, but only people with Subversion write access can approve it.
139
Manuel Klimek81eb88f2012-10-11 19:40:46 +0000140There is a web based code review tool that can optionally be used
141for code reviews. See the documentation on `Code Reviews with
142Phabricator <Phabricator.html>`_.
143
Bill Wendlingbbc3be52012-06-20 11:20:07 +0000144Code Owners
145-----------
146
147The LLVM Project relies on two features of its process to maintain rapid
148development in addition to the high quality of its source base: the combination
149of code review plus post-commit review for trusted maintainers. Having both is
150a great way for the project to take advantage of the fact that most people do
151the right thing most of the time, and only commit patches without pre-commit
152review when they are confident they are right.
153
154The trick to this is that the project has to guarantee that all patches that are
155committed are reviewed after they go in: you don't want everyone to assume
156someone else will review it, allowing the patch to go unreviewed. To solve this
157problem, we have a notion of an 'owner' for a piece of the code. The sole
158responsibility of a code owner is to ensure that a commit to their area of the
Duncan Sands35b87602012-07-26 08:04:09 +0000159code is appropriately reviewed, either by themself or by someone else. The list
160of current code owners can be found in the file
Duncan Sands52a111f2012-07-26 08:08:31 +0000161`CODE_OWNERS.TXT <http://llvm.org/viewvc/llvm-project/llvm/trunk/CODE_OWNERS.TXT?view=markup>`_
Duncan Sands35b87602012-07-26 08:04:09 +0000162in the root of the LLVM source tree.
Bill Wendlingbbc3be52012-06-20 11:20:07 +0000163
164Note that code ownership is completely different than reviewers: anyone can
165review a piece of code, and we welcome code review from anyone who is
166interested. Code owners are the "last line of defense" to guarantee that all
167patches that are committed are actually reviewed.
168
169Being a code owner is a somewhat unglamorous position, but it is incredibly
170important for the ongoing success of the project. Because people get busy,
171interests change, and unexpected things happen, code ownership is purely opt-in,
172and anyone can choose to resign their "title" at any time. For now, we do not
173have an official policy on how one gets elected to be a code owner.
174
175.. _include a testcase:
176
177Test Cases
178----------
179
180Developers are required to create test cases for any bugs fixed and any new
181features added. Some tips for getting your testcase approved:
182
183* All feature and regression test cases are added to the ``llvm/test``
184 directory. The appropriate sub-directory should be selected (see the `Testing
185 Guide <TestingGuide.html>`_ for details).
186
187* Test cases should be written in `LLVM assembly language <LangRef.html>`_
188 unless the feature or regression being tested requires another language
189 (e.g. the bug being fixed or feature being implemented is in the llvm-gcc C++
190 front-end, in which case it must be written in C++).
191
192* Test cases, especially for regressions, should be reduced as much as possible,
193 by `bugpoint <Bugpoint.html>`_ or manually. It is unacceptable to place an
194 entire failing program into ``llvm/test`` as this creates a *time-to-test*
195 burden on all developers. Please keep them short.
196
197Note that llvm/test and clang/test are designed for regression and small feature
198tests only. More extensive test cases (e.g., entire applications, benchmarks,
199etc) should be added to the ``llvm-test`` test suite. The llvm-test suite is
200for coverage (correctness, performance, etc) testing, not feature or regression
201testing.
202
203Quality
204-------
205
206The minimum quality standards that any change must satisfy before being
207committed to the main development branch are:
208
209#. Code must adhere to the `LLVM Coding Standards <CodingStandards.html>`_.
210
211#. Code must compile cleanly (no errors, no warnings) on at least one platform.
212
213#. Bug fixes and new features should `include a testcase`_ so we know if the
214 fix/feature ever regresses in the future.
215
216#. Code must pass the ``llvm/test`` test suite.
217
218#. The code must not cause regressions on a reasonable subset of llvm-test,
219 where "reasonable" depends on the contributor's judgement and the scope of
220 the change (more invasive changes require more testing). A reasonable subset
221 might be something like "``llvm-test/MultiSource/Benchmarks``".
222
223Additionally, the committer is responsible for addressing any problems found in
224the future that the change is responsible for. For example:
225
226* The code should compile cleanly on all supported platforms.
227
228* The changes should not cause any correctness regressions in the ``llvm-test``
229 suite and must not cause any major performance regressions.
230
231* The change set should not cause performance or correctness regressions for the
232 LLVM tools.
233
234* The changes should not cause performance or correctness regressions in code
235 compiled by LLVM on all applicable targets.
236
237* You are expected to address any `Bugzilla bugs <http://llvm.org/bugs/>`_ that
238 result from your change.
239
240We prefer for this to be handled before submission but understand that it isn't
241possible to test all of this for every submission. Our build bots and nightly
242testing infrastructure normally finds these problems. A good rule of thumb is
243to check the nightly testers for regressions the day after your change. Build
244bots will directly email you if a group of commits that included yours caused a
245failure. You are expected to check the build bot messages to see if they are
246your fault and, if so, fix the breakage.
247
248Commits that violate these quality standards (e.g. are very broken) may be
249reverted. This is necessary when the change blocks other developers from making
250progress. The developer is welcome to re-commit the change after the problem has
251been fixed.
252
253Obtaining Commit Access
254-----------------------
255
256We grant commit access to contributors with a track record of submitting high
257quality patches. If you would like commit access, please send an email to
258`Chris <mailto:sabre@nondot.org>`_ with the following information:
259
260#. The user name you want to commit with, e.g. "hacker".
261
262#. The full name and email address you want message to llvm-commits to come
263 from, e.g. "J. Random Hacker <hacker@yoyodyne.com>".
264
265#. A "password hash" of the password you want to use, e.g. "``2ACR96qjUqsyM``".
266 Note that you don't ever tell us what your password is, you just give it to
267 us in an encrypted form. To get this, run "``htpasswd``" (a utility that
268 comes with apache) in crypt mode (often enabled with "``-d``"), or find a web
269 page that will do it for you.
270
271Once you've been granted commit access, you should be able to check out an LLVM
272tree with an SVN URL of "https://username@llvm.org/..." instead of the normal
273anonymous URL of "http://llvm.org/...". The first time you commit you'll have
274to type in your password. Note that you may get a warning from SVN about an
275untrusted key, you can ignore this. To verify that your commit access works,
276please do a test commit (e.g. change a comment or add a blank line). Your first
277commit to a repository may require the autogenerated email to be approved by a
278mailing list. This is normal, and will be done when the mailing list owner has
279time.
280
281If you have recently been granted commit access, these policies apply:
282
283#. You are granted *commit-after-approval* to all parts of LLVM. To get
284 approval, submit a `patch`_ to `llvm-commits
285 <http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>`_. When approved
Sean Silvaa177a512012-09-18 22:21:43 +0000286 you may commit it yourself.
Bill Wendlingbbc3be52012-06-20 11:20:07 +0000287
288#. You are allowed to commit patches without approval which you think are
289 obvious. This is clearly a subjective decision --- we simply expect you to
290 use good judgement. Examples include: fixing build breakage, reverting
291 obviously broken patches, documentation/comment changes, any other minor
292 changes.
293
294#. You are allowed to commit patches without approval to those portions of LLVM
295 that you have contributed or maintain (i.e., have been assigned
296 responsibility for), with the proviso that such commits must not break the
297 build. This is a "trust but verify" policy and commits of this nature are
298 reviewed after they are committed.
299
300#. Multiple violations of these policies or a single egregious violation may
301 cause commit access to be revoked.
302
303In any case, your changes are still subject to `code review`_ (either before or
304after they are committed, depending on the nature of the change). You are
305encouraged to review other peoples' patches as well, but you aren't required
306to.
307
308.. _discuss the change/gather consensus:
309
310Making a Major Change
311---------------------
312
313When a developer begins a major new project with the aim of contributing it back
314to LLVM, s/he should inform the community with an email to the `llvmdev
315<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>`_ email list, to the extent
316possible. The reason for this is to:
317
318#. keep the community informed about future changes to LLVM,
319
320#. avoid duplication of effort by preventing multiple parties working on the
321 same thing and not knowing about it, and
322
323#. ensure that any technical issues around the proposed work are discussed and
324 resolved before any significant work is done.
325
326The design of LLVM is carefully controlled to ensure that all the pieces fit
327together well and are as consistent as possible. If you plan to make a major
328change to the way LLVM works or want to add a major new extension, it is a good
329idea to get consensus with the development community before you start working on
330it.
331
332Once the design of the new feature is finalized, the work itself should be done
333as a series of `incremental changes`_, not as a long-term development branch.
334
335.. _incremental changes:
336
337Incremental Development
338-----------------------
339
340In the LLVM project, we do all significant changes as a series of incremental
341patches. We have a strong dislike for huge changes or long-term development
342branches. Long-term development branches have a number of drawbacks:
343
344#. Branches must have mainline merged into them periodically. If the branch
345 development and mainline development occur in the same pieces of code,
346 resolving merge conflicts can take a lot of time.
347
348#. Other people in the community tend to ignore work on branches.
349
350#. Huge changes (produced when a branch is merged back onto mainline) are
351 extremely difficult to `code review`_.
352
353#. Branches are not routinely tested by our nightly tester infrastructure.
354
355#. Changes developed as monolithic large changes often don't work until the
356 entire set of changes is done. Breaking it down into a set of smaller
357 changes increases the odds that any of the work will be committed to the main
358 repository.
359
360To address these problems, LLVM uses an incremental development style and we
361require contributors to follow this practice when making a large/invasive
362change. Some tips:
363
364* Large/invasive changes usually have a number of secondary changes that are
365 required before the big change can be made (e.g. API cleanup, etc). These
366 sorts of changes can often be done before the major change is done,
367 independently of that work.
368
369* The remaining inter-related work should be decomposed into unrelated sets of
370 changes if possible. Once this is done, define the first increment and get
371 consensus on what the end goal of the change is.
372
373* Each change in the set can be stand alone (e.g. to fix a bug), or part of a
374 planned series of changes that works towards the development goal.
375
376* Each change should be kept as small as possible. This simplifies your work
377 (into a logical progression), simplifies code review and reduces the chance
378 that you will get negative feedback on the change. Small increments also
379 facilitate the maintenance of a high quality code base.
380
381* Often, an independent precursor to a big change is to add a new API and slowly
382 migrate clients to use the new API. Each change to use the new API is often
383 "obvious" and can be committed without review. Once the new API is in place
384 and used, it is much easier to replace the underlying implementation of the
385 API. This implementation change is logically separate from the API
386 change.
387
388If you are interested in making a large change, and this scares you, please make
389sure to first `discuss the change/gather consensus`_ then ask about the best way
390to go about making the change.
391
392Attribution of Changes
393----------------------
394
395We believe in correct attribution of contributions to their contributors.
396However, we do not want the source code to be littered with random attributions
397"this code written by J. Random Hacker" (this is noisy and distracting). In
398practice, the revision control system keeps a perfect history of who changed
399what, and the CREDITS.txt file describes higher-level contributions. If you
400commit a patch for someone else, please say "patch contributed by J. Random
401Hacker!" in the commit message.
402
403Overall, please do not add contributor names to the source code.
404
405.. _copyright, license, and patent policies:
406
407Copyright, License, and Patents
408===============================
409
410.. note::
411
412 This section deals with legal matters but does not provide legal advice. We
413 are not lawyers --- please seek legal counsel from an attorney.
414
415This section addresses the issues of copyright, license and patents for the LLVM
416project. The copyright for the code is held by the individual contributors of
417the code and the terms of its license to LLVM users and developers is the
418`University of Illinois/NCSA Open Source License
419<http://www.opensource.org/licenses/UoI-NCSA.php>`_ (with portions dual licensed
420under the `MIT License <http://www.opensource.org/licenses/mit-license.php>`_,
421see below). As contributor to the LLVM project, you agree to allow any
422contributions to the project to licensed under these terms.
423
424Copyright
425---------
426
427The LLVM project does not require copyright assignments, which means that the
428copyright for the code in the project is held by its respective contributors who
429have each agreed to release their contributed code under the terms of the `LLVM
430License`_.
431
432An implication of this is that the LLVM license is unlikely to ever change:
433changing it would require tracking down all the contributors to LLVM and getting
434them to agree that a license change is acceptable for their contribution. Since
435there are no plans to change the license, this is not a cause for concern.
436
437As a contributor to the project, this means that you (or your company) retain
438ownership of the code you contribute, that it cannot be used in a way that
439contradicts the license (which is a liberal BSD-style license), and that the
440license for your contributions won't change without your approval in the
441future.
442
443.. _LLVM License:
444
445License
446-------
447
448We intend to keep LLVM perpetually open source and to use a liberal open source
449license. **As a contributor to the project, you agree that any contributions be
450licensed under the terms of the corresponding subproject.** All of the code in
451LLVM is available under the `University of Illinois/NCSA Open Source License
452<http://www.opensource.org/licenses/UoI-NCSA.php>`_, which boils down to
453this:
454
455* You can freely distribute LLVM.
456* You must retain the copyright notice if you redistribute LLVM.
457* Binaries derived from LLVM must reproduce the copyright notice (e.g. in an
458 included readme file).
459* You can't use our names to promote your LLVM derived products.
460* There's no warranty on LLVM at all.
461
462We believe this fosters the widest adoption of LLVM because it **allows
463commercial products to be derived from LLVM** with few restrictions and without
464a requirement for making any derived works also open source (i.e. LLVM's
465license is not a "copyleft" license like the GPL). We suggest that you read the
466`License <http://www.opensource.org/licenses/UoI-NCSA.php>`_ if further
467clarification is needed.
468
469In addition to the UIUC license, the runtime library components of LLVM
470(**compiler_rt, libc++, and libclc**) are also licensed under the `MIT License
471<http://www.opensource.org/licenses/mit-license.php>`_, which does not contain
472the binary redistribution clause. As a user of these runtime libraries, it
473means that you can choose to use the code under either license (and thus don't
474need the binary redistribution clause), and as a contributor to the code that
475you agree that any contributions to these libraries be licensed under both
476licenses. We feel that this is important for runtime libraries, because they
477are implicitly linked into applications and therefore should not subject those
478applications to the binary redistribution clause. This also means that it is ok
479to move code from (e.g.) libc++ to the LLVM core without concern, but that code
480cannot be moved from the LLVM core to libc++ without the copyright owner's
481permission.
482
483Note that the LLVM Project does distribute llvm-gcc and dragonegg, **which are
484GPL.** This means that anything "linked" into llvm-gcc must itself be compatible
485with the GPL, and must be releasable under the terms of the GPL. This implies
486that **any code linked into llvm-gcc and distributed to others may be subject to
487the viral aspects of the GPL** (for example, a proprietary code generator linked
488into llvm-gcc must be made available under the GPL). This is not a problem for
489code already distributed under a more liberal license (like the UIUC license),
490and GPL-containing subprojects are kept in separate SVN repositories whose
491LICENSE.txt files specifically indicate that they contain GPL code.
492
493We have no plans to change the license of LLVM. If you have questions or
494comments about the license, please contact the `LLVM Developer's Mailing
495List <mailto:llvmdev@cs.uiuc.edu>`_.
496
497Patents
498-------
499
500To the best of our knowledge, LLVM does not infringe on any patents (we have
501actually removed code from LLVM in the past that was found to infringe). Having
502code in LLVM that infringes on patents would violate an important goal of the
503project by making it hard or impossible to reuse the code for arbitrary purposes
504(including commercial use).
505
506When contributing code, we expect contributors to notify us of any potential for
507patent-related trouble with their changes (including from third parties). If
508you or your employer own the rights to a patent and would like to contribute
509code to LLVM that relies on it, we require that the copyright owner sign an
510agreement that allows any other user of LLVM to freely use your patent. Please
511contact the `oversight group <mailto:llvm-oversight@cs.uiuc.edu>`_ for more
512details.