rustc licensing guidelines
Rationale: due to multiple incidents around licensing of rustc, we are putting guidelines in place for adoption of code into the project. Accidental inclusion of incompatible code or improper licensing of ported code poses a substantial risk for rustc. These apply to all newly posted pull requests and must be followed.

1. Responsibility and Severity


In general, reviewers need to be looking not only for the code quality of contributions but also that they are properly licensed. We have some tips below for things to look out for when reviewing, but if you ever feel uncertain as to whether some code might be properly licensed, err on the safe side — reach out to the core team for feedback!

Things to watch out for:
  • The PR author states that they copied, ported, or adapted the code from some other source.
  • There is a comment in the code pointing to a webpage or describing where the algorithm was taken from.
  • The algorithm or code pattern seems like it was likely copied from somewhere else.

In all of these cases, we will want to check that source to make sure it it is licensed in a way that is compatible with Rust’s license.

Examples

  • Porting C code from a GPL project, like GNU binutils, is not allowed. That would require rust itself to be licensed under the GPL.
  • Copying code from an algorithms text book may be allowed, but some algorithms are patented.


Code reviewers are responsible not only for the code quality of contributions, but also for their legal soundness. If code is obviously ported/imported, apply the guidelines below. If you are not sure, err on the safe side - licensing issues encumber all following releases until they are fixed!

In case you’re not sure, please contact core.

2. Current state: License review


Unfortunately, we’ve had a number of PRs land where the code may have been incorrectly licensed. We are currently in the process of reviewing the rustc code base to ensure we are on safe ground. Therefore, it is important that we take extra care when reviewing not to make the situation worse.

The rustc codebase must currently be considered to be in an unknown state around licensing. This is following multiple findings of wrong license attribution or inclusion of code from other projects with different licenses. Please take great care to not worsen the situation!

3. rustc main codebase licensing


rustc and all libraries originally produced for it are double-licensed MIT/APACHE-2.0, with the user being allowed to choose between both. This means all contributions to its main code must be licensed under both licenses, to allow the user to pick. Including code that is only MIT or only APACHE-2.0 licensed into a code base means a breach of contract towards our user. New developments done by the Rust project must be MIT/APACHE-2.0 only.

Note that due to the mixed nature of rustc’s licensing, users must use rustc library by library and some may not give them the opportunity described above. This is acceptable and hard to rule out.

4. License isolation


rustc can use libraries under different, compatible licenses. Those include the University of Berkeley license and several BSD licenses. This list is non-exhaustive. In general, once picked, libraries should be checked for their compatibility with the distribution and then not changed.

5. Porting work


Contributions to rustc, especially around platform and compiler intrinsics, often include porting over work from other projects, mainly LLVM and GCC.

Some general rules apply:

  • Copying work needs to adhere to the original license
  • This applies to direct copy & paste
  • This also applies to code you looked at and ported