@@ -44,12 +44,29 @@ const EXCEPTIONS: &[(&str, &str)] = &[
44
44
( "fortanix-sgx-abi" , "MPL-2.0" ) , // libstd but only for `sgx` target
45
45
] ;
46
46
47
+ const EXCEPTIONS_CRANELIFT : & [ ( & str , & str ) ] = & [
48
+ ( "cranelift-bforest" , "Apache-2.0 WITH LLVM-exception" ) ,
49
+ ( "cranelift-codegen" , "Apache-2.0 WITH LLVM-exception" ) ,
50
+ ( "cranelift-codegen-meta" , "Apache-2.0 WITH LLVM-exception" ) ,
51
+ ( "cranelift-codegen-shared" , "Apache-2.0 WITH LLVM-exception" ) ,
52
+ ( "cranelift-entity" , "Apache-2.0 WITH LLVM-exception" ) ,
53
+ ( "cranelift-frontend" , "Apache-2.0 WITH LLVM-exception" ) ,
54
+ ( "cranelift-jit" , "Apache-2.0 WITH LLVM-exception" ) ,
55
+ ( "cranelift-module" , "Apache-2.0 WITH LLVM-exception" ) ,
56
+ ( "cranelift-native" , "Apache-2.0 WITH LLVM-exception" ) ,
57
+ ( "cranelift-object" , "Apache-2.0 WITH LLVM-exception" ) ,
58
+ ( "libloading" , "ISC" ) ,
59
+ ( "mach" , "BSD-2-Clause" ) ,
60
+ ( "regalloc" , "Apache-2.0 WITH LLVM-exception" ) ,
61
+ ( "target-lexicon" , "Apache-2.0 WITH LLVM-exception" ) ,
62
+ ] ;
63
+
47
64
/// These are the root crates that are part of the runtime. The licenses for
48
65
/// these and all their dependencies *must not* be in the exception list.
49
66
const RUNTIME_CRATES : & [ & str ] = & [ "std" , "core" , "alloc" , "test" , "panic_abort" , "panic_unwind" ] ;
50
67
51
68
/// Crates whose dependencies must be explicitly permitted.
52
- const RESTRICTED_DEPENDENCY_CRATES : & [ & str ] = & [ "rustc_middle " , "rustc_codegen_llvm" ] ;
69
+ const RESTRICTED_DEPENDENCY_CRATES : & [ & str ] = & [ "rustc_driver " , "rustc_codegen_llvm" ] ;
53
70
54
71
/// Crates rustc is allowed to depend on. Avoid adding to the list if possible.
55
72
///
@@ -72,7 +89,10 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
72
89
"cc" ,
73
90
"cfg-if" ,
74
91
"chalk-derive" ,
92
+ "chalk-engine" ,
75
93
"chalk-ir" ,
94
+ "chalk-solve" ,
95
+ "chrono" ,
76
96
"cmake" ,
77
97
"compiler_builtins" ,
78
98
"cpuid-bool" ,
@@ -92,6 +112,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
92
112
"expect-test" ,
93
113
"fake-simd" ,
94
114
"filetime" ,
115
+ "fixedbitset" ,
95
116
"flate2" ,
96
117
"fortanix-sgx-abi" ,
97
118
"fuchsia-zircon" ,
@@ -107,13 +128,15 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
107
128
"indexmap" ,
108
129
"instant" ,
109
130
"itertools" ,
131
+ "itoa" ,
110
132
"jobserver" ,
111
133
"kernel32-sys" ,
112
134
"lazy_static" ,
113
135
"libc" ,
114
136
"libz-sys" ,
115
137
"lock_api" ,
116
138
"log" ,
139
+ "matchers" ,
117
140
"maybe-uninit" ,
118
141
"md-5" ,
119
142
"measureme" ,
@@ -123,13 +146,16 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
123
146
"memoffset" ,
124
147
"miniz_oxide" ,
125
148
"num_cpus" ,
149
+ "num-integer" ,
150
+ "num-traits" ,
126
151
"object" ,
127
152
"once_cell" ,
128
153
"opaque-debug" ,
129
154
"parking_lot" ,
130
155
"parking_lot_core" ,
131
156
"pathdiff" ,
132
157
"perf-event-open-sys" ,
158
+ "petgraph" ,
133
159
"pin-project-lite" ,
134
160
"pkg-config" ,
135
161
"polonius-engine" ,
@@ -147,22 +173,28 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
147
173
"rand_xorshift" ,
148
174
"redox_syscall" ,
149
175
"regex" ,
176
+ "regex-automata" ,
150
177
"regex-syntax" ,
151
178
"remove_dir_all" ,
179
+ "rls-data" ,
180
+ "rls-span" ,
152
181
"rustc-demangle" ,
153
182
"rustc-hash" ,
154
183
"rustc-rayon" ,
155
184
"rustc-rayon-core" ,
156
185
"rustc_version" ,
186
+ "ryu" ,
157
187
"scoped-tls" ,
158
188
"scopeguard" ,
159
189
"semver" ,
160
190
"semver-parser" ,
161
191
"serde" ,
162
192
"serde_derive" ,
193
+ "serde_json" ,
163
194
"sha-1" ,
164
195
"sha2" ,
165
196
"smallvec" ,
197
+ "sharded-slab" ,
166
198
"snap" ,
167
199
"stable_deref_trait" ,
168
200
"stacker" ,
@@ -172,9 +204,15 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
172
204
"termcolor" ,
173
205
"termize" ,
174
206
"thread_local" ,
207
+ "time" ,
208
+ "tinyvec" ,
175
209
"tracing" ,
176
210
"tracing-attributes" ,
177
211
"tracing-core" ,
212
+ "tracing-log" ,
213
+ "tracing-serde" ,
214
+ "tracing-subscriber" ,
215
+ "tracing-tree" ,
178
216
"typenum" ,
179
217
"unicode-normalization" ,
180
218
"unicode-script" ,
@@ -193,6 +231,59 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
193
231
"yansi-term" ,
194
232
] ;
195
233
234
+ const PERMITTED_CRANELIFT_DEPENDENCIES : & [ & str ] = & [
235
+ "anyhow" ,
236
+ "ar" ,
237
+ "autocfg" ,
238
+ "bitflags" ,
239
+ "byteorder" ,
240
+ "cfg-if" ,
241
+ "cranelift-bforest" ,
242
+ "cranelift-codegen" ,
243
+ "cranelift-codegen-meta" ,
244
+ "cranelift-codegen-shared" ,
245
+ "cranelift-entity" ,
246
+ "cranelift-frontend" ,
247
+ "cranelift-jit" ,
248
+ "cranelift-module" ,
249
+ "cranelift-native" ,
250
+ "cranelift-object" ,
251
+ "crc32fast" ,
252
+ "errno" ,
253
+ "errno-dragonfly" ,
254
+ "gcc" ,
255
+ "gimli" ,
256
+ "hashbrown" ,
257
+ "indexmap" ,
258
+ "libc" ,
259
+ "libloading" ,
260
+ "log" ,
261
+ "mach" ,
262
+ "object" ,
263
+ "proc-macro2" ,
264
+ "quote" ,
265
+ "regalloc" ,
266
+ "region" ,
267
+ "rustc-hash" ,
268
+ "smallvec" ,
269
+ "syn" ,
270
+ "target-lexicon" ,
271
+ "thiserror" ,
272
+ "thiserror-impl" ,
273
+ "unicode-xid" ,
274
+ "winapi" ,
275
+ "winapi-i686-pc-windows-gnu" ,
276
+ "winapi-x86_64-pc-windows-gnu" ,
277
+ ] ;
278
+
279
+ const FORBIDDEN_TO_HAVE_DUPLICATES : & [ & str ] = & [
280
+ // These two crates take quite a long time to build, so don't allow two versions of them
281
+ // to accidentally sneak into our dependency graph, in order to ensure we keep our CI times
282
+ // under control.
283
+ "cargo" ,
284
+ "rustc-ap-rustc_ast" ,
285
+ ] ;
286
+
196
287
/// Dependency checks.
197
288
///
198
289
/// `root` is path to the directory with the root `Cargo.toml` (for the workspace). `cargo` is path
@@ -203,17 +294,39 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
203
294
. manifest_path ( root. join ( "Cargo.toml" ) )
204
295
. features ( cargo_metadata:: CargoOpt :: AllFeatures ) ;
205
296
let metadata = t ! ( cmd. exec( ) ) ;
206
- check_exceptions ( & metadata, bad) ;
207
- check_dependencies ( & metadata, bad) ;
208
- check_crate_duplicate ( & metadata, bad) ;
297
+ let runtime_ids = compute_runtime_crates ( & metadata) ;
298
+ check_exceptions ( & metadata, EXCEPTIONS , runtime_ids, bad) ;
299
+ check_dependencies ( & metadata, PERMITTED_DEPENDENCIES , RESTRICTED_DEPENDENCY_CRATES , bad) ;
300
+ check_crate_duplicate ( & metadata, FORBIDDEN_TO_HAVE_DUPLICATES , bad) ;
301
+
302
+ // Check rustc_codegen_cranelift independently as it has it's own workspace.
303
+ let mut cmd = cargo_metadata:: MetadataCommand :: new ( ) ;
304
+ cmd. cargo_path ( cargo)
305
+ . manifest_path ( root. join ( "compiler/rustc_codegen_cranelift/Cargo.toml" ) )
306
+ . features ( cargo_metadata:: CargoOpt :: AllFeatures ) ;
307
+ let metadata = t ! ( cmd. exec( ) ) ;
308
+ let runtime_ids = HashSet :: new ( ) ;
309
+ check_exceptions ( & metadata, EXCEPTIONS_CRANELIFT , runtime_ids, bad) ;
310
+ check_dependencies (
311
+ & metadata,
312
+ PERMITTED_CRANELIFT_DEPENDENCIES ,
313
+ & [ "rustc_codegen_cranelift" ] ,
314
+ bad,
315
+ ) ;
316
+ check_crate_duplicate ( & metadata, & [ ] , bad) ;
209
317
}
210
318
211
319
/// Check that all licenses are in the valid list in `LICENSES`.
212
320
///
213
321
/// Packages listed in `EXCEPTIONS` are allowed for tools.
214
- fn check_exceptions ( metadata : & Metadata , bad : & mut bool ) {
322
+ fn check_exceptions (
323
+ metadata : & Metadata ,
324
+ exceptions : & [ ( & str , & str ) ] ,
325
+ runtime_ids : HashSet < & PackageId > ,
326
+ bad : & mut bool ,
327
+ ) {
215
328
// Validate the EXCEPTIONS list hasn't changed.
216
- for ( name, license) in EXCEPTIONS {
329
+ for ( name, license) in exceptions {
217
330
// Check that the package actually exists.
218
331
if !metadata. packages . iter ( ) . any ( |p| p. name == * name) {
219
332
tidy_error ! (
@@ -225,13 +338,6 @@ fn check_exceptions(metadata: &Metadata, bad: &mut bool) {
225
338
}
226
339
// Check that the license hasn't changed.
227
340
for pkg in metadata. packages . iter ( ) . filter ( |p| p. name == * name) {
228
- if pkg. name == "fuchsia-cprng" {
229
- // This package doesn't declare a license expression. Manual
230
- // inspection of the license file is necessary, which appears
231
- // to be BSD-3-Clause.
232
- assert ! ( pkg. license. is_none( ) ) ;
233
- continue ;
234
- }
235
341
match & pkg. license {
236
342
None => {
237
343
tidy_error ! (
@@ -242,14 +348,6 @@ fn check_exceptions(metadata: &Metadata, bad: &mut bool) {
242
348
}
243
349
Some ( pkg_license) => {
244
350
if pkg_license. as_str ( ) != * license {
245
- if * name == "crossbeam-queue"
246
- && * license == "MIT/Apache-2.0 AND BSD-2-Clause"
247
- {
248
- // We have two versions of crossbeam-queue and both
249
- // are fine.
250
- continue ;
251
- }
252
-
253
351
println ! ( "dependency exception `{}` license has changed" , name) ;
254
352
println ! ( " previously `{}` now `{}`" , license, pkg_license) ;
255
353
println ! ( " update EXCEPTIONS for the new license" ) ;
@@ -260,8 +358,7 @@ fn check_exceptions(metadata: &Metadata, bad: &mut bool) {
260
358
}
261
359
}
262
360
263
- let exception_names: Vec < _ > = EXCEPTIONS . iter ( ) . map ( |( name, _license) | * name) . collect ( ) ;
264
- let runtime_ids = compute_runtime_crates ( metadata) ;
361
+ let exception_names: Vec < _ > = exceptions. iter ( ) . map ( |( name, _license) | * name) . collect ( ) ;
265
362
266
363
// Check if any package does not have a valid license.
267
364
for pkg in & metadata. packages {
@@ -296,9 +393,14 @@ fn check_exceptions(metadata: &Metadata, bad: &mut bool) {
296
393
/// `true` if a check failed.
297
394
///
298
395
/// Specifically, this checks that the dependencies are on the `PERMITTED_DEPENDENCIES`.
299
- fn check_dependencies ( metadata : & Metadata , bad : & mut bool ) {
396
+ fn check_dependencies (
397
+ metadata : & Metadata ,
398
+ permitted_dependencies : & [ & ' static str ] ,
399
+ restricted_dependency_crates : & [ & ' static str ] ,
400
+ bad : & mut bool ,
401
+ ) {
300
402
// Check that the PERMITTED_DEPENDENCIES does not have unused entries.
301
- for name in PERMITTED_DEPENDENCIES {
403
+ for name in permitted_dependencies {
302
404
if !metadata. packages . iter ( ) . any ( |p| p. name == * name) {
303
405
tidy_error ! (
304
406
bad,
@@ -309,12 +411,12 @@ fn check_dependencies(metadata: &Metadata, bad: &mut bool) {
309
411
}
310
412
}
311
413
// Get the list in a convenient form.
312
- let permitted_dependencies: HashSet < _ > = PERMITTED_DEPENDENCIES . iter ( ) . cloned ( ) . collect ( ) ;
414
+ let permitted_dependencies: HashSet < _ > = permitted_dependencies . iter ( ) . cloned ( ) . collect ( ) ;
313
415
314
416
// Check dependencies.
315
417
let mut visited = BTreeSet :: new ( ) ;
316
418
let mut unapproved = BTreeSet :: new ( ) ;
317
- for & krate in RESTRICTED_DEPENDENCY_CRATES . iter ( ) {
419
+ for & krate in restricted_dependency_crates . iter ( ) {
318
420
let pkg = pkg_from_name ( metadata, krate) ;
319
421
let mut bad =
320
422
check_crate_dependencies ( & permitted_dependencies, metadata, & mut visited, pkg) ;
@@ -367,16 +469,12 @@ fn check_crate_dependencies<'a>(
367
469
}
368
470
369
471
/// Prevents multiple versions of some expensive crates.
370
- fn check_crate_duplicate ( metadata : & Metadata , bad : & mut bool ) {
371
- const FORBIDDEN_TO_HAVE_DUPLICATES : & [ & str ] = & [
372
- // These two crates take quite a long time to build, so don't allow two versions of them
373
- // to accidentally sneak into our dependency graph, in order to ensure we keep our CI times
374
- // under control.
375
- "cargo" ,
376
- "rustc-ap-rustc_ast" ,
377
- ] ;
378
-
379
- for & name in FORBIDDEN_TO_HAVE_DUPLICATES {
472
+ fn check_crate_duplicate (
473
+ metadata : & Metadata ,
474
+ forbidden_to_have_duplicates : & [ & str ] ,
475
+ bad : & mut bool ,
476
+ ) {
477
+ for & name in forbidden_to_have_duplicates {
380
478
let matches: Vec < _ > = metadata. packages . iter ( ) . filter ( |pkg| pkg. name == name) . collect ( ) ;
381
479
match matches. len ( ) {
382
480
0 => {
@@ -456,16 +554,7 @@ fn normal_deps_of_r<'a>(
456
554
. iter ( )
457
555
. find ( |n| & n. id == pkg_id)
458
556
. unwrap_or_else ( || panic ! ( "could not find `{}` in resolve" , pkg_id) ) ;
459
- // Don't care about dev-dependencies.
460
- // Build dependencies *shouldn't* matter unless they do some kind of
461
- // codegen. For now we'll assume they don't.
462
- let deps = node. deps . iter ( ) . filter ( |node_dep| {
463
- node_dep
464
- . dep_kinds
465
- . iter ( )
466
- . any ( |kind_info| kind_info. kind == cargo_metadata:: DependencyKind :: Normal )
467
- } ) ;
468
- for dep in deps {
557
+ for dep in & node. deps {
469
558
normal_deps_of_r ( resolve, & dep. pkg , result) ;
470
559
}
471
560
}
0 commit comments