Open
Description
It seems that custom panic_fmt
that doesn't touches Arguments
doesnt not help to strip all panic-related strings from final binary while compiling to wasm (either emscripten or wasm32-unknown-unknown)
#![feature(lang_items)]
#![no_std]
#![no_main]
extern "C" {
fn halt();
}
#[no_mangle]
#[lang = "panic_fmt"]
pub extern "C" fn panic_fmt(
_args: ::core::fmt::Arguments,
_file: &'static str,
_line: u32,
_col: u32,
) -> ! {
loop {
unsafe { halt() }
}
}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[no_mangle]
pub fn call(descriptor: u8) -> u8 {
assert!(descriptor > 0);
descriptor
}
Invocation:
rustc --target=wasm32-unknown-emscripten --emit llvm-ir -C lto -C opt-level=3 src/main.rs
$ rustc --version
rustc 1.24.0-nightly (1956d5535 2017-12-03)
this produces the following LLVM IR.
The problem is that panic_fmt
is not using it's _args
, so it is a dead arg. However, despite this, strings for panic messages are still end up in the LLVM IR}.
It seems that running opt -deadargelim -globaldce
helps to strip this strings.
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: An issue proposing an enhancement or a PR with one.Issue: Problems and improvements with respect to binary size of generated code.Relevant to the compiler team, which will review and decide on the PR/issue.Working group: Embedded systems