rust-mos
rust-mos copied to clipboard
Include precompiled core in rust-mos releases
Currently we need to build core each time via unstable build-std featue
It looks like core is unable to build, using the latest docker image (or the stable tag) at least.
cargo build -Zbuild-std --target=mos-unknown-none
fails with:
LLVM ERROR: unable to legalize instruction: %14:_(s32) = G_UITOFP %0:_(s64) (in function: _ZN59_$LT$f32$u20$as$u20$core..num..dec2flt..float..RawFloat$GT$8from_u6417h32e5a3808762377aE)
error: could not compile `core`
The rust file attempting to build is here:
#![no_main]
#![no_std]
use core::panic::PanicInfo;
// This is the most basic banic handler you can have.
#[panic_handler]
fn panic(_panic: &PanicInfo<'_>) -> ! {
loop {}
}
Also I could be using a feature that doesn't work. I'm not quite sure.
Try to enable lto: https://doc.rust-lang.org/cargo/reference/profiles.html#lto
Thanks for the quick response, lto didn't seem to change anything. (tried both dev and release)
Same error. I'm guessing that warning is relevant, but have no idea where it's coming from. I've been deleting the Cargo.lock
and target
dir between builds. Also tried its advice of "cargo update".
Here's the full output:
mos@394b2db7d28e:/code$ cargo build -Zbuild-std --target=mos-unknown-none --release
Updating git repository `https://github.com/mrk-its/compiler-builtins`
warning: Patch `compiler_builtins v0.1.71 (https://github.com/mrk-its/compiler-builtins?branch=mos_target#ea89a31b)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
Compiling compiler_builtins v0.1.70
Compiling core v0.0.0 (/usr/local/rust-mos/lib/rustlib/src/rust/library/core)
Compiling libc v0.2.116
Compiling cc v1.0.69
Compiling memchr v2.4.1
Compiling std v0.0.0 (/usr/local/rust-mos/lib/rustlib/src/rust/library/std)
Compiling unwind v0.0.0 (/usr/local/rust-mos/lib/rustlib/src/rust/library/unwind)
Compiling rustc-std-workspace-core v1.99.0 (/usr/local/rust-mos/lib/rustlib/src/rust/library/rustc-std-workspace-core)
Compiling alloc v0.0.0 (/usr/local/rust-mos/lib/rustlib/src/rust/library/alloc)
Compiling cfg-if v0.1.10
LLVM ERROR: unable to legalize instruction: %143:_(s32) = G_FCONSTANT float 0.000000e+00 (in function: _ZN17compiler_builtins5float4conv11__floatsisf17h614dfe44ea341f21E)
error: could not compile `compiler_builtins`
warning: build failed, waiting for other jobs to finish...
Here's the cargo.toml, maybe I'm missing something there.
[package]
name = "hello_mos"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[profile.dev]
lto = true
[profile.release]
lto = true
thanks, trying to reproduce it locally
I'm not able to reproduce it, I succesfully built two projects with mrkits/rust-mos:latest
docker image.
Please do not use stable
image, it is outdated, use latest
. In my logs I see:
Compiling compiler_builtins v0.1.85 (https://github.com/mrk-its/compiler-builtins?tag=0.1.85-mos#384dcad0)
so much newer version than in your logs.
Also, try to build https://github.com/mrk-its/rust-mos-hello-world/ or https://github.com/mrk-its/aoc2022 (follow README for build instructions, I recommend vscode devcontainer)
Finally, do not use mos-unknown-none
target, use any platform provided by llvm-mos, like mos-sim-none
or mos-atari8-none
Oh yep, the samples work. I totally missed that those were available to look at. Thank you!
If core
is precompiled, would that result in larger binaries? Avoiding precompiled std
is a common way to reduce size, see e.g. https://github.com/johnthagen/min-sized-rust#optimize-libstd-with-build-std