Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include precompiled core in rust-mos releases #19

Open
mrk-its opened this issue Jan 5, 2023 · 7 comments
Open

Include precompiled core in rust-mos releases #19

mrk-its opened this issue Jan 5, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@mrk-its
Copy link
Owner

mrk-its commented Jan 5, 2023

Currently we need to build core each time via unstable build-std featue

@mrk-its mrk-its added the enhancement New feature or request label Jan 5, 2023
@rrohrer
Copy link

rrohrer commented Mar 3, 2023

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.

@mrk-its
Copy link
Owner Author

mrk-its commented Mar 3, 2023 via email

@rrohrer
Copy link

rrohrer commented Mar 3, 2023

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

@mrk-its
Copy link
Owner Author

mrk-its commented Mar 3, 2023

thanks, trying to reproduce it locally

@mrk-its
Copy link
Owner Author

mrk-its commented Mar 3, 2023

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

@rrohrer
Copy link

rrohrer commented Mar 3, 2023

Oh yep, the samples work. I totally missed that those were available to look at. Thank you!

@mlund
Copy link

mlund commented Jul 2, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants