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