Skip to content

Commit 8d8ac2c

Browse files
committed
remove support for the #[start] attribute
1 parent a1740a9 commit 8d8ac2c

File tree

176 files changed

+530
-1360
lines changed

Some content is hidden

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

176 files changed

+530
-1360
lines changed

compiler/rustc_ast/src/entry.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ pub enum EntryPointType {
1919
/// fn main() {}
2020
/// ```
2121
RustcMainAttr,
22-
/// This is a function with the `#[start]` attribute.
23-
/// ```ignore (clashes with test entrypoint)
24-
/// #[start]
25-
/// fn main() {}
26-
/// ```
27-
Start,
2822
/// This function is **not** an entrypoint but simply named `main` (not at the root).
2923
/// This is only used for diagnostics.
3024
/// ```
@@ -41,9 +35,7 @@ pub fn entry_point_type(
4135
at_root: bool,
4236
name: Option<Symbol>,
4337
) -> EntryPointType {
44-
if attr::contains_name(attrs, sym::start) {
45-
EntryPointType::Start
46-
} else if attr::contains_name(attrs, sym::rustc_main) {
38+
if attr::contains_name(attrs, sym::rustc_main) {
4739
EntryPointType::RustcMainAttr
4840
} else if let Some(name) = name
4941
&& name == sym::main

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
231231
}
232232
}
233233

234-
ast::ItemKind::Fn(..) => {
235-
if attr::contains_name(&i.attrs, sym::start) {
236-
gate!(
237-
&self,
238-
start,
239-
i.span,
240-
"`#[start]` functions are experimental and their signature may change \
241-
over time"
242-
);
243-
}
244-
}
245-
246234
ast::ItemKind::Struct(..) => {
247235
for attr in attr::filter_by_name(&i.attrs, sym::repr) {
248236
for item in attr.meta_item_list().unwrap_or_else(ThinVec::new) {

compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
205205
ast::mut_visit::walk_item(self, item);
206206
self.depth -= 1;
207207

208-
// Remove any #[rustc_main] or #[start] from the AST so it doesn't
208+
// Remove any #[rustc_main] from the AST so it doesn't
209209
// clash with the one we're going to add, but mark it as
210210
// #[allow(dead_code)] to avoid printing warnings.
211211
match entry_point_type(&item, self.depth == 0) {
212-
EntryPointType::MainNamed | EntryPointType::RustcMainAttr | EntryPointType::Start => {
212+
EntryPointType::MainNamed | EntryPointType::RustcMainAttr => {
213213
let allow_dead_code = attr::mk_attr_nested_word(
214214
&self.sess.psess.attr_id_generator,
215215
ast::AttrStyle::Outer,
@@ -218,8 +218,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
218218
sym::dead_code,
219219
self.def_site,
220220
);
221-
item.attrs
222-
.retain(|attr| !attr.has_name(sym::rustc_main) && !attr.has_name(sym::start));
221+
item.attrs.retain(|attr| !attr.has_name(sym::rustc_main));
223222
item.attrs.push(allow_dead_code);
224223
}
225224
EntryPointType::None | EntryPointType::OtherMain => {}

compiler/rustc_codegen_cranelift/build_system/tests.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
7373
"example/arbitrary_self_types_pointers_and_wrappers.rs",
7474
&[],
7575
),
76-
TestCase::build_lib("build.alloc_system", "example/alloc_system.rs", "lib"),
77-
TestCase::build_bin_and_run("aot.alloc_example", "example/alloc_example.rs", &[]),
7876
TestCase::jit_bin("jit.std_example", "example/std_example.rs", "arg"),
7977
TestCase::build_bin_and_run("aot.std_example", "example/std_example.rs", &["arg"]),
8078
TestCase::build_bin_and_run("aot.dst_field_align", "example/dst-field-align.rs", &[]),
@@ -89,7 +87,6 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
8987
&[],
9088
),
9189
TestCase::build_bin_and_run("aot.float-minmax-pass", "example/float-minmax-pass.rs", &[]),
92-
TestCase::build_bin_and_run("aot.mod_bench", "example/mod_bench.rs", &[]),
9390
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
9491
TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
9592
TestCase::build_bin_and_run("aot.neon", "example/neon.rs", &[]),

compiler/rustc_codegen_cranelift/config.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,12 @@ aot.mini_core_hello_world
3131
testsuite.base_sysroot
3232
aot.arbitrary_self_types_pointers_and_wrappers
3333
aot.issue_91827_extern_types
34-
build.alloc_system
35-
aot.alloc_example
3634
jit.std_example
3735
aot.std_example
3836
aot.dst_field_align
3937
aot.subslice-patterns-const-eval
4038
aot.track-caller-attribute
4139
aot.float-minmax-pass
42-
aot.mod_bench
4340
aot.issue-72793
4441
aot.issue-59326
4542
aot.neon

compiler/rustc_codegen_cranelift/example/alloc_example.rs

Lines changed: 0 additions & 44 deletions
This file was deleted.

compiler/rustc_codegen_cranelift/example/mod_bench.rs

Lines changed: 0 additions & 37 deletions
This file was deleted.

compiler/rustc_codegen_cranelift/src/main_shim.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
22
use rustc_hir::LangItem;
33
use rustc_middle::ty::{AssocKind, GenericArg};
4-
use rustc_session::config::{EntryFnType, sigpipe};
4+
use rustc_session::config::EntryFnType;
55
use rustc_span::DUMMY_SP;
66
use rustc_span::symbol::Ident;
77

@@ -15,10 +15,9 @@ pub(crate) fn maybe_create_entry_wrapper(
1515
is_jit: bool,
1616
is_primary_cgu: bool,
1717
) {
18-
let (main_def_id, (is_main_fn, sigpipe)) = match tcx.entry_fn(()) {
18+
let (main_def_id, sigpipe) = match tcx.entry_fn(()) {
1919
Some((def_id, entry_ty)) => (def_id, match entry_ty {
20-
EntryFnType::Main { sigpipe } => (true, sigpipe),
21-
EntryFnType::Start => (false, sigpipe::DEFAULT),
20+
EntryFnType::Main { sigpipe } => sigpipe,
2221
}),
2322
None => return,
2423
};
@@ -32,14 +31,13 @@ pub(crate) fn maybe_create_entry_wrapper(
3231
return;
3332
}
3433

35-
create_entry_fn(tcx, module, main_def_id, is_jit, is_main_fn, sigpipe);
34+
create_entry_fn(tcx, module, main_def_id, is_jit, sigpipe);
3635

3736
fn create_entry_fn(
3837
tcx: TyCtxt<'_>,
3938
m: &mut dyn Module,
4039
rust_main_def_id: DefId,
4140
ignore_lang_start_wrapper: bool,
42-
is_main_fn: bool,
4341
sigpipe: u8,
4442
) {
4543
let main_ret_ty = tcx.fn_sig(rust_main_def_id).no_bound_vars().unwrap().output();
@@ -95,8 +93,8 @@ pub(crate) fn maybe_create_entry_wrapper(
9593

9694
let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func);
9795

98-
let result = if is_main_fn && ignore_lang_start_wrapper {
99-
// regular main fn, but ignoring #[lang = "start"] as we are running in the jit
96+
let result = if ignore_lang_start_wrapper {
97+
// ignoring #[lang = "start"] as we are running in the jit
10098
// FIXME set program arguments somehow
10199
let call_inst = bcx.ins().call(main_func_ref, &[]);
102100
let call_results = bcx.func.dfg.inst_results(call_inst).to_owned();
@@ -134,7 +132,8 @@ pub(crate) fn maybe_create_entry_wrapper(
134132
types::I64 => bcx.ins().sextend(types::I64, res),
135133
_ => unimplemented!("16bit systems are not yet supported"),
136134
}
137-
} else if is_main_fn {
135+
} else {
136+
// Regular main fn invoked via start lang item.
138137
let start_def_id = tcx.require_lang_item(LangItem::Start, None);
139138
let start_instance = Instance::expect_resolve(
140139
tcx,
@@ -151,10 +150,6 @@ pub(crate) fn maybe_create_entry_wrapper(
151150
let call_inst =
152151
bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv, arg_sigpipe]);
153152
bcx.inst_results(call_inst)[0]
154-
} else {
155-
// using user-defined start fn
156-
let call_inst = bcx.ins().call(main_func_ref, &[arg_argc, arg_argv]);
157-
bcx.inst_results(call_inst)[0]
158153
};
159154

160155
bcx.ins().return_(&[result]);

compiler/rustc_codegen_gcc/build_system/src/test.rs

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -318,37 +318,6 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
318318
args,
319319
)?;
320320

321-
// FIXME: create a function "display_if_not_quiet" or something along the line.
322-
println!("[AOT] alloc_system");
323-
let mut command = args.config_info.rustc_command_vec();
324-
command.extend_from_slice(&[
325-
&"example/alloc_system.rs",
326-
&"--crate-type",
327-
&"lib",
328-
&"--target",
329-
&args.config_info.target_triple,
330-
]);
331-
if args.is_using_gcc_master_branch() {
332-
command.extend_from_slice(&[&"--cfg", &"feature=\"master\""]);
333-
}
334-
run_command_with_env(&command, None, Some(env))?;
335-
336-
// FIXME: doesn't work on m68k.
337-
if args.config_info.host_triple == args.config_info.target_triple {
338-
// FIXME: create a function "display_if_not_quiet" or something along the line.
339-
println!("[AOT] alloc_example");
340-
let mut command = args.config_info.rustc_command_vec();
341-
command.extend_from_slice(&[
342-
&"example/alloc_example.rs",
343-
&"--crate-type",
344-
&"bin",
345-
&"--target",
346-
&args.config_info.target_triple,
347-
]);
348-
run_command_with_env(&command, None, Some(env))?;
349-
maybe_run_command_in_vm(&[&cargo_target_dir.join("alloc_example")], env, args)?;
350-
}
351-
352321
// FIXME: create a function "display_if_not_quiet" or something along the line.
353322
println!("[AOT] dst_field_align");
354323
// FIXME(antoyo): Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
@@ -422,19 +391,6 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
422391
run_command_with_env(&command, None, Some(env))?;
423392
maybe_run_command_in_vm(&[&cargo_target_dir.join("track-caller-attribute")], env, args)?;
424393

425-
// FIXME: create a function "display_if_not_quiet" or something along the line.
426-
println!("[AOT] mod_bench");
427-
let mut command = args.config_info.rustc_command_vec();
428-
command.extend_from_slice(&[
429-
&"example/mod_bench.rs",
430-
&"--crate-type",
431-
&"bin",
432-
&"--target",
433-
&args.config_info.target_triple,
434-
]);
435-
run_command_with_env(&command, None, Some(env))?;
436-
// FIXME: the compiled binary is not run.
437-
438394
Ok(())
439395
}
440396

@@ -692,19 +648,6 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> {
692648
Ok(())
693649
}
694650

695-
// echo "[BENCH COMPILE] mod_bench"
696-
//
697-
// COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline"
698-
// COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o $cargo_target_dir/mod_bench_llvm_0 -Cpanic=abort"
699-
// COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o $cargo_target_dir/mod_bench_llvm_1 -Cpanic=abort"
700-
// COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o $cargo_target_dir/mod_bench_llvm_2 -Cpanic=abort"
701-
// COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o $cargo_target_dir/mod_bench_llvm_3 -Cpanic=abort"
702-
//
703-
// Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow
704-
// hyperfine --runs ${COMPILE_RUNS:-100} "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3"
705-
// echo "[BENCH RUN] mod_bench"
706-
// hyperfine --runs ${RUN_RUNS:-10} $cargo_target_dir/mod_bench{,_inline} $cargo_target_dir/mod_bench_llvm_*
707-
708651
fn extended_rand_tests(env: &Env, args: &TestArg) -> Result<(), String> {
709652
if !args.is_using_gcc_master_branch() {
710653
println!("Not using GCC master branch. Skipping `extended_rand_tests`.");

compiler/rustc_codegen_gcc/example/alloc_example.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)