Skip to content

Instantly share code, notes, and snippets.

@MaxGraey
Last active April 17, 2018 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaxGraey/bf004614efaeef1dfaa07921d009a122 to your computer and use it in GitHub Desktop.
Save MaxGraey/bf004614efaeef1dfaa07921d009a122 to your computer and use it in GitHub Desktop.
Shrink Rust wasm size
#![feature(core_intrinsics, lang_items)]
#![no_main]
#![no_std]
#[lang = "panic_fmt"]
extern "C" fn panic_fmt(_args: ::core::fmt::Arguments, _file: &'static str, _line: u32) -> ! {
use core::intrinsics;
unsafe {
intrinsics::abort();
}
}
#[no_mangle]
pub extern "C" fn one() -> i32 {
return None.unwrap();
}
// Compiled to wasm size shrink from 34 Kb to ~350b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment