make unknown-unknown primary

This commit is contained in:
NikVolf
2018-01-30 15:21:17 +03:00
parent a228b43f19
commit 6878005822
3 changed files with 36 additions and 24 deletions
+6 -11
View File
@@ -14,7 +14,7 @@ use std::path::PathBuf;
use clap::{App, Arg};
use parity_wasm::elements;
use wasm_utils::{CREATE_SYMBOL, CALL_SYMBOL, underscore_funcs};
use wasm_utils::{CREATE_SYMBOL, CALL_SYMBOL, MEMORY_SYMBOL, ununderscore_funcs};
#[derive(Debug)]
pub enum Error {
@@ -125,15 +125,7 @@ fn main() {
let mut module = parity_wasm::deserialize_file(&path).unwrap();
if let source::SourceTarget::Unknown = source_input.target() {
module = underscore_funcs(module);
// Removes the start section for 'wasm32-unknown-unknown' target if exists
module.sections_mut().retain(|section| {
if let &elements::Section::Start(ref _a) = section {
false
} else {
true
}
});
module = ununderscore_funcs(module);
}
if let Some(runtime_type) = matches.value_of("runtime_type") {
@@ -149,7 +141,10 @@ fn main() {
let mut ctor_module = module.clone();
if !matches.is_present("skip_optimization") {
wasm_utils::optimize(&mut module, vec![CALL_SYMBOL]).expect("Optimizer to finish without errors");
wasm_utils::optimize(
&mut module,
vec![CALL_SYMBOL, MEMORY_SYMBOL]
).expect("Optimizer to finish without errors");
}
if let Some(save_raw_path) = matches.value_of("save_raw") {