Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 39 additions & 92 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ const LICENSES: &[&str] = &[
"Apache-2.0 OR ISC OR MIT",
"Apache-2.0 OR MIT",
"Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT", // wasi license
"Apache-2.0 WITH LLVM-exception",
"Apache-2.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised we allow bare Apache-2.0 for the runtime. This was added in a dependency update PR over a year ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise; I'd like to know where this is used, and if we could avoid it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it isn't used for the runtime, only for tools. I've pushed a commit to move all licenses that are not like MIT to the tools-only license list.

"Apache-2.0/MIT",
"BSD-2-Clause OR Apache-2.0 OR MIT", // zerocopy
"BSD-2-Clause OR MIT OR Apache-2.0",
"BSD-3-Clause/MIT",
"CC0-1.0 OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception",
"CC0-1.0 OR MIT-0 OR Apache-2.0",
"ISC",
"MIT / Apache-2.0",
"MIT AND (MIT OR Apache-2.0)",
"MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)", // compiler-builtins
"MIT OR Apache-2.0 OR LGPL-2.1-or-later", // r-efi, r-efi-alloc
"MIT OR Apache-2.0 OR BSD-1-Clause",
"MIT OR Apache-2.0 OR LGPL-2.1-or-later", // r-efi, r-efi-alloc; LGPL is not acceptable, but we use it under MIT OR Apache-2.0
"MIT OR Apache-2.0 OR Zlib", // tinyvec_macros
"MIT OR Apache-2.0",
"MIT OR Zlib OR Apache-2.0", // miniz_oxide
Expand All @@ -48,6 +54,20 @@ const LICENSES: &[&str] = &[
// tidy-alphabetical-end
];

/// These are licenses that are allowed for rustc, tools, etc. But not for the runtime!
#[rustfmt::skip]
const LICENSES_TOOLS: &[&str] = &[
// tidy-alphabetical-start
"(Apache-2.0 OR MIT) AND BSD-3-Clause",
"Apache-2.0 AND ISC",
"Apache-2.0 OR BSL-1.0", // BSL is not acceptble, but we use it under Apache-2.0
"BSD-2-Clause",
"BSD-3-Clause",
"CC0-1.0",
"Zlib",
// tidy-alphabetical-end
];

type ExceptionList = &'static [(&'static str, &'static str)];

#[derive(Clone, Copy)]
Expand Down Expand Up @@ -89,17 +109,15 @@ pub(crate) const WORKSPACES: &[WorkspaceInfo<'static>] = &[
)),
submodules: &[],
},
{
WorkspaceInfo {
path: "compiler/rustc_codegen_cranelift",
exceptions: EXCEPTIONS_CRANELIFT,
crates_and_deps: Some((
&["rustc_codegen_cranelift"],
PERMITTED_CRANELIFT_DEPENDENCIES,
PERMITTED_CRANELIFT_DEPS_LOCATION,
)),
submodules: &[],
}
WorkspaceInfo {
path: "compiler/rustc_codegen_cranelift",
exceptions: EXCEPTIONS_CRANELIFT,
crates_and_deps: Some((
&["rustc_codegen_cranelift"],
PERMITTED_CRANELIFT_DEPENDENCIES,
PERMITTED_CRANELIFT_DEPS_LOCATION,
)),
submodules: &[],
},
WorkspaceInfo {
path: "compiler/rustc_codegen_gcc",
Expand Down Expand Up @@ -169,19 +187,8 @@ pub(crate) const WORKSPACES: &[WorkspaceInfo<'static>] = &[
#[rustfmt::skip]
const EXCEPTIONS: ExceptionList = &[
// tidy-alphabetical-start
("ar_archive_writer", "Apache-2.0 WITH LLVM-exception"), // rustc
("arrayref", "BSD-2-Clause"), // rustc
("blake3", "CC0-1.0 OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception"), // rustc
("colored", "MPL-2.0"), // rustfmt
("constant_time_eq", "CC0-1.0 OR MIT-0 OR Apache-2.0"), // rustc
("dissimilar", "Apache-2.0"), // rustdoc, rustc_lexer (few tests) via expect-test, (dev deps)
("fluent-langneg", "Apache-2.0"), // rustc (fluent translations)
("foldhash", "Zlib"), // rustc
("option-ext", "MPL-2.0"), // cargo-miri (via `directories`)
("rustc_apfloat", "Apache-2.0 WITH LLVM-exception"), // rustc (license is the same as LLVM uses)
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0 // cargo/... (because of serde)
("self_cell", "Apache-2.0"), // rustc (fluent translations)
("wasi-preview1-component-adapter-provider", "Apache-2.0 WITH LLVM-exception"), // rustc
// tidy-alphabetical-end
];

Expand All @@ -198,57 +205,22 @@ const EXCEPTIONS_STDLIB: ExceptionList = &[

const EXCEPTIONS_CARGO: ExceptionList = &[
// tidy-alphabetical-start
("arrayref", "BSD-2-Clause"),
("bitmaps", "MPL-2.0+"),
("blake3", "CC0-1.0 OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception"),
("ciborium", "Apache-2.0"),
("ciborium-io", "Apache-2.0"),
("ciborium-ll", "Apache-2.0"),
("constant_time_eq", "CC0-1.0 OR MIT-0 OR Apache-2.0"),
("dunce", "CC0-1.0 OR MIT-0 OR Apache-2.0"),
("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"),
("fiat-crypto", "MIT OR Apache-2.0 OR BSD-1-Clause"),
("foldhash", "Zlib"),
("im-rc", "MPL-2.0+"),
("libz-rs-sys", "Zlib"),
("normalize-line-endings", "Apache-2.0"),
("openssl", "Apache-2.0"),
("ring", "Apache-2.0 AND ISC"),
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0
("similar", "Apache-2.0"),
("sized-chunks", "MPL-2.0+"),
("subtle", "BSD-3-Clause"),
("supports-hyperlinks", "Apache-2.0"),
("unicode-bom", "Apache-2.0"),
("zlib-rs", "Zlib"),
// tidy-alphabetical-end
];

const EXCEPTIONS_RUST_ANALYZER: ExceptionList = &[
// tidy-alphabetical-start
("dissimilar", "Apache-2.0"),
("foldhash", "Zlib"),
("notify", "CC0-1.0"),
("option-ext", "MPL-2.0"),
("pulldown-cmark-to-cmark", "Apache-2.0"),
("rustc_apfloat", "Apache-2.0 WITH LLVM-exception"),
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0
("scip", "Apache-2.0"),
// tidy-alphabetical-end
];

const EXCEPTIONS_RUSTC_PERF: ExceptionList = &[
// tidy-alphabetical-start
("alloc-no-stdlib", "BSD-3-Clause"),
("alloc-stdlib", "BSD-3-Clause"),
("brotli", "BSD-3-Clause/MIT"),
("brotli-decompressor", "BSD-3-Clause/MIT"),
("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"),
("inferno", "CDDL-1.0"),
("option-ext", "MPL-2.0"),
("ryu", "Apache-2.0 OR BSL-1.0"),
("snap", "BSD-3-Clause"),
("subtle", "BSD-3-Clause"),
// tidy-alphabetical-end
];

Expand All @@ -258,36 +230,10 @@ const EXCEPTIONS_RUSTBOOK: ExceptionList = &[
("cssparser-macros", "MPL-2.0"),
("dtoa-short", "MPL-2.0"),
("mdbook", "MPL-2.0"),
("ryu", "Apache-2.0 OR BSL-1.0"),
// tidy-alphabetical-end
];

const EXCEPTIONS_CRANELIFT: ExceptionList = &[
// tidy-alphabetical-start
("cranelift-assembler-x64", "Apache-2.0 WITH LLVM-exception"),
("cranelift-assembler-x64-meta", "Apache-2.0 WITH LLVM-exception"),
("cranelift-bforest", "Apache-2.0 WITH LLVM-exception"),
("cranelift-bitset", "Apache-2.0 WITH LLVM-exception"),
("cranelift-codegen", "Apache-2.0 WITH LLVM-exception"),
("cranelift-codegen-meta", "Apache-2.0 WITH LLVM-exception"),
("cranelift-codegen-shared", "Apache-2.0 WITH LLVM-exception"),
("cranelift-control", "Apache-2.0 WITH LLVM-exception"),
("cranelift-entity", "Apache-2.0 WITH LLVM-exception"),
("cranelift-frontend", "Apache-2.0 WITH LLVM-exception"),
("cranelift-isle", "Apache-2.0 WITH LLVM-exception"),
("cranelift-jit", "Apache-2.0 WITH LLVM-exception"),
("cranelift-module", "Apache-2.0 WITH LLVM-exception"),
("cranelift-native", "Apache-2.0 WITH LLVM-exception"),
("cranelift-object", "Apache-2.0 WITH LLVM-exception"),
("cranelift-srcgen", "Apache-2.0 WITH LLVM-exception"),
("foldhash", "Zlib"),
("mach2", "BSD-2-Clause OR MIT OR Apache-2.0"),
("regalloc2", "Apache-2.0 WITH LLVM-exception"),
("target-lexicon", "Apache-2.0 WITH LLVM-exception"),
("wasmtime-jit-icache-coherence", "Apache-2.0 WITH LLVM-exception"),
("wasmtime-math", "Apache-2.0 WITH LLVM-exception"),
// tidy-alphabetical-end
];
const EXCEPTIONS_CRANELIFT: ExceptionList = &[];

const EXCEPTIONS_GCC: ExceptionList = &[
// tidy-alphabetical-start
Expand All @@ -296,13 +242,9 @@ const EXCEPTIONS_GCC: ExceptionList = &[
// tidy-alphabetical-end
];

const EXCEPTIONS_BOOTSTRAP: ExceptionList = &[
("ryu", "Apache-2.0 OR BSL-1.0"), // through serde. BSL is not acceptble, but we use it under Apache-2.0
];
const EXCEPTIONS_BOOTSTRAP: ExceptionList = &[];

const EXCEPTIONS_UEFI_QEMU_TEST: ExceptionList = &[
("r-efi", "MIT OR Apache-2.0 OR LGPL-2.1-or-later"), // LGPL is not acceptable, but we use it under MIT OR Apache-2.0
];
const EXCEPTIONS_UEFI_QEMU_TEST: ExceptionList = &[];

#[derive(Clone, Copy)]
struct ListLocation {
Expand Down Expand Up @@ -867,6 +809,11 @@ fn check_license_exceptions(
}
}
}
if LICENSES.contains(license) || LICENSES_TOOLS.contains(license) {
check.error(format!(
"dependency exception `{name}` is not necessary. `{license}` is an allowed license"
));
}
}

let exception_names: Vec<_> = exceptions.iter().map(|(name, _license)| *name).collect();
Expand All @@ -890,7 +837,7 @@ fn check_license_exceptions(
continue;
}
};
if !LICENSES.contains(&license.as_str()) {
if !LICENSES.contains(&license.as_str()) && !LICENSES_TOOLS.contains(&license.as_str()) {
check.error(format!(
"invalid license `{}` for package `{}` in workspace `{workspace}`",
license, pkg.id
Expand Down
Loading