Skip to content

Commit

Permalink
Update brioche-packed-userland-exec to use #![no_main]
Browse files Browse the repository at this point in the history
This skips some Rust runtime setup code and further reduces the binary
size
  • Loading branch information
kylewlacy committed Dec 31, 2023
1 parent 7e7f8d8 commit ffac788
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/brioche-packed-userland-exec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ edition = "2021"
bincode = "2.0.0-rc.3"
brioche-pack = { path = "../brioche-pack", default-features = false }
bstr = "1.8.0"
libc = "0.2.151"
thiserror = "1.0.51"
userland-execve = { git = "https://github.com/brioche-dev/userland-execve-rust.git" }
14 changes: 7 additions & 7 deletions crates/brioche-packed-userland-exec/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use std::{
ffi::{CStr, CString},
process::ExitCode,
};
#![no_main]

use std::ffi::{CStr, CString};

use bstr::ByteSlice as _;

const BRIOCHE_PACKED_ERROR: u8 = 121;

fn main() -> ExitCode {
#[no_mangle]
pub extern "C" fn main(_argc: libc::c_int, _argv: *const *const libc::c_char) -> libc::c_int {
let result = run();
match result {
Ok(()) => ExitCode::SUCCESS,
Ok(()) => 0,
Err(err) => {
eprintln!("brioche-packed error: {err}");
ExitCode::from(BRIOCHE_PACKED_ERROR)
BRIOCHE_PACKED_ERROR.into()
}
}
}
Expand Down

0 comments on commit ffac788

Please sign in to comment.