Update Cranelift

This commit is contained in:
bjorn3 2020-06-16 10:38:12 +02:00
parent bd6e0e6e12
commit d471c1b521
3 changed files with 44 additions and 20 deletions

30
Cargo.lock generated
View file

@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cranelift-bforest"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
dependencies = [
"cranelift-entity",
]
@ -53,7 +53,7 @@ dependencies = [
[[package]]
name = "cranelift-codegen"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
dependencies = [
"byteorder",
"cranelift-bforest",
@ -71,7 +71,7 @@ dependencies = [
[[package]]
name = "cranelift-codegen-meta"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
dependencies = [
"cranelift-codegen-shared",
"cranelift-entity",
@ -80,17 +80,17 @@ dependencies = [
[[package]]
name = "cranelift-codegen-shared"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
[[package]]
name = "cranelift-entity"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
[[package]]
name = "cranelift-frontend"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
dependencies = [
"cranelift-codegen",
"log",
@ -101,7 +101,7 @@ dependencies = [
[[package]]
name = "cranelift-module"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
dependencies = [
"anyhow",
"cranelift-codegen",
@ -113,7 +113,7 @@ dependencies = [
[[package]]
name = "cranelift-native"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
dependencies = [
"cranelift-codegen",
"raw-cpuid",
@ -123,8 +123,9 @@ dependencies = [
[[package]]
name = "cranelift-object"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
dependencies = [
"anyhow",
"cranelift-codegen",
"cranelift-module",
"object",
@ -134,7 +135,7 @@ dependencies = [
[[package]]
name = "cranelift-simplejit"
version = "0.65.0"
source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a"
source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e"
dependencies = [
"cranelift-codegen",
"cranelift-module",
@ -235,13 +236,12 @@ dependencies = [
[[package]]
name = "object"
version = "0.18.0"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5666bbb90bc4d1e5bdcb26c0afda1822d25928341e9384ab187a9b37ab69e36"
checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2"
dependencies = [
"crc32fast",
"indexmap",
"target-lexicon",
"wasmparser",
]
@ -397,9 +397,9 @@ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "wasmparser"
version = "0.51.4"
version = "0.54.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a"
checksum = "747467da102640806cf6643e032a70174e7768839bcac7e71a0a9aaa54761d59"
[[package]]
name = "winapi"

View file

@ -21,7 +21,7 @@ indexmap = "1.0.2"
cfg-if = "0.1.10"
[dependencies.object]
version = "0.18.0"
version = "0.19.0"
default-features = false
features = ["read", "std", "write"] # We don't need WASM support

View file

@ -58,7 +58,7 @@ impl WriteDebugInfo for ObjectProduct {
id: SectionId,
data: Vec<u8>,
) -> (object::write::SectionId, object::write::SymbolId) {
let name = if self.object.format() == target_lexicon::BinaryFormat::Macho {
let name = if self.object.format() == object::BinaryFormat::MachO {
id.name().replace('.', "__") // machO expects __debug_info instead of .debug_info
} else {
id.name().to_string()
@ -109,8 +109,32 @@ impl Emit for ObjectProduct {
pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> Vec<u8> {
let triple = crate::build_isa(sess, true).triple().clone();
let mut metadata_object =
object::write::Object::new(triple.binary_format, triple.architecture);
let binary_format = match triple.binary_format {
target_lexicon::BinaryFormat::Elf => object::BinaryFormat::Elf,
target_lexicon::BinaryFormat::Coff => object::BinaryFormat::Coff,
target_lexicon::BinaryFormat::Macho => object::BinaryFormat::MachO,
target_lexicon::BinaryFormat::Wasm => sess.fatal("binary format wasm is unsupported"),
target_lexicon::BinaryFormat::Unknown => sess.fatal("binary format is unknown"),
};
let architecture = match triple.architecture {
target_lexicon::Architecture::I386
| target_lexicon::Architecture::I586
| target_lexicon::Architecture::I686 => object::Architecture::I386,
target_lexicon::Architecture::X86_64 => object::Architecture::X86_64,
target_lexicon::Architecture::Arm(_) => object::Architecture::Arm,
target_lexicon::Architecture::Aarch64(_) => object::Architecture::Aarch64,
architecture => sess.fatal(&format!(
"target architecture {:?} is unsupported",
architecture,
))
};
let endian = match triple.endianness().unwrap() {
target_lexicon::Endianness::Little => object::Endianness::Little,
target_lexicon::Endianness::Big => object::Endianness::Big,
};
let mut metadata_object = object::write::Object::new(binary_format, architecture, endian);
metadata_object.add_file_symbol(name.as_bytes().to_vec());
f(&mut metadata_object);
metadata_object.write().unwrap()
@ -124,7 +148,7 @@ pub(crate) fn make_module(sess: &Session, name: String) -> Module<Backend> {
crate::build_isa(sess, true),
name + ".o",
cranelift_module::default_libcall_names(),
),
).unwrap(),
);
module
}