Fix dependency paths. wasmstandalone no longer depends on out-of-tree patches.
This commit is contained in:
10
Cargo.toml
10
Cargo.toml
@@ -17,11 +17,11 @@ name = "wasm2obj"
|
|||||||
path = "src/wasm2obj.rs"
|
path = "src/wasm2obj.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cretonne = { path = "/home/sunfish/rust/cretonne/lib/cretonne" }
|
cretonne = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
cretonne-frontend = { path = "/home/sunfish/rust/cretonne/lib/frontend" }
|
cretonne-frontend = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
cretonne-reader = { path = "/home/sunfish/rust/cretonne/lib/reader" }
|
cretonne-reader = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
cretonne-wasm = { path = "/home/sunfish/rust/cretonne/lib/wasm" }
|
cretonne-wasm = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
cretonne-native = { path = "/home/sunfish/rust/cretonne/lib/native" }
|
cretonne-native = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
wasmstandalone = { path = "lib/wasmstandalone" }
|
wasmstandalone = { path = "lib/wasmstandalone" }
|
||||||
wasm2obj = { path = "lib/wasm2obj" }
|
wasm2obj = { path = "lib/wasm2obj" }
|
||||||
wasmparser = "0.8.2"
|
wasmparser = "0.8.2"
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ authors = ["The Cretonne Project Developers"]
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cretonne = { path = "/home/sunfish/rust/cretonne/lib/cretonne" }
|
cretonne = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
cretonne-frontend = { path = "/home/sunfish/rust/cretonne/lib/frontend" }
|
cretonne-frontend = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
cretonne-wasm = { path = "/home/sunfish/rust/cretonne/lib/wasm" }
|
cretonne-wasm = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
|
wasmstandalone = { path = "../wasmstandalone" }
|
||||||
faerie = { git = "https://github.com/m4b/faerie" }
|
faerie = { git = "https://github.com/m4b/faerie" }
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use cton_wasm::TranslationResult;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use faerie::Artifact;
|
use faerie::Artifact;
|
||||||
|
use wasmstandalone::StandaloneRuntime;
|
||||||
|
|
||||||
type RelocRef = u16;
|
type RelocRef = u16;
|
||||||
|
|
||||||
@@ -50,10 +51,11 @@ pub fn emit_module(
|
|||||||
trans_result: &TranslationResult,
|
trans_result: &TranslationResult,
|
||||||
obj: &mut Artifact,
|
obj: &mut Artifact,
|
||||||
isa: &TargetIsa,
|
isa: &TargetIsa,
|
||||||
|
runtime: &StandaloneRuntime,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
trans_result.start_index.is_none() ||
|
trans_result.start_index.is_none() ||
|
||||||
trans_result.start_index.unwrap() >= trans_result.function_imports_count,
|
trans_result.start_index.unwrap() >= runtime.imported_funcs.len(),
|
||||||
"imported start functions not supported yet"
|
"imported start functions not supported yet"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
extern crate cretonne;
|
extern crate cretonne;
|
||||||
extern crate cton_wasm;
|
extern crate cton_wasm;
|
||||||
extern crate faerie;
|
extern crate faerie;
|
||||||
|
extern crate wasmstandalone;
|
||||||
|
|
||||||
mod emit_module;
|
mod emit_module;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ repository = "https://github.com/stoklund/cretonne"
|
|||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cretonne = { path = "/home/sunfish/rust/cretonne/lib/cretonne" }
|
cretonne = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
cretonne-frontend = { path = "/home/sunfish/rust/cretonne/lib/frontend" }
|
cretonne-frontend = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
cretonne-wasm = { path = "/home/sunfish/rust/cretonne/lib/wasm" }
|
cretonne-wasm = { git = "https://github.com/stoklund/cretonne.git" }
|
||||||
region = "0.0.8"
|
region = "0.0.8"
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ pub fn compile_module(
|
|||||||
) -> Result<ExecutableCode, String> {
|
) -> Result<ExecutableCode, String> {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
trans_result.start_index.is_none() ||
|
trans_result.start_index.is_none() ||
|
||||||
trans_result.start_index.unwrap() >= trans_result.function_imports_count,
|
trans_result.start_index.unwrap() >= runtime.imported_funcs.len(),
|
||||||
"imported start functions not supported yet"
|
"imported start functions not supported yet"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -101,12 +101,7 @@ pub fn compile_module(
|
|||||||
});
|
});
|
||||||
functions_code.push(code_buf);
|
functions_code.push(code_buf);
|
||||||
}
|
}
|
||||||
relocate(
|
relocate(&functions_metatada, &mut functions_code, runtime);
|
||||||
trans_result.function_imports_count,
|
|
||||||
&functions_metatada,
|
|
||||||
&mut functions_code,
|
|
||||||
runtime,
|
|
||||||
);
|
|
||||||
// After having emmitted the code to memory, we deal with relocations
|
// After having emmitted the code to memory, we deal with relocations
|
||||||
match trans_result.start_index {
|
match trans_result.start_index {
|
||||||
None => Err(String::from(
|
None => Err(String::from(
|
||||||
@@ -152,7 +147,6 @@ pub fn execute(exec: &ExecutableCode) -> Result<(), String> {
|
|||||||
|
|
||||||
/// Performs the relocations inside the function bytecode, provided the necessary metadata
|
/// Performs the relocations inside the function bytecode, provided the necessary metadata
|
||||||
fn relocate(
|
fn relocate(
|
||||||
function_imports_count: usize,
|
|
||||||
functions_metatada: &[FunctionMetaData],
|
functions_metatada: &[FunctionMetaData],
|
||||||
functions_code: &mut Vec<Vec<u8>>,
|
functions_code: &mut Vec<Vec<u8>>,
|
||||||
runtime: &StandaloneRuntime,
|
runtime: &StandaloneRuntime,
|
||||||
@@ -164,7 +158,7 @@ fn relocate(
|
|||||||
ref il_func,
|
ref il_func,
|
||||||
} = *function_in_memory;
|
} = *function_in_memory;
|
||||||
for &(func_ref, offset) in relocs.funcs.values() {
|
for &(func_ref, offset) in relocs.funcs.values() {
|
||||||
let target_func_index = runtime.func_indices[func_ref] - function_imports_count;
|
let target_func_index = runtime.func_indices[func_ref] - runtime.imported_funcs.len();
|
||||||
let target_func_address: isize = functions_code[target_func_index].as_ptr() as isize;
|
let target_func_address: isize = functions_code[target_func_index].as_ptr() as isize;
|
||||||
unsafe {
|
unsafe {
|
||||||
let reloc_address: isize = functions_code[func_index].as_mut_ptr().offset(
|
let reloc_address: isize = functions_code[func_index].as_mut_ptr().offset(
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ struct GlobalInfo {
|
|||||||
offset: usize,
|
offset: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GlobalsData {
|
pub struct GlobalsData {
|
||||||
data: Vec<u8>,
|
data: Vec<u8>,
|
||||||
info: Vec<GlobalInfo>,
|
info: Vec<GlobalInfo>,
|
||||||
}
|
}
|
||||||
@@ -51,17 +51,18 @@ const PAGE_SIZE: usize = 65536;
|
|||||||
/// Object containing the standalone runtime information. To be passed after creation as argument
|
/// Object containing the standalone runtime information. To be passed after creation as argument
|
||||||
/// to `cton_wasm::translatemodule`.
|
/// to `cton_wasm::translatemodule`.
|
||||||
pub struct StandaloneRuntime {
|
pub struct StandaloneRuntime {
|
||||||
// Compilation setting flags.
|
/// Compilation setting flags.
|
||||||
flags: settings::Flags,
|
flags: settings::Flags,
|
||||||
|
|
||||||
// Unprocessed signatures exactly as provided by `declare_signature()`.
|
/// Unprocessed signatures exactly as provided by `declare_signature()`.
|
||||||
signatures: Vec<ir::Signature>,
|
signatures: Vec<ir::Signature>,
|
||||||
// Types of functions, imported and local.
|
/// Types of functions, imported and local.
|
||||||
func_types: Vec<SignatureIndex>,
|
func_types: Vec<SignatureIndex>,
|
||||||
// Names of imported functions.
|
/// Names of imported functions.
|
||||||
imported_funcs: Vec<ir::FunctionName>,
|
pub imported_funcs: Vec<ir::FunctionName>,
|
||||||
|
|
||||||
globals: GlobalsData,
|
/// WebAssembly global variables.
|
||||||
|
pub globals: GlobalsData,
|
||||||
/// WebAssembly tables.
|
/// WebAssembly tables.
|
||||||
pub tables: Vec<TableData>,
|
pub tables: Vec<TableData>,
|
||||||
/// WebAssembly linear memories.
|
/// WebAssembly linear memories.
|
||||||
|
|||||||
13
src/main.rs
13
src/main.rs
@@ -207,7 +207,15 @@ fn handle_module(args: &Args, path: PathBuf, name: &str, isa: &TargetIsa) -> Res
|
|||||||
if args.flag_print {
|
if args.flag_print {
|
||||||
let mut writer1 = stdout();
|
let mut writer1 = stdout();
|
||||||
let mut writer2 = stdout();
|
let mut writer2 = stdout();
|
||||||
match pretty_print_translation(name, &data, &translation, &mut writer1, &mut writer2, isa) {
|
match pretty_print_translation(
|
||||||
|
name,
|
||||||
|
&data,
|
||||||
|
&translation,
|
||||||
|
&mut writer1,
|
||||||
|
&mut writer2,
|
||||||
|
isa,
|
||||||
|
&runtime,
|
||||||
|
) {
|
||||||
Err(error) => return Err(String::from(error.description())),
|
Err(error) => return Err(String::from(error.description())),
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
}
|
}
|
||||||
@@ -334,11 +342,12 @@ fn pretty_print_translation(
|
|||||||
writer_wat: &mut Write,
|
writer_wat: &mut Write,
|
||||||
writer_cretonne: &mut Write,
|
writer_cretonne: &mut Write,
|
||||||
isa: &TargetIsa,
|
isa: &TargetIsa,
|
||||||
|
runtime: &StandaloneRuntime,
|
||||||
) -> Result<(), io::Error> {
|
) -> Result<(), io::Error> {
|
||||||
let mut terminal = term::stdout().unwrap();
|
let mut terminal = term::stdout().unwrap();
|
||||||
let mut parser = Parser::new(data);
|
let mut parser = Parser::new(data);
|
||||||
let mut parser_writer = Writer::new(writer_wat);
|
let mut parser_writer = Writer::new(writer_wat);
|
||||||
let imports_count = translation.function_imports_count;
|
let imports_count = runtime.imported_funcs.len();
|
||||||
match parser.read() {
|
match parser.read() {
|
||||||
s @ &ParserState::BeginWasm { .. } => parser_writer.write(s)?,
|
s @ &ParserState::BeginWasm { .. } => parser_writer.write(s)?,
|
||||||
_ => panic!("modules should begin properly"),
|
_ => panic!("modules should begin properly"),
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ fn handle_module(path: PathBuf, output: &str) -> Result<(), String> {
|
|||||||
// FIXME: Make the output filename a parameter.
|
// FIXME: Make the output filename a parameter.
|
||||||
let mut obj = Artifact::new(Target::X86_64, Some(String::from(output)));
|
let mut obj = Artifact::new(Target::X86_64, Some(String::from(output)));
|
||||||
|
|
||||||
emit_module(&translation, &mut obj, &*isa)?;
|
emit_module(&translation, &mut obj, &*isa, &runtime)?;
|
||||||
|
|
||||||
if !runtime.tables.is_empty() {
|
if !runtime.tables.is_empty() {
|
||||||
if runtime.tables.len() > 1 {
|
if runtime.tables.len() > 1 {
|
||||||
|
|||||||
Reference in New Issue
Block a user