Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove support for the (unstable) #[start] attribute #134299

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions compiler/rustc_ast/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ pub enum EntryPointType {
/// fn main() {}
/// ```
RustcMainAttr,
/// This is a function with the `#[start]` attribute.
/// ```ignore (clashes with test entrypoint)
/// #[start]
/// fn main() {}
/// ```
Start,
/// This function is **not** an entrypoint but simply named `main` (not at the root).
/// This is only used for diagnostics.
/// ```
Expand All @@ -41,9 +35,7 @@ pub fn entry_point_type(
at_root: bool,
name: Option<Symbol>,
) -> EntryPointType {
if attr::contains_name(attrs, sym::start) {
EntryPointType::Start
} else if attr::contains_name(attrs, sym::rustc_main) {
if attr::contains_name(attrs, sym::rustc_main) {
EntryPointType::RustcMainAttr
} else if let Some(name) = name
&& name == sym::main
Expand Down
12 changes: 0 additions & 12 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}
}

ast::ItemKind::Fn(..) => {
if attr::contains_name(&i.attrs, sym::start) {
gate!(
&self,
start,
i.span,
"`#[start]` functions are experimental and their signature may change \
over time"
);
}
}

ast::ItemKind::Struct(..) => {
for attr in attr::filter_by_name(&i.attrs, sym::repr) {
for item in attr.meta_item_list().unwrap_or_else(ThinVec::new) {
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_builtin_macros/src/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
ast::mut_visit::walk_item(self, item);
self.depth -= 1;

// Remove any #[rustc_main] or #[start] from the AST so it doesn't
// Remove any #[rustc_main] from the AST so it doesn't
// clash with the one we're going to add, but mark it as
// #[allow(dead_code)] to avoid printing warnings.
match entry_point_type(&item, self.depth == 0) {
EntryPointType::MainNamed | EntryPointType::RustcMainAttr | EntryPointType::Start => {
EntryPointType::MainNamed | EntryPointType::RustcMainAttr => {
let allow_dead_code = attr::mk_attr_nested_word(
&self.sess.psess.attr_id_generator,
ast::AttrStyle::Outer,
Expand All @@ -218,8 +218,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
sym::dead_code,
self.def_site,
);
item.attrs
.retain(|attr| !attr.has_name(sym::rustc_main) && !attr.has_name(sym::start));
item.attrs.retain(|attr| !attr.has_name(sym::rustc_main));
item.attrs.push(allow_dead_code);
}
EntryPointType::None | EntryPointType::OtherMain => {}
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_codegen_cranelift/build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
"example/arbitrary_self_types_pointers_and_wrappers.rs",
&[],
),
TestCase::build_lib("build.alloc_system", "example/alloc_system.rs", "lib"),
TestCase::build_bin_and_run("aot.alloc_example", "example/alloc_example.rs", &[]),
TestCase::jit_bin("jit.std_example", "example/std_example.rs", "arg"),
TestCase::build_bin_and_run("aot.std_example", "example/std_example.rs", &["arg"]),
TestCase::build_bin_and_run("aot.dst_field_align", "example/dst-field-align.rs", &[]),
Expand All @@ -89,7 +87,6 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
&[],
),
TestCase::build_bin_and_run("aot.float-minmax-pass", "example/float-minmax-pass.rs", &[]),
TestCase::build_bin_and_run("aot.mod_bench", "example/mod_bench.rs", &[]),
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
TestCase::build_bin_and_run("aot.neon", "example/neon.rs", &[]),
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_codegen_cranelift/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ aot.mini_core_hello_world
testsuite.base_sysroot
aot.arbitrary_self_types_pointers_and_wrappers
aot.issue_91827_extern_types
build.alloc_system
aot.alloc_example
jit.std_example
aot.std_example
aot.dst_field_align
aot.subslice-patterns-const-eval
aot.track-caller-attribute
aot.float-minmax-pass
aot.mod_bench
aot.issue-72793
aot.issue-59326
aot.neon
Expand Down
44 changes: 0 additions & 44 deletions compiler/rustc_codegen_cranelift/example/alloc_example.rs

This file was deleted.

124 changes: 0 additions & 124 deletions compiler/rustc_codegen_cranelift/example/alloc_system.rs

This file was deleted.

37 changes: 0 additions & 37 deletions compiler/rustc_codegen_cranelift/example/mod_bench.rs

This file was deleted.

21 changes: 8 additions & 13 deletions compiler/rustc_codegen_cranelift/src/main_shim.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use rustc_hir::LangItem;
use rustc_middle::ty::{AssocKind, GenericArg};
use rustc_session::config::{EntryFnType, sigpipe};
use rustc_session::config::EntryFnType;
use rustc_span::DUMMY_SP;
use rustc_span::symbol::Ident;

Expand All @@ -15,10 +15,9 @@ pub(crate) fn maybe_create_entry_wrapper(
is_jit: bool,
is_primary_cgu: bool,
) {
let (main_def_id, (is_main_fn, sigpipe)) = match tcx.entry_fn(()) {
let (main_def_id, sigpipe) = match tcx.entry_fn(()) {
Some((def_id, entry_ty)) => (def_id, match entry_ty {
EntryFnType::Main { sigpipe } => (true, sigpipe),
EntryFnType::Start => (false, sigpipe::DEFAULT),
EntryFnType::Main { sigpipe } => sigpipe,
}),
None => return,
};
Expand All @@ -32,14 +31,13 @@ pub(crate) fn maybe_create_entry_wrapper(
return;
}

create_entry_fn(tcx, module, main_def_id, is_jit, is_main_fn, sigpipe);
create_entry_fn(tcx, module, main_def_id, is_jit, sigpipe);

fn create_entry_fn(
tcx: TyCtxt<'_>,
m: &mut dyn Module,
rust_main_def_id: DefId,
ignore_lang_start_wrapper: bool,
is_main_fn: bool,
sigpipe: u8,
) {
let main_ret_ty = tcx.fn_sig(rust_main_def_id).no_bound_vars().unwrap().output();
Expand Down Expand Up @@ -95,8 +93,8 @@ pub(crate) fn maybe_create_entry_wrapper(

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

let result = if is_main_fn && ignore_lang_start_wrapper {
// regular main fn, but ignoring #[lang = "start"] as we are running in the jit
let result = if ignore_lang_start_wrapper {
// ignoring #[lang = "start"] as we are running in the jit
// FIXME set program arguments somehow
let call_inst = bcx.ins().call(main_func_ref, &[]);
let call_results = bcx.func.dfg.inst_results(call_inst).to_owned();
Expand Down Expand Up @@ -134,7 +132,8 @@ pub(crate) fn maybe_create_entry_wrapper(
types::I64 => bcx.ins().sextend(types::I64, res),
_ => unimplemented!("16bit systems are not yet supported"),
}
} else if is_main_fn {
} else {
// Regular main fn invoked via start lang item.
let start_def_id = tcx.require_lang_item(LangItem::Start, None);
let start_instance = Instance::expect_resolve(
tcx,
Expand All @@ -151,10 +150,6 @@ pub(crate) fn maybe_create_entry_wrapper(
let call_inst =
bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv, arg_sigpipe]);
bcx.inst_results(call_inst)[0]
} else {
// using user-defined start fn
let call_inst = bcx.ins().call(main_func_ref, &[arg_argc, arg_argv]);
bcx.inst_results(call_inst)[0]
};

bcx.ins().return_(&[result]);
Expand Down
Loading
Loading