Skip to content

Commit

Permalink
Remove #[start] entrypoints (closes #897)
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Dec 25, 2024
1 parent 1a45e84 commit 2a9f626
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 7 additions & 3 deletions crates/rune/src/runtime/from_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,13 @@ where
/// field: u64,
/// }
///
/// let mut sources = rune::sources!(entry => {
/// pub fn main() { #{field: 42} }
/// });
/// let mut sources = rune::sources! {
/// entry => {
/// pub fn main() {
/// #{field: 42}
/// }
/// }
/// };
///
/// let unit = rune::prepare(&mut sources).build()?;
///
Expand Down
2 changes: 1 addition & 1 deletion no-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ rune = { path = "../crates/rune", default-features = false, features = ["alloc"]
wee_alloc = "0.4.5"
# Pull in your own critical-section implementation.
# See: https://github.com/rust-embedded/critical-section/tree/main#usage-in-no-std-binaries
critical-section = { version = "1.1.2", default-features = false }
critical-section = { version = "1.2.0", default-features = false }
15 changes: 9 additions & 6 deletions no-std/examples/minimal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![no_std]
#![feature(alloc_error_handler, start, core_intrinsics, lang_items, link_cfg)]
#![no_main]
#![feature(alloc_error_handler, core_intrinsics, lang_items, link_cfg)]
#![allow(internal_features)]

extern crate alloc;
Expand Down Expand Up @@ -33,6 +34,8 @@ extern "C" fn eh_personality() {}
#[no_mangle]
pub extern "C" fn _Unwind_Resume() {}

use core::ffi::c_int;

use alloc::sync::Arc;

use rune::{Diagnostics, Vm};
Expand All @@ -53,24 +56,24 @@ unsafe impl critical_section::Impl for MyCriticalSection {
unsafe fn release(_: RawRestoreState) {}
}

#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
#[no_mangle]
extern "C" fn main(_argc: c_int, _argv: *const *const u8) -> c_int {
match inner_main() {
Ok(output) => output as isize,
Ok(output) => output as c_int,
Err(..) => -1,
}
}

fn inner_main() -> rune::support::Result<i32> {
let context = rune::Context::with_default_modules()?;

let mut sources = rune::sources!(
let mut sources = rune::sources! {
entry => {
pub fn main(number) {
number + 10
}
}
);
};

let mut diagnostics = Diagnostics::new();

Expand Down

0 comments on commit 2a9f626

Please sign in to comment.