diff --git a/Cargo.lock b/Cargo.lock index 77d1fd0b405..9c669c87a73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -317,7 +317,6 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar", - "byteorder", "cfg-if", "cranelift-codegen", "cranelift-frontend", diff --git a/Cargo.toml b/Cargo.toml index e178e29925b..5962356beea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ gimli = { version = "0.21.0", default-features = false, features = ["write"]} object = { version = "0.21.1", default-features = false, features = ["read", "std", "write"] } ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } -byteorder = "1.2.7" indexmap = "1.0.2" cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } diff --git a/src/vtable.rs b/src/vtable.rs index d23b077148e..c58b39c1c82 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -168,18 +168,23 @@ fn build_vtable<'tcx>( } fn write_usize(tcx: TyCtxt<'_>, buf: &mut [u8], idx: usize, num: u64) { - use byteorder::{BigEndian, LittleEndian, WriteBytesExt}; - - let usize_size = tcx + let pointer_size = tcx .layout_of(ParamEnv::reveal_all().and(tcx.types.usize)) .unwrap() .size .bytes() as usize; - let mut target = &mut buf[idx * usize_size..(idx + 1) * usize_size]; + let target = &mut buf[idx * pointer_size..(idx + 1) * pointer_size]; match tcx.data_layout.endian { - rustc_target::abi::Endian::Little => target.write_uint::(num, usize_size), - rustc_target::abi::Endian::Big => target.write_uint::(num, usize_size), + rustc_target::abi::Endian::Little => match pointer_size { + 4 => target.copy_from_slice(&(num as u32).to_le_bytes()), + 8 => target.copy_from_slice(&(num as u64).to_le_bytes()), + _ => todo!("pointer size {} is not yet supported", pointer_size), + }, + rustc_target::abi::Endian::Big => match pointer_size { + 4 => target.copy_from_slice(&(num as u32).to_be_bytes()), + 8 => target.copy_from_slice(&(num as u64).to_be_bytes()), + _ => todo!("pointer size {} is not yet supported", pointer_size), + }, } - .unwrap() }