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 #[start] entrypoints (closes #897) #898

Merged
merged 1 commit into from
Dec 25, 2024
Merged
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: 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
Loading