From mrustc 0.9. # Add mrustc slice length intrinsics --- rustc-1.29.0-src/src/libcore/intrinsics.rs +++ rustc-1.29.0-src/src/libcore/intrinsics.rs @@ -678,5 +678,9 @@ pub fn min_align_of_val(_: &T) -> usize; + /// Obtain the length of a slice pointer + #[cfg(rust_compiler="mrustc")] + pub fn mrustc_slice_len(pointer: *const [T]) -> usize; + /// Gets a static string slice containing the name of a type. pub fn type_name() -> &'static str; --- rustc-1.29.0-src/src/libcore/slice/mod.rs +++ rustc-1.29.0-src/src/libcore/slice/mod.rs @@ -413,5 +413,7 @@ pub const fn len(&self) -> usize { - unsafe { - Repr { rust: self }.raw.len - } + #[cfg(not(rust_compiler="mrustc"))] + const fn len_inner(s: &[T]) -> usize { unsafe { Repr { rust: s }.raw.len } }; + #[cfg(rust_compiler="mrustc")] + const fn len_inner(s: &[T]) -> usize { unsafe { ::intrinsics::mrustc_slice_len(s) } } + len_inner(self) } # Static-link rustc_codegen_llvm because mrustc doesn't have dylib support --- rustc-1.29.0-src/src/librustc_driver/Cargo.toml +++ rustc-1.29.0-src/src/librustc_driver/Cargo.toml @@ -39,1 +39,2 @@ syntax_pos = { path = "../libsyntax_pos" } +rustc_codegen_llvm = { path = "../librustc_codegen_llvm" } --- rustc-1.29.0-src/src/librustc_driver/lib.rs +++ rustc-1.29.0-src/src/librustc_driver/lib.rs @@ -63,2 +63,3 @@ extern crate syntax_pos; +extern crate rustc_codegen_llvm; @@ -296,3 +296,7 @@ } + if backend_name == "llvm" { + return rustc_codegen_llvm::__rustc_codegen_backend; + } + let target = session::config::host_triple(); # No workspace support in minicargo, patch cargo's Cargo.toml --- rustc-1.29.0-src/src/tools/cargo/Cargo.toml +++ rustc-1.29.0-src/src/tools/cargo/Cargo.toml @@ -60,5 +60,5 @@ # A noop dependency that changes in the Rust repository, it's a bit of a hack. # See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust` # for more information. -rustc-workspace-hack = "1.0.0" +rustc-workspace-hack = { path = "../rustc-workspace-hack" } # mrustc can't represent a 24 byte version of this enum (no way of storing the # tag in padding) --- rustc-1.29.0-src/src/librustc/ty/context.rs +++ rustc-1.29.0-src/src/librustc/ty/context.rs @@ -805,5 +805,5 @@ // Ensure our type representation does not grow - #[cfg(target_pointer_width = "64")] - assert!(mem::size_of::() <= 24); - #[cfg(target_pointer_width = "64")] - assert!(mem::size_of::() <= 32); + //#[cfg(target_pointer_width = "64")] + //assert!(mem::size_of::() <= 24); + //#[cfg(target_pointer_width = "64")] + //assert!(mem::size_of::() <= 32); --- rustc-1.29.0-src/src/stdsimd/stdsimd/arch/detect/os/x86.rs +++ rustc-1.29.0-src/src/stdsimd/stdsimd/arch/detect/os/x86.rs @@ -14,5 +14,11 @@ /// Performs run-time feature detection. #[inline] +#[cfg(not(rust_compiler="mrustc"))] pub fn check_for(x: Feature) -> bool { cache::test(x as u32, detect_features) } +#[inline] +#[cfg(rust_compiler="mrustc")] +pub fn check_for(x: Feature) -> bool { + false +}