Skip to content

Commit d2f8c30

Browse files
authored
Rollup merge of #74127 - tamird:allowlist, r=oli-obk
Avoid "whitelist" Other terms are more inclusive and precise.
2 parents 8355024 + 62cf767 commit d2f8c30

File tree

55 files changed

+296
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+296
-278
lines changed

src/bootstrap/doc.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,6 @@ impl Step for Std {
439439
builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc");
440440
compile::std_cargo(builder, target, compiler.stage, &mut cargo);
441441

442-
// Keep a whitelist so we do not build internal stdlib crates, these will be
443-
// build by the rustc step later if enabled.
444442
cargo.arg("-p").arg(package);
445443
// Create all crate output directories first to make sure rustdoc uses
446444
// relative links.
@@ -460,6 +458,10 @@ impl Step for Std {
460458

461459
builder.run(&mut cargo.into());
462460
};
461+
// Only build the following crates. While we could just iterate over the
462+
// folder structure, that would also build internal crates that we do
463+
// not want to show in documentation. These crates will later be visited
464+
// by the rustc step, so internal documentation will show them.
463465
let krates = ["alloc", "core", "std", "proc_macro", "test"];
464466
for krate in &krates {
465467
run_cargo_rustdoc_for(krate);

src/etc/test-float-parse/runtests.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ def main():
195195
global MAILBOX
196196
tests = [os.path.splitext(f)[0] for f in glob('*.rs')
197197
if not f.startswith('_')]
198-
whitelist = sys.argv[1:]
199-
if whitelist:
200-
tests = [test for test in tests if test in whitelist]
198+
listed = sys.argv[1:]
199+
if listed:
200+
tests = [test for test in tests if test in listed]
201201
if not tests:
202202
print("Error: No tests to run")
203203
sys.exit(1)
@@ -210,8 +210,6 @@ def main():
210210
mailman.daemon = True
211211
mailman.start()
212212
for test in tests:
213-
if whitelist and test not in whitelist:
214-
continue
215213
run(test)
216214
MAILBOX.put(None)
217215
mailman.join()

src/libcore/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<'a, 'f: 'a> DerefMut for VaList<'a, 'f> {
280280
// within a private module. Once RFC 2145 has been implemented look into
281281
// improving this.
282282
mod sealed_trait {
283-
/// Trait which whitelists the allowed types to be used with [VaList::arg]
283+
/// Trait which permits the allowed types to be used with [VaList::arg].
284284
///
285285
/// [VaList::arg]: ../struct.VaList.html#method.arg
286286
#[unstable(

src/librustc_codegen_llvm/attributes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
263263
// Windows we end up still needing the `uwtable` attribute even if the `-C
264264
// panic=abort` flag is passed.
265265
//
266-
// You can also find more info on why Windows is whitelisted here in:
266+
// You can also find more info on why Windows always requires uwtables here:
267267
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
268268
if cx.sess().must_emit_unwind_tables() {
269269
attributes::emit_uwtable(llfn, true);
@@ -343,14 +343,14 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
343343
}
344344

345345
pub fn provide(providers: &mut Providers) {
346-
providers.target_features_whitelist = |tcx, cnum| {
346+
providers.supported_target_features = |tcx, cnum| {
347347
assert_eq!(cnum, LOCAL_CRATE);
348348
if tcx.sess.opts.actually_rustdoc {
349349
// rustdoc needs to be able to document functions that use all the features, so
350-
// whitelist them all
350+
// provide them all.
351351
llvm_util::all_known_features().map(|(a, b)| (a.to_string(), b)).collect()
352352
} else {
353-
llvm_util::target_feature_whitelist(tcx.sess)
353+
llvm_util::supported_target_features(tcx.sess)
354354
.iter()
355355
.map(|&(a, b)| (a.to_string(), b))
356356
.collect()

src/librustc_codegen_llvm/back/lto.rs

+37-20
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ fn prepare_lto(
6262
}
6363
};
6464
let exported_symbols = cgcx.exported_symbols.as_ref().expect("needs exported symbols for LTO");
65-
let mut symbol_white_list = {
66-
let _timer = cgcx.prof.generic_activity("LLVM_lto_generate_symbol_white_list");
65+
let mut symbols_below_threshold = {
66+
let _timer = cgcx.prof.generic_activity("LLVM_lto_generate_symbols_below_threshold");
6767
exported_symbols[&LOCAL_CRATE].iter().filter_map(symbol_filter).collect::<Vec<CString>>()
6868
};
69-
info!("{} symbols to preserve in this crate", symbol_white_list.len());
69+
info!("{} symbols to preserve in this crate", symbols_below_threshold.len());
7070

7171
// If we're performing LTO for the entire crate graph, then for each of our
7272
// upstream dependencies, find the corresponding rlib and load the bitcode
@@ -102,8 +102,10 @@ fn prepare_lto(
102102
let exported_symbols =
103103
cgcx.exported_symbols.as_ref().expect("needs exported symbols for LTO");
104104
{
105-
let _timer = cgcx.prof.generic_activity("LLVM_lto_generate_symbol_white_list");
106-
symbol_white_list.extend(exported_symbols[&cnum].iter().filter_map(symbol_filter));
105+
let _timer =
106+
cgcx.prof.generic_activity("LLVM_lto_generate_symbols_below_threshold");
107+
symbols_below_threshold
108+
.extend(exported_symbols[&cnum].iter().filter_map(symbol_filter));
107109
}
108110

109111
let archive = ArchiveRO::open(&path).expect("wanted an rlib");
@@ -124,7 +126,7 @@ fn prepare_lto(
124126
}
125127
}
126128

127-
Ok((symbol_white_list, upstream_modules))
129+
Ok((symbols_below_threshold, upstream_modules))
128130
}
129131

130132
fn get_bitcode_slice_from_object_data(obj: &[u8]) -> Result<&[u8], String> {
@@ -155,9 +157,17 @@ pub(crate) fn run_fat(
155157
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
156158
) -> Result<LtoModuleCodegen<LlvmCodegenBackend>, FatalError> {
157159
let diag_handler = cgcx.create_diag_handler();
158-
let (symbol_white_list, upstream_modules) = prepare_lto(cgcx, &diag_handler)?;
159-
let symbol_white_list = symbol_white_list.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();
160-
fat_lto(cgcx, &diag_handler, modules, cached_modules, upstream_modules, &symbol_white_list)
160+
let (symbols_below_threshold, upstream_modules) = prepare_lto(cgcx, &diag_handler)?;
161+
let symbols_below_threshold =
162+
symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();
163+
fat_lto(
164+
cgcx,
165+
&diag_handler,
166+
modules,
167+
cached_modules,
168+
upstream_modules,
169+
&symbols_below_threshold,
170+
)
161171
}
162172

163173
/// Performs thin LTO by performing necessary global analysis and returning two
@@ -169,15 +179,23 @@ pub(crate) fn run_thin(
169179
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
170180
) -> Result<(Vec<LtoModuleCodegen<LlvmCodegenBackend>>, Vec<WorkProduct>), FatalError> {
171181
let diag_handler = cgcx.create_diag_handler();
172-
let (symbol_white_list, upstream_modules) = prepare_lto(cgcx, &diag_handler)?;
173-
let symbol_white_list = symbol_white_list.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();
182+
let (symbols_below_threshold, upstream_modules) = prepare_lto(cgcx, &diag_handler)?;
183+
let symbols_below_threshold =
184+
symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();
174185
if cgcx.opts.cg.linker_plugin_lto.enabled() {
175186
unreachable!(
176187
"We should never reach this case if the LTO step \
177188
is deferred to the linker"
178189
);
179190
}
180-
thin_lto(cgcx, &diag_handler, modules, upstream_modules, cached_modules, &symbol_white_list)
191+
thin_lto(
192+
cgcx,
193+
&diag_handler,
194+
modules,
195+
upstream_modules,
196+
cached_modules,
197+
&symbols_below_threshold,
198+
)
181199
}
182200

183201
pub(crate) fn prepare_thin(module: ModuleCodegen<ModuleLlvm>) -> (String, ThinBuffer) {
@@ -192,7 +210,7 @@ fn fat_lto(
192210
modules: Vec<FatLTOInput<LlvmCodegenBackend>>,
193211
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
194212
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
195-
symbol_white_list: &[*const libc::c_char],
213+
symbols_below_threshold: &[*const libc::c_char],
196214
) -> Result<LtoModuleCodegen<LlvmCodegenBackend>, FatalError> {
197215
let _timer = cgcx.prof.generic_activity("LLVM_fat_lto_build_monolithic_module");
198216
info!("going for a fat lto");
@@ -306,14 +324,13 @@ fn fat_lto(
306324
drop(linker);
307325
save_temp_bitcode(&cgcx, &module, "lto.input");
308326

309-
// Internalize everything that *isn't* in our whitelist to help strip out
310-
// more modules and such
327+
// Internalize everything below threshold to help strip out more modules and such.
311328
unsafe {
312-
let ptr = symbol_white_list.as_ptr();
329+
let ptr = symbols_below_threshold.as_ptr();
313330
llvm::LLVMRustRunRestrictionPass(
314331
llmod,
315332
ptr as *const *const libc::c_char,
316-
symbol_white_list.len() as libc::size_t,
333+
symbols_below_threshold.len() as libc::size_t,
317334
);
318335
save_temp_bitcode(&cgcx, &module, "lto.after-restriction");
319336
}
@@ -395,7 +412,7 @@ fn thin_lto(
395412
modules: Vec<(String, ThinBuffer)>,
396413
serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
397414
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
398-
symbol_white_list: &[*const libc::c_char],
415+
symbols_below_threshold: &[*const libc::c_char],
399416
) -> Result<(Vec<LtoModuleCodegen<LlvmCodegenBackend>>, Vec<WorkProduct>), FatalError> {
400417
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_global_analysis");
401418
unsafe {
@@ -463,8 +480,8 @@ fn thin_lto(
463480
let data = llvm::LLVMRustCreateThinLTOData(
464481
thin_modules.as_ptr(),
465482
thin_modules.len() as u32,
466-
symbol_white_list.as_ptr(),
467-
symbol_white_list.len() as u32,
483+
symbols_below_threshold.as_ptr(),
484+
symbols_below_threshold.len() as u32,
468485
)
469486
.ok_or_else(|| write::llvm_err(&diag_handler, "failed to prepare thin LTO context"))?;
470487

src/librustc_codegen_llvm/llvm_util.rs

+28-29
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub fn time_trace_profiler_finish(file_name: &str) {
139139
// to LLVM or the feature detection code will walk past the end of the feature
140140
// array, leading to crashes.
141141

142-
const ARM_WHITELIST: &[(&str, Option<Symbol>)] = &[
142+
const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
143143
("aclass", Some(sym::arm_target_feature)),
144144
("mclass", Some(sym::arm_target_feature)),
145145
("rclass", Some(sym::arm_target_feature)),
@@ -162,7 +162,7 @@ const ARM_WHITELIST: &[(&str, Option<Symbol>)] = &[
162162
("thumb-mode", Some(sym::arm_target_feature)),
163163
];
164164

165-
const AARCH64_WHITELIST: &[(&str, Option<Symbol>)] = &[
165+
const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
166166
("fp", Some(sym::aarch64_target_feature)),
167167
("neon", Some(sym::aarch64_target_feature)),
168168
("sve", Some(sym::aarch64_target_feature)),
@@ -180,7 +180,7 @@ const AARCH64_WHITELIST: &[(&str, Option<Symbol>)] = &[
180180
("v8.3a", Some(sym::aarch64_target_feature)),
181181
];
182182

183-
const X86_WHITELIST: &[(&str, Option<Symbol>)] = &[
183+
const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
184184
("adx", Some(sym::adx_target_feature)),
185185
("aes", None),
186186
("avx", None),
@@ -224,12 +224,12 @@ const X86_WHITELIST: &[(&str, Option<Symbol>)] = &[
224224
("xsaves", None),
225225
];
226226

227-
const HEXAGON_WHITELIST: &[(&str, Option<Symbol>)] = &[
227+
const HEXAGON_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
228228
("hvx", Some(sym::hexagon_target_feature)),
229229
("hvx-length128b", Some(sym::hexagon_target_feature)),
230230
];
231231

232-
const POWERPC_WHITELIST: &[(&str, Option<Symbol>)] = &[
232+
const POWERPC_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
233233
("altivec", Some(sym::powerpc_target_feature)),
234234
("power8-altivec", Some(sym::powerpc_target_feature)),
235235
("power9-altivec", Some(sym::powerpc_target_feature)),
@@ -238,10 +238,10 @@ const POWERPC_WHITELIST: &[(&str, Option<Symbol>)] = &[
238238
("vsx", Some(sym::powerpc_target_feature)),
239239
];
240240

241-
const MIPS_WHITELIST: &[(&str, Option<Symbol>)] =
241+
const MIPS_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] =
242242
&[("fp64", Some(sym::mips_target_feature)), ("msa", Some(sym::mips_target_feature))];
243243

244-
const RISCV_WHITELIST: &[(&str, Option<Symbol>)] = &[
244+
const RISCV_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
245245
("m", Some(sym::riscv_target_feature)),
246246
("a", Some(sym::riscv_target_feature)),
247247
("c", Some(sym::riscv_target_feature)),
@@ -250,7 +250,7 @@ const RISCV_WHITELIST: &[(&str, Option<Symbol>)] = &[
250250
("e", Some(sym::riscv_target_feature)),
251251
];
252252

253-
const WASM_WHITELIST: &[(&str, Option<Symbol>)] = &[
253+
const WASM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
254254
("simd128", Some(sym::wasm_target_feature)),
255255
("atomics", Some(sym::wasm_target_feature)),
256256
("nontrapping-fptoint", Some(sym::wasm_target_feature)),
@@ -259,19 +259,18 @@ const WASM_WHITELIST: &[(&str, Option<Symbol>)] = &[
259259
/// When rustdoc is running, provide a list of all known features so that all their respective
260260
/// primitives may be documented.
261261
///
262-
/// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this
263-
/// iterator!
262+
/// IMPORTANT: If you're adding another feature list above, make sure to add it to this iterator!
264263
pub fn all_known_features() -> impl Iterator<Item = (&'static str, Option<Symbol>)> {
265-
ARM_WHITELIST
266-
.iter()
264+
std::iter::empty()
265+
.chain(ARM_ALLOWED_FEATURES.iter())
266+
.chain(AARCH64_ALLOWED_FEATURES.iter())
267+
.chain(X86_ALLOWED_FEATURES.iter())
268+
.chain(HEXAGON_ALLOWED_FEATURES.iter())
269+
.chain(POWERPC_ALLOWED_FEATURES.iter())
270+
.chain(MIPS_ALLOWED_FEATURES.iter())
271+
.chain(RISCV_ALLOWED_FEATURES.iter())
272+
.chain(WASM_ALLOWED_FEATURES.iter())
267273
.cloned()
268-
.chain(AARCH64_WHITELIST.iter().cloned())
269-
.chain(X86_WHITELIST.iter().cloned())
270-
.chain(HEXAGON_WHITELIST.iter().cloned())
271-
.chain(POWERPC_WHITELIST.iter().cloned())
272-
.chain(MIPS_WHITELIST.iter().cloned())
273-
.chain(RISCV_WHITELIST.iter().cloned())
274-
.chain(WASM_WHITELIST.iter().cloned())
275274
}
276275

277276
pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
@@ -289,7 +288,7 @@ pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
289288

290289
pub fn target_features(sess: &Session) -> Vec<Symbol> {
291290
let target_machine = create_informational_target_machine(sess);
292-
target_feature_whitelist(sess)
291+
supported_target_features(sess)
293292
.iter()
294293
.filter_map(|&(feature, gate)| {
295294
if UnstableFeatures::from_environment().is_nightly_build() || gate.is_none() {
@@ -307,16 +306,16 @@ pub fn target_features(sess: &Session) -> Vec<Symbol> {
307306
.collect()
308307
}
309308

310-
pub fn target_feature_whitelist(sess: &Session) -> &'static [(&'static str, Option<Symbol>)] {
309+
pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Option<Symbol>)] {
311310
match &*sess.target.target.arch {
312-
"arm" => ARM_WHITELIST,
313-
"aarch64" => AARCH64_WHITELIST,
314-
"x86" | "x86_64" => X86_WHITELIST,
315-
"hexagon" => HEXAGON_WHITELIST,
316-
"mips" | "mips64" => MIPS_WHITELIST,
317-
"powerpc" | "powerpc64" => POWERPC_WHITELIST,
318-
"riscv32" | "riscv64" => RISCV_WHITELIST,
319-
"wasm32" => WASM_WHITELIST,
311+
"arm" => ARM_ALLOWED_FEATURES,
312+
"aarch64" => AARCH64_ALLOWED_FEATURES,
313+
"x86" | "x86_64" => X86_ALLOWED_FEATURES,
314+
"hexagon" => HEXAGON_ALLOWED_FEATURES,
315+
"mips" | "mips64" => MIPS_ALLOWED_FEATURES,
316+
"powerpc" | "powerpc64" => POWERPC_ALLOWED_FEATURES,
317+
"riscv32" | "riscv64" => RISCV_ALLOWED_FEATURES,
318+
"wasm32" => WASM_ALLOWED_FEATURES,
320319
_ => &[],
321320
}
322321
}

src/librustc_codegen_ssa/back/linker.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,10 @@ impl<'a> Linker for WasmLd<'a> {
11701170
self.cmd.arg("--export").arg(&sym);
11711171
}
11721172

1173-
// LLD will hide these otherwise-internal symbols since our `--export`
1174-
// list above is a whitelist of what to export. Various bits and pieces
1175-
// of tooling use this, so be sure these symbols make their way out of
1176-
// the linker as well.
1173+
// LLD will hide these otherwise-internal symbols since it only exports
1174+
// symbols explicity passed via the `--export` flags above and hides all
1175+
// others. Various bits and pieces of tooling use this, so be sure these
1176+
// symbols make their way out of the linker as well.
11771177
self.cmd.arg("--export=__heap_base");
11781178
self.cmd.arg("--export=__data_end");
11791179
}

src/librustc_codegen_ssa/base.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -842,10 +842,9 @@ impl CrateInfo {
842842
}
843843
}
844844

845-
// No need to look for lang items that are whitelisted and don't
846-
// actually need to exist.
845+
// No need to look for lang items that don't actually need to exist.
847846
let missing =
848-
missing.iter().cloned().filter(|&l| !lang_items::whitelisted(tcx, l)).collect();
847+
missing.iter().cloned().filter(|&l| lang_items::required(tcx, l)).collect();
849848
info.missing_lang_items.insert(cnum, missing);
850849
}
851850

src/librustc_expand/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ pub struct SyntaxExtension {
735735
pub kind: SyntaxExtensionKind,
736736
/// Span of the macro definition.
737737
pub span: Span,
738-
/// Whitelist of unstable features that are treated as stable inside this macro.
738+
/// List of unstable features that are treated as stable inside this macro.
739739
pub allow_internal_unstable: Option<Lrc<[Symbol]>>,
740740
/// Suppresses the `unsafe_code` lint for code produced by this macro.
741741
pub allow_internal_unsafe: bool,

0 commit comments

Comments
 (0)