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