-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-embeddedWorking group: Embedded systemsWorking group: Embedded systems
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.
sanmai-NL, stephank, pocesar, hberntsen, gxtaillon and 3 more
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-embeddedWorking group: Embedded systemsWorking group: Embedded systems