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 tree 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.llvm.org/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 `llvm-dev 51<http://lists.llvm.org/mailman/listinfo/llvm-dev>`_ for LLVM, `cfe-dev 52<http://lists.llvm.org/mailman/listinfo/cfe-dev>`_ for Clang, or `lldb-dev 53<http://lists.llvm.org/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.llvm.org/mailman/listinfo/llvm-commits>`_, `cfe-commits 58<http://lists.llvm.org/mailman/listinfo/cfe-commits>`_, or `lldb-commits 59<http://lists.llvm.org/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 <https://bugs.llvm.org/>`_ and preferably subscribe to the `llvm-bugs 66<http://lists.llvm.org/mailman/listinfo/llvm-bugs>`_ 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 git main, not a branch, and not an old version 84 of LLVM. This makes it easy to apply the patch. For information on how to 85 clone from git, please see the :ref:`Getting Started Guide 86 <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 ``git format-patch``, or similar (see special 93 commands for `Requesting Phabricator review via the web interface 94 <Phabricator.html#phabricator-request-review-web>`_ ). If you use a 95 different tool, make sure it uses the ``diff -u`` format and that it 96 doesn't contain clutter which makes it hard to read. 97 98Once your patch is ready, submit it by emailing it to the appropriate project's 99commit mailing list (or commit it directly if applicable). Alternatively, some 100patches get sent to the project's development list or component of the LLVM bug 101tracker, but the commit list is the primary place for reviews and should 102generally be preferred. 103 104When sending a patch to a mailing list, it is a good idea to send it as an 105*attachment* to the message, not embedded into the text of the message. This 106ensures that your mailer will not mangle the patch when it sends it (e.g. by 107making whitespace changes or by wrapping lines). 108 109*For Thunderbird users:* Before submitting a patch, please open *Preferences > 110Advanced > General > Config Editor*, find the key 111``mail.content_disposition_type``, and set its value to ``1``. Without this 112setting, Thunderbird sends your attachment using ``Content-Disposition: inline`` 113rather than ``Content-Disposition: attachment``. Apple Mail gamely displays such 114a file inline, making it difficult to work with for reviewers using that 115program. 116 117When submitting patches, please do not add confidentiality or non-disclosure 118notices to the patches themselves. These notices conflict with the LLVM 119licensing terms and may result in your contribution being excluded. 120 121.. _code review: 122 123Code Reviews 124------------ 125 126LLVM has a code-review policy. Code review is one way to increase the quality of 127software. Please see :doc:`CodeReview` for more information on LLVM's code-review 128process. 129 130.. _code owners: 131 132Code Owners 133----------- 134 135The LLVM Project relies on two features of its process to maintain rapid 136development in addition to the high quality of its source base: the combination 137of code review plus post-commit review for trusted maintainers. Having both is 138a great way for the project to take advantage of the fact that most people do 139the right thing most of the time, and only commit patches without pre-commit 140review when they are confident they are right. 141 142The trick to this is that the project has to guarantee that all patches that are 143committed are reviewed after they go in: you don't want everyone to assume 144someone else will review it, allowing the patch to go unreviewed. To solve this 145problem, we have a notion of an 'owner' for a piece of the code. The sole 146responsibility of a code owner is to ensure that a commit to their area of the 147code is appropriately reviewed, either by themself or by someone else. The list 148of current code owners can be found in the file `CODE_OWNERS.TXT 149<https://github.com/llvm/llvm-project/blob/main/llvm/CODE_OWNERS.TXT>`_ in the 150root of the LLVM source tree. 151 152Note that code ownership is completely different than reviewers: anyone can 153review a piece of code, and we welcome code review from anyone who is 154interested. Code owners are the "last line of defense" to guarantee that all 155patches that are committed are actually reviewed. 156 157Being a code owner is a somewhat unglamorous position, but it is incredibly 158important for the ongoing success of the project. Because people get busy, 159interests change, and unexpected things happen, code ownership is purely opt-in, 160and anyone can choose to resign their "title" at any time. For now, we do not 161have an official policy on how one gets elected to be a code owner. 162 163.. _include a testcase: 164 165Test Cases 166---------- 167 168Developers are required to create test cases for any bugs fixed and any new 169features added. Some tips for getting your testcase approved: 170 171* All feature and regression test cases are added to the ``llvm/test`` 172 directory. The appropriate sub-directory should be selected (see the 173 :doc:`Testing Guide <TestingGuide>` for details). 174 175* Test cases should be written in :doc:`LLVM assembly language <LangRef>`. 176 177* Test cases, especially for regressions, should be reduced as much as possible, 178 by :doc:`bugpoint <Bugpoint>` or manually. It is unacceptable to place an 179 entire failing program into ``llvm/test`` as this creates a *time-to-test* 180 burden on all developers. Please keep them short. 181 182Note that llvm/test and clang/test are designed for regression and small feature 183tests only. More extensive test cases (e.g., entire applications, benchmarks, 184etc) should be added to the ``llvm-test`` test suite. The llvm-test suite is 185for coverage (correctness, performance, etc) testing, not feature or regression 186testing. 187 188Quality 189------- 190 191The minimum quality standards that any change must satisfy before being 192committed to the main development branch are: 193 194#. Code must adhere to the `LLVM Coding Standards <CodingStandards.html>`_. 195 196#. Code must compile cleanly (no errors, no warnings) on at least one platform. 197 198#. Bug fixes and new features should `include a testcase`_ so we know if the 199 fix/feature ever regresses in the future. 200 201#. Code must pass the ``llvm/test`` test suite. 202 203#. The code must not cause regressions on a reasonable subset of llvm-test, 204 where "reasonable" depends on the contributor's judgement and the scope of 205 the change (more invasive changes require more testing). A reasonable subset 206 might be something like "``llvm-test/MultiSource/Benchmarks``". 207 208Additionally, the committer is responsible for addressing any problems found in 209the future that the change is responsible for. For example: 210 211* The code should compile cleanly on all supported platforms. 212 213* The changes should not cause any correctness regressions in the ``llvm-test`` 214 suite and must not cause any major performance regressions. 215 216* The change set should not cause performance or correctness regressions for the 217 LLVM tools. 218 219* The changes should not cause performance or correctness regressions in code 220 compiled by LLVM on all applicable targets. 221 222* You are expected to address any `Bugzilla bugs <https://bugs.llvm.org/>`_ that 223 result from your change. 224 225We prefer for this to be handled before submission but understand that it isn't 226possible to test all of this for every submission. Our build bots and nightly 227testing infrastructure normally finds these problems. A good rule of thumb is 228to check the nightly testers for regressions the day after your change. Build 229bots will directly email you if a group of commits that included yours caused a 230failure. You are expected to check the build bot messages to see if they are 231your fault and, if so, fix the breakage. 232 233Commits that violate these quality standards (e.g. are very broken) may be 234reverted. This is necessary when the change blocks other developers from making 235progress. The developer is welcome to re-commit the change after the problem has 236been fixed. 237 238.. _commit messages: 239 240Commit messages 241--------------- 242 243Although we don't enforce the format of commit messages, we prefer that 244you follow these guidelines to help review, search in logs, email formatting 245and so on. These guidelines are very similar to rules used by other open source 246projects. 247 248Most importantly, the contents of the message should be carefully written to 249convey the rationale of the change (without delving too much in detail). It 250also should avoid being vague or overly specific. For example, "bits were not 251set right" will leave the reviewer wondering about which bits, and why they 252weren't right, while "Correctly set overflow bits in TargetInfo" conveys almost 253all there is to the change. 254 255Below are some guidelines about the format of the message itself: 256 257* Separate the commit message into title and body separated by a blank line. 258 259* If you're not the original author, ensure the 'Author' property of the commit is 260 set to the original author and the 'Committer' property is set to yourself. 261 You can use a command similar to 262 ``git commit --amend --author="John Doe <[email protected]>"`` to correct the 263 author property if it is incorrect. See `Attribution of Changes`_ for more 264 information including the method we used for attribution before the project 265 migrated to git. 266 267* The title should be concise. Because all commits are emailed to the list with 268 the first line as the subject, long titles are frowned upon. Short titles 269 also look better in `git log`. 270 271* When the changes are restricted to a specific part of the code (e.g. a 272 back-end or optimization pass), it is customary to add a tag to the 273 beginning of the line in square brackets. For example, "[SCEV] ..." 274 or "[OpenMP] ...". This helps email filters and searches for post-commit 275 reviews. 276 277* The body, if it exists, should be separated from the title by an empty line. 278 279* The body should be concise, but explanatory, including a complete 280 reasoning. Unless it is required to understand the change, examples, 281 code snippets and gory details should be left to bug comments, web 282 review or the mailing list. 283 284* If the patch fixes a bug in bugzilla, please include the PR# in the message. 285 286* Text formatting and spelling should follow the same rules as documentation 287 and in-code comments, ex. capitalization, full stop, etc. 288 289* If the commit is a bug fix on top of another recently committed patch, or a 290 revert or reapply of a patch, include the git commit hash of the prior 291 related commit. This could be as simple as "Revert commit NNNN because it 292 caused PR#". 293 294* If the patch has been reviewed, add a link to its review page, as shown 295 `here <https://www.llvm.org/docs/Phabricator.html#committing-a-change>`_. 296 297For minor violations of these recommendations, the community normally favors 298reminding the contributor of this policy over reverting. Minor corrections and 299omissions can be handled by sending a reply to the commits mailing list. 300 301Obtaining Commit Access 302----------------------- 303 304We grant commit access to contributors with a track record of submitting high 305quality patches. If you would like commit access, please send an email to 306`Chris <mailto:[email protected]>`_ with your GitHub username. This is true 307for former contributors with SVN access as well as new contributors. 308 309Prior to obtaining commit access, it is common practice to request that 310someone with commit access commits on your behalf. When doing so, please 311provide the name and email address you would like to use in the Author 312property of the commit. 313 314Your first commit to a repository may require the autogenerated email to be 315approved by a moderator of the mailing list. 316This is normal and will be done when the mailing list owner has time. 317 318If you have recently been granted commit access, these policies apply: 319 320#. You are granted *commit-after-approval* to all parts of LLVM. For 321 information on how to get approval for a patch, please see :doc:`CodeReview`. 322 When approved, you may commit it yourself. 323 324#. You are allowed to commit patches without approval which you think are 325 obvious. This is clearly a subjective decision --- we simply expect you to 326 use good judgement. Examples include: fixing build breakage, reverting 327 obviously broken patches, documentation/comment changes, any other minor 328 changes. Avoid committing formatting- or whitespace-only changes outside of 329 code you plan to make subsequent changes to. Also, try to separate 330 formatting or whitespace changes from functional changes, either by 331 correcting the format first (ideally) or afterward. Such changes should be 332 highly localized and the commit message should clearly state that the commit 333 is not intended to change functionality, usually by stating it is 334 :ref:`NFC <nfc>`. 335 336#. You are allowed to commit patches without approval to those portions of LLVM 337 that you have contributed or maintain (i.e., have been assigned 338 responsibility for), with the proviso that such commits must not break the 339 build. This is a "trust but verify" policy, and commits of this nature are 340 reviewed after they are committed. 341 342#. Multiple violations of these policies or a single egregious violation may 343 cause commit access to be revoked. 344 345In any case, your changes are still subject to `code review`_ (either before or 346after they are committed, depending on the nature of the change). You are 347encouraged to review other peoples' patches as well, but you aren't required 348to do so. 349 350.. _discuss the change/gather consensus: 351 352Making a Major Change 353--------------------- 354 355When a developer begins a major new project with the aim of contributing it back 356to LLVM, they should inform the community with an email to the `llvm-dev 357<http://lists.llvm.org/mailman/listinfo/llvm-dev>`_ email list, to the extent 358possible. The reason for this is to: 359 360#. keep the community informed about future changes to LLVM, 361 362#. avoid duplication of effort by preventing multiple parties working on the 363 same thing and not knowing about it, and 364 365#. ensure that any technical issues around the proposed work are discussed and 366 resolved before any significant work is done. 367 368The design of LLVM is carefully controlled to ensure that all the pieces fit 369together well and are as consistent as possible. If you plan to make a major 370change to the way LLVM works or want to add a major new extension, it is a good 371idea to get consensus with the development community before you start working on 372it. 373 374Once the design of the new feature is finalized, the work itself should be done 375as a series of `incremental changes`_, not as a long-term development branch. 376 377.. _incremental changes: 378 379Incremental Development 380----------------------- 381 382In the LLVM project, we do all significant changes as a series of incremental 383patches. We have a strong dislike for huge changes or long-term development 384branches. Long-term development branches have a number of drawbacks: 385 386#. Branches must have mainline merged into them periodically. If the branch 387 development and mainline development occur in the same pieces of code, 388 resolving merge conflicts can take a lot of time. 389 390#. Other people in the community tend to ignore work on branches. 391 392#. Huge changes (produced when a branch is merged back onto mainline) are 393 extremely difficult to `code review`_. 394 395#. Branches are not routinely tested by our nightly tester infrastructure. 396 397#. Changes developed as monolithic large changes often don't work until the 398 entire set of changes is done. Breaking it down into a set of smaller 399 changes increases the odds that any of the work will be committed to the main 400 repository. 401 402To address these problems, LLVM uses an incremental development style and we 403require contributors to follow this practice when making a large/invasive 404change. Some tips: 405 406* Large/invasive changes usually have a number of secondary changes that are 407 required before the big change can be made (e.g. API cleanup, etc). These 408 sorts of changes can often be done before the major change is done, 409 independently of that work. 410 411* The remaining inter-related work should be decomposed into unrelated sets of 412 changes if possible. Once this is done, define the first increment and get 413 consensus on what the end goal of the change is. 414 415* Each change in the set can be stand alone (e.g. to fix a bug), or part of a 416 planned series of changes that works towards the development goal. 417 418* Each change should be kept as small as possible. This simplifies your work 419 (into a logical progression), simplifies code review and reduces the chance 420 that you will get negative feedback on the change. Small increments also 421 facilitate the maintenance of a high quality code base. 422 423* Often, an independent precursor to a big change is to add a new API and slowly 424 migrate clients to use the new API. Each change to use the new API is often 425 "obvious" and can be committed without review. Once the new API is in place 426 and used, it is much easier to replace the underlying implementation of the 427 API. This implementation change is logically separate from the API 428 change. 429 430If you are interested in making a large change, and this scares you, please make 431sure to first `discuss the change/gather consensus`_ then ask about the best way 432to go about making the change. 433 434Attribution of Changes 435---------------------- 436 437When contributors submit a patch to an LLVM project, other developers with 438commit access may commit it for the author once appropriate (based on the 439progression of code review, etc.). When doing so, it is important to retain 440correct attribution of contributions to their contributors. However, we do not 441want the source code to be littered with random attributions "this code written 442by J. Random Hacker" (this is noisy and distracting). In practice, the revision 443control system keeps a perfect history of who changed what, and the CREDITS.txt 444file describes higher-level contributions. If you commit a patch for someone 445else, please follow the attribution of changes in the simple manner as outlined 446by the `commit messages`_ section. Overall, please do not add contributor names 447to the source code. 448 449Also, don't commit patches authored by others unless they have submitted the 450patch to the project or you have been authorized to submit them on their behalf 451(you work together and your company authorized you to contribute the patches, 452etc.). The author should first submit them to the relevant project's commit 453list, development list, or LLVM bug tracker component. If someone sends you 454a patch privately, encourage them to submit it to the appropriate list first. 455 456Our previous version control system (subversion) did not distinguish between the 457author and the committer like git does. As such, older commits used a different 458attribution mechanism. The previous method was to include "Patch by John Doe." 459in a separate line of the commit message and there are automated processes that 460rely on this format. 461 462.. _IR backwards compatibility: 463 464IR Backwards Compatibility 465-------------------------- 466 467When the IR format has to be changed, keep in mind that we try to maintain some 468backwards compatibility. The rules are intended as a balance between convenience 469for llvm users and not imposing a big burden on llvm developers: 470 471* The textual format is not backwards compatible. We don't change it too often, 472 but there are no specific promises. 473 474* Additions and changes to the IR should be reflected in 475 ``test/Bitcode/compatibility.ll``. 476 477* The current LLVM version supports loading any bitcode since version 3.0. 478 479* After each X.Y release, ``compatibility.ll`` must be copied to 480 ``compatibility-X.Y.ll``. The corresponding bitcode file should be assembled 481 using the X.Y build and committed as ``compatibility-X.Y.ll.bc``. 482 483* Newer releases can ignore features from older releases, but they cannot 484 miscompile them. For example, if nsw is ever replaced with something else, 485 dropping it would be a valid way to upgrade the IR. 486 487* Debug metadata is special in that it is currently dropped during upgrades. 488 489* Non-debug metadata is defined to be safe to drop, so a valid way to upgrade 490 it is to drop it. That is not very user friendly and a bit more effort is 491 expected, but no promises are made. 492 493C API Changes 494---------------- 495 496* Stability Guarantees: The C API is, in general, a "best effort" for stability. 497 This means that we make every attempt to keep the C API stable, but that 498 stability will be limited by the abstractness of the interface and the 499 stability of the C++ API that it wraps. In practice, this means that things 500 like "create debug info" or "create this type of instruction" are likely to be 501 less stable than "take this IR file and JIT it for my current machine". 502 503* Release stability: We won't break the C API on the release branch with patches 504 that go on that branch, with the exception that we will fix an unintentional 505 C API break that will keep the release consistent with both the previous and 506 next release. 507 508* Testing: Patches to the C API are expected to come with tests just like any 509 other patch. 510 511* Including new things into the API: If an LLVM subcomponent has a C API already 512 included, then expanding that C API is acceptable. Adding C API for 513 subcomponents that don't currently have one needs to be discussed on the 514 mailing list for design and maintainability feedback prior to implementation. 515 516* Documentation: Any changes to the C API are required to be documented in the 517 release notes so that it's clear to external users who do not follow the 518 project how the C API is changing and evolving. 519 520.. _toolchain: 521 522Updating Toolchain Requirements 523------------------------------- 524 525We intend to require newer toolchains as time goes by. This means LLVM's 526codebase can use newer versions of C++ as they get standardized. Requiring newer 527toolchains to build LLVM can be painful for those building LLVM; therefore, it 528will only be done through the following process: 529 530 * It is a general goal to support LLVM and GCC versions from the last 3 years 531 at a minimum. This time-based guideline is not strict: we may support much 532 older compilers, or decide to support fewer versions. 533 534 * An RFC is sent to the `llvm-dev mailing list`_ 535 536 - Detail upsides of the version increase (e.g. which newer C++ language or 537 library features LLVM should use; avoid miscompiles in particular compiler 538 versions, etc). 539 - Detail downsides on important platforms (e.g. Ubuntu LTS status). 540 541 * Once the RFC reaches consensus, update the CMake toolchain version checks as 542 well as the :doc:`getting started<GettingStarted>` guide. This provides a 543 softer transition path for developers compiling LLVM, because the 544 error can be turned into a warning using a CMake flag. This is an important 545 step: LLVM still doesn't have code which requires the new toolchains, but it 546 soon will. If you compile LLVM but don't read the mailing list, we should 547 tell you! 548 549 * Ensure that at least one LLVM release has had this soft-error. Not all 550 developers compile LLVM top-of-tree. These release-bound developers should 551 also be told about upcoming changes. 552 553 * Turn the soft-error into a hard-error after said LLVM release has branched. 554 555 * Update the :doc:`coding standards<CodingStandards>` to allow the new 556 features we've explicitly approved in the RFC. 557 558 * Start using the new features in LLVM's codebase. 559 560Here's a `sample RFC 561<http://lists.llvm.org/pipermail/llvm-dev/2019-January/129452.html>`_ and the 562`corresponding change <https://reviews.llvm.org/D57264>`_. 563 564.. _new-llvm-components: 565 566Introducing New Components into LLVM 567==================================== 568 569The LLVM community is a vibrant and exciting place to be, and we look to be 570inclusive of new projects and foster new communities, and increase 571collaboration across industry and academia. 572 573That said, we need to strike a balance between being inclusive of new ideas and 574people and the cost of ongoing maintenance that new code requires. As such, we 575have a general :doc:`support policy<SupportPolicy>` for introducing major new 576components into the LLVM world, depending on the degree of detail and 577responsibility required. *Core* projects need a higher degree of scrutiny 578than *peripheral* projects, and the latter may have additional differences. 579 580However, this is really only intended to cover common cases 581that we have seen arise: different situations are different, and we are open 582to discussing unusual cases as well - just start an RFC thread on the 583`llvm-dev mailing list`_. 584 585Adding a New Target 586------------------- 587 588LLVM is very receptive to new targets, even experimental ones, but a number of 589problems can appear when adding new large portions of code, and back-ends are 590normally added in bulk. New targets need the same level of support as other 591*core* parts of the compiler, so they are covered in the *core tier* of our 592:doc:`support policy<SupportPolicy>`. 593 594We have found that landing large pieces of new code and then trying to fix 595emergent problems in-tree is problematic for a variety of reasons. For these 596reasons, new targets are *always* added as *experimental* until they can be 597proven stable, and later moved to non-experimental. 598 599The differences between both classes are: 600 601* Experimental targets are not built by default (they need to be explicitly 602 enabled at CMake time). 603 604* Test failures, bugs, and build breakages that only appear when the 605 experimental target is enabled, caused by changes unrelated to the target, are 606 the responsibility of the community behind the target to fix. 607 608The basic rules for a back-end to be upstreamed in **experimental** mode are: 609 610* Every target must have a :ref:`code owner<code owners>`. The `CODE_OWNERS.TXT` 611 file has to be updated as part of the first merge. The code owner makes sure 612 that changes to the target get reviewed and steers the overall effort. 613 614* There must be an active community behind the target. This community 615 will help maintain the target by providing buildbots, fixing 616 bugs, answering the LLVM community's questions and making sure the new 617 target doesn't break any of the other targets, or generic code. This 618 behavior is expected to continue throughout the lifetime of the 619 target's code. 620 621* The code must be free of contentious issues, for example, large 622 changes in how the IR behaves or should be formed by the front-ends, 623 unless agreed by the majority of the community via refactoring of the 624 (:doc:`IR standard<LangRef>`) **before** the merge of the new target changes, 625 following the :ref:`IR backwards compatibility`. 626 627* The code conforms to all of the policies laid out in this developer policy 628 document, including license, patent, and coding standards. 629 630* The target should have either reasonable documentation on how it 631 works (ISA, ABI, etc.) or a publicly available simulator/hardware 632 (either free or cheap enough) - preferably both. This allows 633 developers to validate assumptions, understand constraints and review code 634 that can affect the target. 635 636In addition, the rules for a back-end to be promoted to **official** are: 637 638* The target must have addressed every other minimum requirement and 639 have been stable in tree for at least 3 months. This cool down 640 period is to make sure that the back-end and the target community can 641 endure continuous upstream development for the foreseeable future. 642 643* The target's code must have been completely adapted to this policy 644 as well as the :doc:`coding standards<CodingStandards>`. Any exceptions that 645 were made to move into experimental mode must have been fixed **before** 646 becoming official. 647 648* The test coverage needs to be broad and well written (small tests, 649 well documented). The build target ``check-all`` must pass with the 650 new target built, and where applicable, the ``test-suite`` must also 651 pass without errors, in at least one configuration (publicly 652 demonstrated, for example, via buildbots). 653 654* Public buildbots need to be created and actively maintained, unless 655 the target requires no additional buildbots (ex. ``check-all`` covers 656 all tests). The more relevant and public the new target's CI infrastructure 657 is, the more the LLVM community will embrace it. 658 659To **continue** as a supported and official target: 660 661* The maintainer(s) must continue following these rules throughout the lifetime 662 of the target. Continuous violations of aforementioned rules and policies 663 could lead to complete removal of the target from the code base. 664 665* Degradation in support, documentation or test coverage will make the target as 666 nuisance to other targets and be considered a candidate for deprecation and 667 ultimately removed. 668 669In essences, these rules are necessary for targets to gain and retain their 670status, but also markers to define bit-rot, and will be used to clean up the 671tree from unmaintained targets. 672 673Adding an Established Project To the LLVM Monorepo 674-------------------------------------------------- 675 676The `LLVM monorepo <https://github.com/llvm/llvm-project>`_ is the centerpoint 677of development in the LLVM world, and has all of the primary LLVM components, 678including the LLVM optimizer and code generators, Clang, LLDB, etc. `Monorepos 679in general <https://en.wikipedia.org/wiki/Monorepo>`_ are great because they 680allow atomic commits to the project, simplify CI, and make it easier for 681subcommunities to collaborate. 682 683Like new targets, most projects already in the monorepo are considered to be in 684the *core tier* of our :doc:`support policy<SupportPolicy>`. The burden to add 685things to the LLVM monorepo needs to be very high - code that is added to this 686repository is checked out by everyone in the community. As such, we hold 687components to a high bar similar to "official targets", they: 688 689 * Must be generally aligned with the mission of the LLVM project to advance 690 compilers, languages, tools, runtimes, etc. 691 * Must conform to all of the policies laid out in this developer policy 692 document, including license, patent, coding standards, and code of conduct. 693 * Must have an active community that maintains the code, including established 694 code owners. 695 * Should have reasonable documentation about how it works, including a high 696 quality README file. 697 * Should have CI to catch breakage within the project itself or due to 698 underlying LLVM dependencies. 699 * Should have code free of issues the community finds contentious, or be on a 700 clear path to resolving them. 701 * Must be proposed through the LLVM RFC process, and have its addition approved 702 by the LLVM community - this ultimately mediates the resolution of the 703 "should" concerns above. 704 705If you have a project that you think would make sense to add to the LLVM 706monorepo, please start an RFC thread on the `llvm-dev mailing list`_ to kick off 707the discussion. This process can take some time and iteration - please don’t 708be discouraged or intimidated by that! 709 710If you have an earlier stage project that you think is aligned with LLVM, please 711see the "Incubating New Projects" section. 712 713Incubating New Projects 714----------------------- 715 716The burden to add a new project to the LLVM monorepo is intentionally very high, 717but that can have a chilling effect on new and innovative projects. To help 718foster these sorts of projects, LLVM supports an "incubator" process that is 719much easier to get started with. It provides space for potentially valuable, 720new top-level and sub-projects to reach a critical mass before they have enough 721code to prove their utility and grow a community. This also allows 722collaboration between teams that already have permissions to make contributions 723to projects under the LLVM umbrella. 724 725Projects which can be considered for the LLVM incubator meet the following 726criteria: 727 728 * Must be generally aligned with the mission of the LLVM project to advance 729 compilers, languages, tools, runtimes, etc. 730 * Must conform to the license, patent, and code of conduct policies laid out 731 in this developer policy document. 732 * Must have a documented charter and development plan, e.g. in the form of a 733 README file, mission statement, and/or manifesto. 734 * Should conform to coding standards, incremental development process, and 735 other expectations. 736 * Should have a sense of the community that it hopes to eventually foster, and 737 there should be interest from members with different affiliations / 738 organizations. 739 * Should have a feasible path to eventually graduate as a dedicated top-level 740 or sub-project within the `LLVM monorepo 741 <https://github.com/llvm/llvm-project>`_. 742 * Should include a notice (e.g. in the project README or web page) that the 743 project is in ‘incubation status’ and is not included in LLVM releases (see 744 suggested wording below). 745 * Must be proposed through the LLVM RFC process, and have its addition 746 approved by the LLVM community - this ultimately mediates the resolution of 747 the "should" concerns above. 748 749That said, the project need not have any code to get started, and need not have 750an established community at all! Furthermore, incubating projects may pass 751through transient states that violate the "Should" guidelines above, or would 752otherwise make them unsuitable for direct inclusion in the monorepo (e.g. 753dependencies that have not yet been factored appropriately, leveraging 754experimental components or APIs that are not yet upstream, etc). 755 756When approved, the llvm-admin group can grant the new project: 757 * A new repository in the LLVM Github Organization - but not the LLVM monorepo. 758 * New mailing list, discourse forum, and/or discord chat hosted with other LLVM 759 forums. 760 * Other infrastructure integration can be discussed on a case-by-case basis. 761 762Graduation to the mono-repo would follow existing processes and standards for 763becoming a first-class part of the monorepo. Similarly, an incubating project 764may be eventually retired, but no process has been established for that yet. If 765and when this comes up, please start an RFC discussion on llvm-dev. 766 767This process is very new - please expect the details to change, it is always 768safe to ask on the `llvm-dev mailing list`_ about this. 769 770Suggested disclaimer for the project README and the main project web page: 771 772:: 773 774 This project is participating in the LLVM Incubator process: as such, it is 775 not part of any official LLVM release. While incubation status is not 776 necessarily a reflection of the completeness or stability of the code, it 777 does indicate that the project is not yet endorsed as a component of LLVM. 778 779.. _copyright-license-patents: 780 781Copyright, License, and Patents 782=============================== 783 784.. note:: 785 786 This section deals with legal matters but does not provide legal advice. We 787 are not lawyers --- please seek legal counsel from a licensed attorney. 788 789This section addresses the issues of copyright, license and patents for the LLVM 790project. The copyright for the code is held by the contributors of 791the code. The code is licensed under permissive `open source licensing terms`_, 792namely the Apache-2.0 with LLVM-exception license, which includes a copyright 793and `patent license`_. When you contribute code to the LLVM project, you 794license it under these terms. 795 796If you have questions or comments about these topics, please contact the 797`LLVM Developer's Mailing List <mailto:[email protected]>`_. However, 798please realize that most compiler developers are not lawyers, and therefore you 799will not be getting official legal advice. 800 801Copyright 802--------- 803 804The LLVM project does not collect copyright assignments, which means that the 805copyright for the code in the project is held by the respective contributors. 806Because you (or your company) 807retain ownership of the code you contribute, you know it may only be used under 808the terms of the open source license you contributed it under: the license for 809your contributions cannot be changed in the future without your approval. 810 811Because the LLVM project does not require copyright assignments, changing the 812LLVM license requires tracking down the 813contributors to LLVM and getting them to agree that a license change is 814acceptable for their contributions. We feel that a high burden for relicensing 815is good for the project, because contributors do not have to fear that their 816code will be used in a way with which they disagree. 817 818Relicensing 819----------- 820 821The last paragraph notwithstanding, the LLVM Project is in the middle of a large 822effort to change licenses, which aims to solve several problems: 823 824* The old licenses made it difficult to move code from (e.g.) the compiler to 825 runtime libraries, because runtime libraries used a different license from the 826 rest of the compiler. 827* Some contributions were not submitted to LLVM due to concerns that 828 the patent grant required by the project was overly broad. 829* The patent grant was unique to the LLVM Project, not written by a lawyer, and 830 was difficult to determine what protection was provided (if any). 831 832The scope of relicensing is all code that is considered part of the LLVM 833project, including the main LLVM repository, runtime libraries (compiler_rt, 834OpenMP, etc), Polly, and all other subprojects. There are a few exceptions: 835 836* Code imported from other projects (e.g. Google Test, Autoconf, etc) will 837 remain as it is. This code isn't developed as part of the LLVM project, it 838 is used by LLVM. 839* Some subprojects are impractical or uninteresting to relicense (e.g. llvm-gcc 840 and dragonegg). These will be split off from the LLVM project (e.g. to 841 separate GitHub projects), allowing interested people to continue their 842 development elsewhere. 843 844To relicense LLVM, we will be seeking approval from all of the copyright holders 845of code in the repository, or potentially remove/rewrite code if we cannot. 846This is a large 847and challenging project which will take a significant amount of time to 848complete. In the interim, **all contributions to the project will be made under 849the terms of both the new license and the legacy license scheme** (each of which 850is described below). The exception to this is the legacy patent grant, which 851will not be required for new contributions. 852 853When all of the code in the project has been converted to the new license or 854removed, we will drop the requirement to contribute under the legacy license. 855This will achieve the goal of having 856a single standardized license for the entire codebase. 857 858If you are a prior contributor to LLVM and have not done so already, please do 859*TODO* to allow us to use your code. *Add a link to a separate page here, which 860is probably a click through web form or something like that. Details to be 861determined later*. 862 863 864.. _open source licensing terms: 865 866New LLVM Project License Framework 867---------------------------------- 868 869Contributions to LLVM are licensed under the `Apache License, Version 2.0 870<https://www.apache.org/licenses/LICENSE-2.0>`_, with two limited 871exceptions intended to ensure that LLVM is very permissively licensed. 872Collectively, the name of this license is "Apache 2.0 License with LLVM 873exceptions". The exceptions read: 874 875:: 876 877 ---- LLVM Exceptions to the Apache 2.0 License ---- 878 879 As an exception, if, as a result of your compiling your source code, portions 880 of this Software are embedded into an Object form of such source code, you 881 may redistribute such embedded portions in such Object form without complying 882 with the conditions of Sections 4(a), 4(b) and 4(d) of the License. 883 884 In addition, if you combine or link compiled forms of this Software with 885 software that is licensed under the GPLv2 ("Combined Software") and if a 886 court of competent jurisdiction determines that the patent provision (Section 887 3), the indemnity provision (Section 9) or other Section of the License 888 conflicts with the conditions of the GPLv2, you may retroactively and 889 prospectively choose to deem waived or otherwise exclude such Section(s) of 890 the License, but only in their entirety and only with respect to the Combined 891 Software. 892 893 894We intend to keep LLVM perpetually open source and available under a permissive 895license - this fosters the widest adoption of LLVM by 896**allowing commercial products to be derived from LLVM** with few restrictions 897and without a requirement for making any derived works also open source. In 898particular, LLVM's license is not a "copyleft" license like the GPL. 899 900The "Apache 2.0 License with LLVM exceptions" allows you to: 901 902* freely download and use LLVM (in whole or in part) for personal, internal, or 903 commercial purposes. 904* include LLVM in packages or distributions you create. 905* combine LLVM with code licensed under every other major open source 906 license (including BSD, MIT, GPLv2, GPLv3...). 907* make changes to LLVM code without being required to contribute it back 908 to the project - contributions are appreciated though! 909 910However, it imposes these limitations on you: 911 912* You must retain the copyright notice if you redistribute LLVM: You cannot 913 strip the copyright headers off or replace them with your own. 914* Binaries that include LLVM must reproduce the copyright notice (e.g. in an 915 included README file or in an "About" box), unless the LLVM code was added as 916 a by-product of compilation. For example, if an LLVM runtime library like 917 compiler_rt or libc++ was automatically included into your application by the 918 compiler, you do not need to attribute it. 919* You can't use our names to promote your products (LLVM derived or not) - 920 though you can make truthful statements about your use of the LLVM code, 921 without implying our sponsorship. 922* There's no warranty on LLVM at all. 923 924We want LLVM code to be widely used, and believe that this provides a model that 925is great for contributors and users of the project. For more information about 926the Apache 2.0 License, please see the `Apache License FAQ 927<http://www.apache.org/foundation/license-faq.html>`_, maintained by the 928Apache Project. 929 930 931.. note:: 932 933 The LLVM Project includes some really old subprojects (dragonegg, 934 llvm-gcc-4.0, and llvm-gcc-4.2), which are licensed under **GPL 935 licenses**. This code is not actively maintained - it does not even 936 build successfully. This code is cleanly separated into distinct SVN 937 repositories from the rest of LLVM, and the LICENSE.txt files specifically 938 indicate that they contain GPL code. When LLVM transitions from SVN to Git, 939 we plan to drop these code bases from the new repository structure. 940 941 942.. _patent license: 943 944Patents 945------- 946 947Section 3 of the Apache 2.0 license is a patent grant under which 948contributors of code to the project contribute the rights to use any of 949their patents that would otherwise be infringed by that code contribution 950(protecting uses of that code). Further, the patent grant is revoked 951from anyone who files a patent lawsuit about code in LLVM - this protects the 952community by providing a "patent commons" for the code base and reducing the 953odds of patent lawsuits in general. 954 955The license specifically scopes which patents are included with code 956contributions. To help explain this, the `Apache License FAQ 957<http://www.apache.org/foundation/license-faq.html>`_ explains this scope using 958some questions and answers, which we reproduce here for your convenience (for 959reference, the "ASF" is the Apache Software Foundation, the guidance still 960holds though):: 961 962 Q1: If I own a patent and contribute to a Work, and, at the time my 963 contribution is included in that Work, none of my patent's claims are subject 964 to Apache's Grant of Patent License, is there a way any of those claims would 965 later become subject to the Grant of Patent License solely due to subsequent 966 contributions by other parties who are not licensees of that patent. 967 968 A1: No. 969 970 Q2: If at any time after my contribution, I am able to license other patent 971 claims that would have been subject to Apache's Grant of Patent License if 972 they were licensable by me at the time of my contribution, do those other 973 claims become subject to the Grant of Patent License? 974 975 A2: Yes. 976 977 Q3: If I own or control a licensable patent and contribute code to a specific 978 Apache product, which of my patent claims are subject to Apache's Grant of 979 Patent License? 980 981 A3: The only patent claims that are licensed to the ASF are those you own or 982 have the right to license that read on your contribution or on the 983 combination of your contribution with the specific Apache product to which 984 you contributed as it existed at the time of your contribution. No additional 985 patent claims become licensed as a result of subsequent combinations of your 986 contribution with any other software. Note, however, that licensable patent 987 claims include those that you acquire in the future, as long as they read on 988 your original contribution as made at the original time. Once a patent claim 989 is subject to Apache's Grant of Patent License, it is licensed under the 990 terms of that Grant to the ASF and to recipients of any software distributed 991 by the ASF for any Apache software product whatsoever. 992 993.. _legacy: 994 995Legacy License Structure 996------------------------ 997 998.. note:: 999 The code base was previously licensed under the Terms described here. 1000 We are in the middle of relicensing to a new approach (described above), but 1001 until this effort is complete, the code is also still available under these 1002 terms. Once we finish the relicensing project, new versions of the code will 1003 not be available under these terms. However, nothing takes away your right 1004 to use old versions under the licensing terms under which they were 1005 originally released. 1006 1007We intend to keep LLVM perpetually open source and to use a permissive open 1008source license. The code in 1009LLVM is available under the `University of Illinois/NCSA Open Source License 1010<http://www.opensource.org/licenses/UoI-NCSA.php>`_, which boils down to 1011this: 1012 1013* You can freely distribute LLVM. 1014* You must retain the copyright notice if you redistribute LLVM. 1015* Binaries derived from LLVM must reproduce the copyright notice (e.g. in an 1016 included README file). 1017* You can't use our names to promote your LLVM derived products. 1018* There's no warranty on LLVM at all. 1019 1020We believe this fosters the widest adoption of LLVM because it **allows 1021commercial products to be derived from LLVM** with few restrictions and without 1022a requirement for making any derived works also open source (i.e. LLVM's 1023license is not a "copyleft" license like the GPL). We suggest that you read the 1024`License <http://www.opensource.org/licenses/UoI-NCSA.php>`_ if further 1025clarification is needed. 1026 1027In addition to the UIUC license, the runtime library components of LLVM 1028(**compiler_rt, libc++, and libclc**) are also licensed under the `MIT License 1029<http://www.opensource.org/licenses/mit-license.php>`_, which does not contain 1030the binary redistribution clause. As a user of these runtime libraries, it 1031means that you can choose to use the code under either license (and thus don't 1032need the binary redistribution clause), and as a contributor to the code that 1033you agree that any contributions to these libraries be licensed under both 1034licenses. We feel that this is important for runtime libraries, because they 1035are implicitly linked into applications and therefore should not subject those 1036applications to the binary redistribution clause. This also means that it is ok 1037to move code from (e.g.) libc++ to the LLVM core without concern, but that code 1038cannot be moved from the LLVM core to libc++ without the copyright owner's 1039permission. 1040 1041.. _llvm-dev mailing list: http://lists.llvm.org/mailman/listinfo/llvm-dev 1042