@@ -63,6 +63,10 @@ const EXCEPTIONS_CRANELIFT: &[(&str, &str)] = &[
63
63
( "target-lexicon" , "Apache-2.0 WITH LLVM-exception" ) ,
64
64
] ;
65
65
66
+ const EXCEPTIONS_BOOTSTRAP : & [ ( & str , & str ) ] = & [
67
+ ( "ryu" , "Apache-2.0 OR BSL-1.0" ) , // through serde
68
+ ] ;
69
+
66
70
/// These are the root crates that are part of the runtime. The licenses for
67
71
/// these and all their dependencies *must not* be in the exception list.
68
72
const RUNTIME_CRATES : & [ & str ] = & [ "std" , "core" , "alloc" , "test" , "panic_abort" , "panic_unwind" ] ;
@@ -96,7 +100,6 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
96
100
"chalk-ir" ,
97
101
"chalk-solve" ,
98
102
"chrono" ,
99
- "cmake" ,
100
103
"compiler_builtins" ,
101
104
"cpufeatures" ,
102
105
"crc32fast" ,
@@ -290,6 +293,82 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
290
293
"winapi-x86_64-pc-windows-gnu" ,
291
294
] ;
292
295
296
+ const PERMITTED_BOOTSTRAP_DEPENDENCIES : & [ & str ] = & [
297
+ "aho-corasick" ,
298
+ "autocfg" ,
299
+ "ansi_term" ,
300
+ "block-buffer" ,
301
+ "bitflags" ,
302
+ "bstr" ,
303
+ "core-foundation-sys" ,
304
+ "cc" ,
305
+ "cfg-if" ,
306
+ "crossbeam-utils" ,
307
+ "cmake" ,
308
+ "cpufeatures" ,
309
+ "crossbeam-channel" ,
310
+ "crossbeam-deque" ,
311
+ "crossbeam-epoch" ,
312
+ "crypto-common" ,
313
+ "ctor" ,
314
+ "diff" ,
315
+ "digest" ,
316
+ "either" ,
317
+ "filetime" ,
318
+ "fnv" ,
319
+ "getopts" ,
320
+ "generic-array" ,
321
+ "globset" ,
322
+ "hermit-abi" ,
323
+ "hex" ,
324
+ "ignore" ,
325
+ "itoa" ,
326
+ "lazy_static" ,
327
+ "libc" ,
328
+ "log" ,
329
+ "lzma-sys" ,
330
+ "memchr" ,
331
+ "memoffset" ,
332
+ "ntapi" ,
333
+ "num_cpus" ,
334
+ "once_cell" ,
335
+ "opener" ,
336
+ "output_vt100" ,
337
+ "pkg-config" ,
338
+ "pretty_assertions" ,
339
+ "proc-macro2" ,
340
+ "quote" ,
341
+ "rayon" ,
342
+ "rayon-core" ,
343
+ "redox_syscall" ,
344
+ "regex" ,
345
+ "regex-automata" ,
346
+ "regex-syntax" ,
347
+ "ryu" ,
348
+ "same-file" ,
349
+ "scopeguard" ,
350
+ "serde" ,
351
+ "serde_derive" ,
352
+ "serde_json" ,
353
+ "sha2" ,
354
+ "syn" ,
355
+ "sysinfo" ,
356
+ "tar" ,
357
+ "thread_local" ,
358
+ "toml" ,
359
+ "typenum" ,
360
+ "unicode-ident" ,
361
+ "unicode-width" ,
362
+ "version_check" ,
363
+ "walkdir" ,
364
+ "winapi" ,
365
+ "winapi-i686-pc-windows-gnu" ,
366
+ "winapi-util" ,
367
+ "winapi-x86_64-pc-windows-gnu" ,
368
+ "xattr" ,
369
+ "xz2" ,
370
+ ] ;
371
+
293
372
const FORBIDDEN_TO_HAVE_DUPLICATES : & [ & str ] = & [
294
373
// These two crates take quite a long time to build, so don't allow two versions of them
295
374
// to accidentally sneak into our dependency graph, in order to ensure we keep our CI times
@@ -309,7 +388,13 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
309
388
let metadata = t ! ( cmd. exec( ) ) ;
310
389
let runtime_ids = compute_runtime_crates ( & metadata) ;
311
390
check_exceptions ( & metadata, EXCEPTIONS , runtime_ids, bad) ;
312
- check_dependencies ( & metadata, PERMITTED_DEPENDENCIES , RESTRICTED_DEPENDENCY_CRATES , bad) ;
391
+ check_dependencies (
392
+ & metadata,
393
+ "main workspace" ,
394
+ PERMITTED_DEPENDENCIES ,
395
+ RESTRICTED_DEPENDENCY_CRATES ,
396
+ bad,
397
+ ) ;
313
398
check_crate_duplicate ( & metadata, FORBIDDEN_TO_HAVE_DUPLICATES , bad) ;
314
399
check_rustfix ( & metadata, bad) ;
315
400
@@ -323,11 +408,27 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
323
408
check_exceptions ( & metadata, EXCEPTIONS_CRANELIFT , runtime_ids, bad) ;
324
409
check_dependencies (
325
410
& metadata,
411
+ "cranelift" ,
326
412
PERMITTED_CRANELIFT_DEPENDENCIES ,
327
413
& [ "rustc_codegen_cranelift" ] ,
328
414
bad,
329
415
) ;
330
416
check_crate_duplicate ( & metadata, & [ ] , bad) ;
417
+
418
+ let mut cmd = cargo_metadata:: MetadataCommand :: new ( ) ;
419
+ cmd. cargo_path ( cargo)
420
+ . manifest_path ( root. join ( "src/bootstrap/Cargo.toml" ) )
421
+ . features ( cargo_metadata:: CargoOpt :: AllFeatures ) ;
422
+ let metadata = t ! ( cmd. exec( ) ) ;
423
+ let runtime_ids = HashSet :: new ( ) ;
424
+ check_exceptions ( & metadata, EXCEPTIONS_BOOTSTRAP , runtime_ids, bad) ;
425
+ check_dependencies (
426
+ & metadata,
427
+ "bootstrap" ,
428
+ PERMITTED_BOOTSTRAP_DEPENDENCIES ,
429
+ & [ "bootstrap" ] ,
430
+ bad,
431
+ ) ;
331
432
}
332
433
333
434
/// Check that all licenses are in the valid list in `LICENSES`.
@@ -409,6 +510,7 @@ fn check_exceptions(
409
510
/// Specifically, this checks that the dependencies are on the `PERMITTED_DEPENDENCIES`.
410
511
fn check_dependencies (
411
512
metadata : & Metadata ,
513
+ descr : & str ,
412
514
permitted_dependencies : & [ & ' static str ] ,
413
515
restricted_dependency_crates : & [ & ' static str ] ,
414
516
bad : & mut bool ,
@@ -438,7 +540,7 @@ fn check_dependencies(
438
540
}
439
541
440
542
if !unapproved. is_empty ( ) {
441
- tidy_error ! ( bad, "Dependencies not explicitly permitted:" ) ;
543
+ tidy_error ! ( bad, "Dependencies for {} not explicitly permitted:" , descr ) ;
442
544
for dep in unapproved {
443
545
println ! ( "* {dep}" ) ;
444
546
}
0 commit comments