Skip to content

Cross architecture use of kernel snapshots doesn't match documentation #50644

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

Closed
maks opened this issue Dec 7, 2022 · 7 comments
Closed

Cross architecture use of kernel snapshots doesn't match documentation #50644

maks opened this issue Dec 7, 2022 · 7 comments
Labels
area-sdk Use area-sdk for general purpose SDK issues (packaging, distribution, …).

Comments

@maks
Copy link

maks commented Dec 7, 2022

According to the wiki documentation here compiling a kernel snapshot like so:

dart --snapshot-kind=kernel --snapshot=hello.dart.snapshot hello.dart

should produce a snapshot that is:

portable between CPU architectures.

Yet when I do the above on a x86 laptop:

 ~/apps/dart-sdk/bin/dart --version
Dart SDK version: 2.19.0-444.0.dev (dev) (Tue Nov 29 18:38:12 2022 -0800) on "linux_x64"
(HEAD)  ~/work/dart_snaps $ ~/apps/dart-sdk/bin/dart --snapshot=snaps.dart.dill bin/dart_snaps.dart 
Info: Compiling with sound null safety.

then copy across the resulting file and try to run it on a RISC-V D1, I get an error:

dart --version
Dart SDK version: 2.19.0-440.0.dev (dev) (Mon Nov 28 22:10:25 2022 -0800) on "linux_riscv64"
rv@licheerv:~/work$ dart snaps.dart.dill 
Can't load Kernel binary: Invalid SDK hash.

Note above that as far as I can see I am using the same version of the Dart SDK on both machines.

The reason I'm attempting to do this is due to #49253 being too slow to do Dart development on-device.

What I'd like to do is essentially replicate the Flutter development model of compiling snapshots on my (fast) development laptop and then copying them across and hot-reloading (or even hot-restarting) the snapshot on the (slow) RISC-V machine, but with a Dart cli application rather than Flutter.

@kevmoo kevmoo added the area-sdk Use area-sdk for general purpose SDK issues (packaging, distribution, …). label Dec 7, 2022
@rmacnak-google
Copy link
Contributor

It works for me:

$ ./dart-sdk-x64/bin/dart --version
Dart SDK version: 2.19.0-444.0.dev (dev) (Tue Nov 29 18:38:12 2022 -0800) on "linux_x64"
$ qemu-riscv64 -L /usr/riscv64-linux-gnu ./dart-sdk-rv64/bin/dart --version
Dart SDK version: 2.19.0-444.0.dev (dev) (Tue Nov 29 18:38:12 2022 -0800) on "linux_riscv64"
$ ./dart-sdk-x64/bin/dart --snapshot=x64.dill ~/hello.dart
Info: Compiling with sound null safety.
$ qemu-riscv64 -L /usr/riscv64-linux-gnu ./dart-sdk-rv64/bin/dart --snapshot=rv64.dill ~/hello.dart
Info: Compiling with sound null safety.
$ ./dart-sdk-x64/bin/dart x64.dill 
Hello, world!
$ ./dart-sdk-x64/bin/dart rv64.dill 
Hello, world!
$ qemu-riscv64 -L /usr/riscv64-linux-gnu ./dart-sdk-rv64/bin/dart x64.dill 
Hello, world!
$ qemu-riscv64 -L /usr/riscv64-linux-gnu ./dart-sdk-rv64/bin/dart rv64.dill 
Hello, world!

Are you sure you copied the right file to the D1? It's strange that your invocation of --version prints a different timestamp than mine.

@maks
Copy link
Author

maks commented Dec 8, 2022

My apologies, I just re-downloaded the SDK dev channel riscv64 zipfile from dart.dev and used it on my D1 board and it does work fine now and the timestamp in the version matches too:

Dart SDK version: 2.19.0-444.0.dev (dev) (Tue Nov 29 18:38:12 2022 -0800) on "linux_riscv64"

So I think I must have downloaded an earlier build of 2.19.0-444.0.dev initially for riscv64 and not realised it had been replaced with a newer one when I later on downloaded the x86 build zip file. I didn't realise that dev builds could have the same version number but be built at diff times and I guess hence the kernel versions dont match.

Also @rmacnak-google thanks for the tip to use qemu, that will make testing some things a bit easier vs needing to use my actual risc-v D1 devboard.

Sorry about the false alarm.

@maks maks closed this as completed Dec 8, 2022
@whesse
Copy link
Contributor

whesse commented Dec 8, 2022

This is the third time this week that someone has gotten confused over -444.0.dev and -440.0.dev, which
is quite understandable. I got mixed up by this also, earlier this week when making the release.
So this is just a common mistake on this particular release, because the numbers are so similar.

@maks
Copy link
Author

maks commented Dec 8, 2022

ah yes you are spot on @whesse ! I can't believe I posted here twice and didn't spot the difference in version numbers until you pointed it out! As you say they look so similar, its really easy to them confused.

@maks
Copy link
Author

maks commented Feb 13, 2023

@rmacnak-google apologies for posting on a closed issue, but I got a bit stuck trying to replicate the use of the Qemu commands in your prior comment. I'm not super familiar with Qemu, so I've learnt that you are using the user mode emulation of Qemu which I got installed on Ubuntu via the apt package qemu-user but I can't seem to find any docs on how to get the risc-v userspace libs which is what I assume is pointed to via your -L /usr/riscv64-linux-gnu parameter.
Would you have any pointers on how to get those risc-v libs or how you build them?
I tried digging through this repo here looking for CI recipes that might show me the way, but wasn't able to find where they live.

@rmacnak-google
Copy link
Contributor

I believe I got those through some transitive dependency of the g++-riscv64-linux-gnu package. So apt install qemu-user g++-riscv64-linux-gnu should be sufficient, thought there is a probably some more specific package that would be smaller.

@maks
Copy link
Author

maks commented Feb 14, 2023

perfect thanks again @rmacnak-google ! I've got it up and working now 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-sdk Use area-sdk for general purpose SDK issues (packaging, distribution, …).
Projects
None yet
Development

No branches or pull requests

4 participants