@@ -54,6 +54,7 @@ type ExceptionList = &'static [(&'static str, &'static str)];
54
54
pub ( crate ) const WORKSPACES : & [ ( & str , ExceptionList , Option < ( & [ & str ] , & [ & str ] ) > , & [ & str ] ) ] = & [
55
55
// The root workspace has to be first for check_rustfix to work.
56
56
( "." , EXCEPTIONS , Some ( ( & [ "rustc-main" ] , PERMITTED_RUSTC_DEPENDENCIES ) ) , & [ ] ) ,
57
+ ( "library" , EXCEPTIONS_STDLIB , Some ( ( & [ "sysroot" ] , PERMITTED_STDLIB_DEPENDENCIES ) ) , & [ ] ) ,
57
58
// Outside of the alphabetical section because rustfmt formats it using multiple lines.
58
59
(
59
60
"compiler/rustc_codegen_cranelift" ,
@@ -90,7 +91,6 @@ const EXCEPTIONS: ExceptionList = &[
90
91
( "colored" , "MPL-2.0" ) , // rustfmt
91
92
( "dissimilar" , "Apache-2.0" ) , // rustdoc, rustc_lexer (few tests) via expect-test, (dev deps)
92
93
( "fluent-langneg" , "Apache-2.0" ) , // rustc (fluent translations)
93
- ( "fortanix-sgx-abi" , "MPL-2.0" ) , // libstd but only for `sgx` target. FIXME: this dependency violates the documentation comment above.
94
94
( "instant" , "BSD-3-Clause" ) , // rustc_driver/tracing-subscriber/parking_lot
95
95
( "mdbook" , "MPL-2.0" ) , // mdbook
96
96
( "option-ext" , "MPL-2.0" ) , // cargo-miri (via `directories`)
@@ -108,6 +108,17 @@ const EXCEPTIONS: ExceptionList = &[
108
108
// tidy-alphabetical-end
109
109
] ;
110
110
111
+ /// These are exceptions to Rust's permissive licensing policy, and
112
+ /// should be considered bugs. Exceptions are only allowed in Rust
113
+ /// tooling. It is _crucial_ that no exception crates be dependencies
114
+ /// of the Rust runtime (std/test).
115
+ #[ rustfmt:: skip]
116
+ const EXCEPTIONS_STDLIB : ExceptionList = & [
117
+ // tidy-alphabetical-start
118
+ ( "fortanix-sgx-abi" , "MPL-2.0" ) , // libstd but only for `sgx` target. FIXME: this dependency violates the documentation comment above.
119
+ // tidy-alphabetical-end
120
+ ] ;
121
+
111
122
// FIXME uncomment once rust-lang/stdarch#1462 lands
112
123
/*
113
124
const EXCEPTIONS_STDARCH: ExceptionList = &[
@@ -228,10 +239,6 @@ const EXCEPTIONS_NON_STANDARD_LICENSE_DEPS: &[&str] = &[
228
239
"ring" ,
229
240
] ;
230
241
231
- /// These are the root crates that are part of the runtime. The licenses for
232
- /// these and all their dependencies *must not* be in the exception list.
233
- const RUNTIME_CRATES : & [ & str ] = & [ "std" , "core" , "alloc" , "test" , "panic_abort" , "panic_unwind" ] ;
234
-
235
242
const PERMITTED_DEPS_LOCATION : & str = concat ! ( file!( ) , ":" , line!( ) ) ;
236
243
237
244
/// Crates rustc is allowed to depend on. Avoid adding to the list if possible.
@@ -240,7 +247,6 @@ const PERMITTED_DEPS_LOCATION: &str = concat!(file!(), ":", line!());
240
247
/// rustc. Please check with the compiler team before adding an entry.
241
248
const PERMITTED_RUSTC_DEPENDENCIES : & [ & str ] = & [
242
249
// tidy-alphabetical-start
243
- "addr2line" ,
244
250
"adler" ,
245
251
"ahash" ,
246
252
"aho-corasick" ,
@@ -256,7 +262,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
256
262
"cc" ,
257
263
"cfg-if" ,
258
264
"cfg_aliases" ,
259
- "compiler_builtins" ,
260
265
"cpufeatures" ,
261
266
"crc32fast" ,
262
267
"crossbeam-channel" ,
@@ -276,7 +281,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
276
281
"digest" ,
277
282
"displaydoc" ,
278
283
"dissimilar" ,
279
- "dlmalloc" ,
280
284
"either" ,
281
285
"elsa" ,
282
286
"ena" ,
@@ -291,7 +295,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
291
295
"fluent-langneg" ,
292
296
"fluent-syntax" ,
293
297
"fnv" ,
294
- "fortanix-sgx-abi" ,
295
298
"generic-array" ,
296
299
"getopts" ,
297
300
"getrandom" ,
@@ -354,12 +357,9 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
354
357
"pulldown-cmark-escape" ,
355
358
"punycode" ,
356
359
"quote" ,
357
- "r-efi" ,
358
- "r-efi-alloc" ,
359
360
"rand" ,
360
361
"rand_chacha" ,
361
362
"rand_core" ,
362
- "rand_xorshift" ,
363
363
"rand_xoshiro" ,
364
364
"redox_syscall" ,
365
365
"regex" ,
@@ -429,7 +429,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
429
429
"unicode-security" ,
430
430
"unicode-width" ,
431
431
"unicode-xid" ,
432
- "unwinding" ,
433
432
"valuable" ,
434
433
"version_check" ,
435
434
"wasi" ,
@@ -463,6 +462,46 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
463
462
// tidy-alphabetical-end
464
463
] ;
465
464
465
+ const PERMITTED_STDLIB_DEPENDENCIES : & [ & str ] = & [
466
+ // tidy-alphabetical-start
467
+ "addr2line" ,
468
+ "adler" ,
469
+ "allocator-api2" ,
470
+ "cc" ,
471
+ "cfg-if" ,
472
+ "compiler_builtins" ,
473
+ "dlmalloc" ,
474
+ "fortanix-sgx-abi" ,
475
+ "getopts" ,
476
+ "gimli" ,
477
+ "hashbrown" ,
478
+ "hermit-abi" ,
479
+ "libc" ,
480
+ "memchr" ,
481
+ "miniz_oxide" ,
482
+ "object" ,
483
+ "r-efi" ,
484
+ "r-efi-alloc" ,
485
+ "rand" ,
486
+ "rand_core" ,
487
+ "rand_xorshift" ,
488
+ "rustc-demangle" ,
489
+ "unicode-width" ,
490
+ "unwinding" ,
491
+ "wasi" ,
492
+ "windows-sys" ,
493
+ "windows-targets" ,
494
+ "windows_aarch64_gnullvm" ,
495
+ "windows_aarch64_msvc" ,
496
+ "windows_i686_gnu" ,
497
+ "windows_i686_gnullvm" ,
498
+ "windows_i686_msvc" ,
499
+ "windows_x86_64_gnu" ,
500
+ "windows_x86_64_gnullvm" ,
501
+ "windows_x86_64_msvc" ,
502
+ // tidy-alphabetical-end
503
+ ] ;
504
+
466
505
const PERMITTED_CRANELIFT_DEPENDENCIES : & [ & str ] = & [
467
506
// tidy-alphabetical-start
468
507
"ahash" ,
@@ -556,9 +595,8 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
556
595
check_permitted_dependencies ( & metadata, workspace, permitted_deps, crates, bad) ;
557
596
}
558
597
559
- if workspace == "." {
560
- let runtime_ids = compute_runtime_crates ( & metadata) ;
561
- check_runtime_license_exceptions ( & metadata, runtime_ids, bad) ;
598
+ if workspace == "library" {
599
+ check_runtime_license_exceptions ( & metadata, bad) ;
562
600
checked_runtime_licenses = true ;
563
601
}
564
602
}
@@ -583,16 +621,8 @@ pub fn has_missing_submodule(root: &Path, submodules: &[&str]) -> bool {
583
621
///
584
622
/// Unlike for tools we don't allow exceptions to the `LICENSES` list for the runtime with the sole
585
623
/// exception of `fortanix-sgx-abi` which is only used on x86_64-fortanix-unknown-sgx.
586
- fn check_runtime_license_exceptions (
587
- metadata : & Metadata ,
588
- runtime_ids : HashSet < & PackageId > ,
589
- bad : & mut bool ,
590
- ) {
624
+ fn check_runtime_license_exceptions ( metadata : & Metadata , bad : & mut bool ) {
591
625
for pkg in & metadata. packages {
592
- if !runtime_ids. contains ( & pkg. id ) {
593
- // Only checking dependencies of runtime libraries here.
594
- continue ;
595
- }
596
626
if pkg. source . is_none ( ) {
597
627
// No need to check local packages.
598
628
continue ;
@@ -613,20 +643,6 @@ fn check_runtime_license_exceptions(
613
643
continue ;
614
644
}
615
645
616
- // This exception is due to the fact that the feature set of the
617
- // `object` crate is different between rustc and libstd. In the
618
- // standard library only a conservative set of features are enabled
619
- // which notably does not include the `wasm` feature which pulls in
620
- // this dependency. In the compiler, however, the `wasm` feature is
621
- // enabled. This exception is intended to be here so long as the
622
- // `EXCEPTIONS` above contains `wasmparser`, but once that goes away
623
- // this can be removed.
624
- if pkg. name == "wasmparser"
625
- && pkg. license . as_deref ( ) == Some ( "Apache-2.0 WITH LLVM-exception" )
626
- {
627
- continue ;
628
- }
629
-
630
646
tidy_error ! ( bad, "invalid license `{}` in `{}`" , license, pkg. id) ;
631
647
}
632
648
}
@@ -758,16 +774,6 @@ fn pkg_from_id<'a>(metadata: &'a Metadata, id: &PackageId) -> &'a Package {
758
774
metadata. packages . iter ( ) . find ( |p| & p. id == id) . unwrap ( )
759
775
}
760
776
761
- /// Finds all the packages that are in the rust runtime.
762
- fn compute_runtime_crates < ' a > ( metadata : & ' a Metadata ) -> HashSet < & ' a PackageId > {
763
- let mut result = HashSet :: new ( ) ;
764
- for name in RUNTIME_CRATES {
765
- let id = & pkg_from_name ( metadata, name) . id ;
766
- deps_of ( metadata, id, & mut result) ;
767
- }
768
- result
769
- }
770
-
771
777
/// Recursively find all dependencies.
772
778
fn deps_of < ' a > ( metadata : & ' a Metadata , pkg_id : & ' a PackageId , result : & mut HashSet < & ' a PackageId > ) {
773
779
if !result. insert ( pkg_id) {
0 commit comments