GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Embed Notice

HTML Code

Corresponding Notice

  1. Embed this notice
    reimu@mk.fumo.pictures's status on Sunday, 16-Mar-2025 21:51:22 JSTreimureimu
    in reply to
    • EdBoatConnoisseur
    • 翠星石
    • T man :sex: :puffgiga: :puffpowerroll:
    • Pawlicker

    @Suiseiseki@freesoftwareextremist.com @theorytoe@ak.kyaruc.moe @PurpCat@clubcyberia.co @EdBoatConnoisseur@poa.st The problem with the rust compiler is by default it embeds the entire rust standard library into the binary (without optimizing).

    You can disable it with #![no_std] and use libc directly.

    this is the hello world program with libc:#![no_std] #![no_main] use core::ffi::CStr; #[no_mangle] pub extern fn main(_argc: i32, _argv: *const *const core::ffi::c_char) -> i32 { unsafe{libc::printf(CStr::from_bytes_with_nul_unchecked("hello world\n\0".as_bytes()).as_ptr());} 0 } #[cfg(not(test))] #[panic_handler] fn panic(_:&core::panic::PanicInfo)->! { loop{} }
    and add this to cargo.toml[dependencies] libc="*" [profile.dev] panic="abort" opt-level=3
    and add this in .cargo/config.toml[build] rustflags = ["-C", "link-args=-lc"]
    after stripping the binary it is 16K

    After removing the rust standard library you can check the binary if it contains the panic function. If it does that means the program may crash. If it doesn't then it cannot crash. (except in unsafe code). This feature can make rust code safe, but almost no one uses it.

    In conversationabout 2 months ago from mk.fumo.picturespermalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.