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

libs: add flatipc implementation #576

Merged
merged 4 commits into from
Sep 22, 2024
Merged

libs: add flatipc implementation #576

merged 4 commits into from
Sep 22, 2024

Conversation

xobs
Copy link
Member

@xobs xobs commented Sep 22, 2024

flatipc is a new method for doing IPC. This is a zero-copy approach where structs are given repr(C) implementations that are well-defined and work across process boundaries.

If the same struct or enum is used in two processes that has the same layout, then data can be freely passed between the two processes without incurring a serialization or deserialization penalty, provided the following hold:

  1. The buffer must be page-aligned and be a multiple of the page size
  2. The item must be #[repr(C)]
  3. There must be no pointers or references of any kind

If these three things hold, then the object is safe to sling across the process boundary.

This crate adds the ability to annotate structs with #[derive(flatipc::Ipc)] to provide them with this functionality. When doing so, objects gain the .into_ipc() call that turns them into something that can be sent across process boundaries.

The resulting object has .lend(), .lend_mut(), .try_lend(), and .try_lend_mut() as functions.

flatipc is a new method for doing IPC. This is a zero-copy approach
where structs are given `repr(C)` implementations that are well-defined
and work across process boundaries.

If the same struct or enum is used in two processes that has the same
layout, then data can be freely passed between the two processes without
incurring a serialization or deserialization penalty, provided the
following hold:

1. The buffer must be page-aligned and be a multiple of the page size
2. The item must be `#[repr(C)]`
3. There must be no pointers or references of any kind

If these three things hold, then the object is safe to sling across the
process boundary.

This crate adds the ability to annotate structs with
`#[derive(flatipc::Ipc)]` to provide them with this functionality. When
doing so, objects gain the `.into_ipc()` call that turns them into
something that can be sent across process boundaries.

The resulting object has `.lend()`, `.lend_mut()`, `.try_lend()`, and
`.try_lend_mut()` as functions.

Signed-off-by: Sean Cross <[email protected]>
@bunnie
Copy link
Member

bunnie commented Sep 22, 2024

is it easy for you to run cargo +nightly fmt on the patch so it can pass the format check?

@xobs
Copy link
Member Author

xobs commented Sep 22, 2024

Sure.

I initially ran that, and got a lot of changes. I backed those out and ran cargo +nightly fmt -p flatipc.

@bunnie
Copy link
Member

bunnie commented Sep 22, 2024

Super-weird. The patch still doesn't match up to the formatting. What version of Rust are you using?

@xobs
Copy link
Member Author

xobs commented Sep 22, 2024

My nightly version is rustc 1.83.0-nightly (9c01301c5 2024-09-05)

@bunnie
Copy link
Member

bunnie commented Sep 22, 2024

same here. Why would the results of cargo fmt differ? Is your rustfmt.toml modified from main? rustfmt should be deterministic across platforms.

These are required as this goes across the IPC boundary.

Signed-off-by: Sean Cross <[email protected]>
@xobs
Copy link
Member Author

xobs commented Sep 22, 2024

The errors are all in files that I didn't touch. Did they get missed in an earlier reformat?

I get the same diff when I run cargo +nightly fmt where most files require a reformat, which is why I added -p flatipc:

        modified:   apps/app-loader/src/api.rs
        modified:   apps/hello/src/main.rs
        modified:   apps/hidv2/src/main.rs
        modified:   apps/mtxchat/src/listen.rs
        modified:   apps/mtxcli/src/cmds/heap.rs
        modified:   apps/mtxcli/src/mtxcli.rs
        modified:   apps/repl/src/repl.rs
        modified:   apps/transientdisk/src/main.rs
        modified:   apps/vault/src/actions.rs
        modified:   apps/vault/src/main.rs
        modified:   apps/vault/src/prereqs.rs
        modified:   apps/vault/src/totp.rs
        modified:   apps/vault/src/ux/framework.rs
        modified:   apps/vault/src/vendor_commands.rs
        modified:   apps/vault/tools/vaultbackup-rs/src/authenticator.rs
        modified:   kernel/src/arch/arm/irq.rs
        modified:   kernel/src/arch/arm/mem.rs
        modified:   kernel/src/arch/arm/process.rs
        modified:   kernel/src/arch/hosted/mod.rs
        modified:   kernel/src/arch/hosted/process.rs
        modified:   kernel/src/arch/hosted/rand.rs
        modified:   kernel/src/arch/riscv/irq.rs
        modified:   kernel/src/arch/riscv/process.rs
        modified:   kernel/src/debug/gdb.rs
        modified:   kernel/src/debug/gdb/breakpoints.rs
        modified:   kernel/src/debug/gdb/multi_thread_base.rs
        modified:   kernel/src/debug/gdb/riscv.rs
        modified:   kernel/src/debug/gdb/target.rs
        modified:   kernel/src/platform/atsama5d2/aic.rs
        modified:   kernel/src/platform/atsama5d2/uart.rs
        modified:   kernel/src/platform/cramium/rand.rs
        modified:   kernel/src/platform/cramium/uart.rs
        modified:   kernel/src/platform/precursor/gdbuart.rs
        modified:   kernel/src/platform/precursor/uart.rs
        modified:   kernel/src/services.rs
        modified:   kernel/src/swap.rs
        modified:   kernel/src/test.rs
        modified:   libs/chat/src/icontray.rs
        modified:   libs/chat/src/lib.rs
        modified:   libs/chat/src/main.rs
        modified:   libs/chat/src/ui.rs
        modified:   libs/cramium-hal/src/ifram.rs
        modified:   libs/cramium-hal/src/usb/driver.rs
        modified:   libs/flatipc-derive/src/lib.rs
        modified:   libs/flatipc/src/lib.rs
        modified:   libs/perflib/src/lib.rs
        modified:   libs/tls/src/danger.rs
        modified:   libs/tls/src/lib.rs
        modified:   libs/userprefs/prefsgenerator/src/lib.rs
        modified:   loader/src/main.rs
        modified:   loader/src/minielf.rs
        modified:   loader/src/phase1.rs
        modified:   loader/src/platform/atsama5d27/boot.rs
        modified:   loader/src/platform/atsama5d27/debug.rs
        modified:   loader/src/platform/atsama5d27/load.rs
        modified:   loader/src/platform/cramium/swap.rs
        modified:   loader/src/secboot.rs
        modified:   loader/src/test.rs
        modified:   services/aes/src/lib.rs
        modified:   services/aes/src/soft.rs
        modified:   services/aes/src/soft/fixslice32.rs
        modified:   services/aes/src/vex.rs
        modified:   services/codec/src/backend/tlv320aic3100.rs
        modified:   services/codec/src/lib.rs
        modified:   services/codec/src/main.rs
        modified:   services/com/src/lib.rs
        modified:   services/com/src/main.rs
        modified:   services/content-plugin-api/src/lib.rs
        modified:   services/cram-console/src/appmenu.rs
        modified:   services/cram-console/src/cmds/pddb_cmd.rs
        modified:   services/cram-console/src/main.rs
        modified:   services/cram-console/src/repl.rs
        modified:   services/cram-console/src/shell.rs
        modified:   services/cram-hal-service/src/hw/keyboard.rs
        modified:   services/cram-hal-service/src/iox_lib.rs
        modified:   services/cram-hal-service/src/keyboard.rs
        modified:   services/cram-hal-service/src/main.rs
        modified:   services/dns/src/time.rs
        modified:   services/early_settings/src/lib.rs
        modified:   services/early_settings/src/main.rs
        modified:   services/ffi-test/src/bindings.rs
        modified:   services/gam/src/bitmap.rs
        modified:   services/gam/src/bitmap/decode_png.rs
        modified:   services/gam/src/bitmap/dither.rs
        modified:   services/gam/src/layouts/menu.rs
        modified:   services/gam/src/layouts/modal.rs
        modified:   services/gam/src/lib.rs
        modified:   services/gam/src/menu.rs
        modified:   services/gam/src/modal.rs
        modified:   services/graphics-server/src/api/blitstr2/cursor.rs
        modified:   services/graphics-server/src/backend/minifb.rs
        modified:   services/graphics-server/src/blitstr2/blit.rs
        modified:   services/graphics-server/src/lib.rs
        modified:   services/graphics-server/src/main.rs
        modified:   services/graphics-server/src/wordwrap.rs
        modified:   services/ime-frontend/src/main.rs
        modified:   services/ime-plugin-api/src/lib.rs
        modified:   services/jtag/src/lib.rs
        modified:   services/keyboard/src/lib.rs
        modified:   services/keyboard/src/main.rs
        modified:   services/llio/src/i2c/hardware.rs
        modified:   services/llio/src/i2c/hosted.rs
        modified:   services/llio/src/llio_lib.rs
        modified:   services/llio/src/main.rs
        modified:   services/modals/src/api.rs
        modified:   services/modals/src/lib.rs
        modified:   services/modals/src/main.rs
        modified:   services/net/src/connection_manager.rs
        modified:   services/net/src/device.rs
        modified:   services/net/src/lib.rs
        modified:   services/net/src/main.rs
        modified:   services/net/src/protocols/dns.rs
        modified:   services/net/src/protocols/ping.rs
        modified:   services/net/src/std_tcplistener.rs
        modified:   services/net/src/std_udp.rs
        modified:   services/pddb/src/backend/basis.rs
        modified:   services/pddb/src/backend/dictionary.rs
        modified:   services/pddb/src/backend/hosted.rs
        modified:   services/pddb/src/backend/hw.rs
        modified:   services/pddb/src/backend/pagetable.rs
        modified:   services/pddb/src/frontend/pddbkey.rs
        modified:   services/pddb/src/lib.rs
        modified:   services/pddb/src/libstd/mod.rs
        modified:   services/pddb/src/main.rs
        modified:   services/pddb/src/tests.rs
        modified:   services/root-keys/src/backups.rs
        modified:   services/root-keys/src/implementation.rs
        modified:   services/root-keys/src/implementation/keywrap.rs
        modified:   services/root-keys/src/implementation/oracle.rs
        modified:   services/root-keys/src/lib.rs
        modified:   services/root-keys/src/main.rs
        modified:   services/root-keys/src/sha512_digest.rs
        modified:   services/shellchat/src/cmds/aes_cmd.rs
        modified:   services/shellchat/src/cmds/net_cmd.rs
        modified:   services/shellchat/src/cmds/pddb_cmd.rs
        modified:   services/shellchat/src/cmds/test.rs
        modified:   services/shellchat/src/cmds/trng_cmd.rs
        modified:   services/shellchat/src/main.rs
        modified:   services/spinor/src/lib.rs
        modified:   services/status/src/appmenu.rs
        modified:   services/status/src/main.rs
        modified:   services/trng/src/lib.rs
        modified:   services/trng/src/main.rs
        modified:   services/tts/src/lib.rs
        modified:   services/tts/src/main.rs
        modified:   services/usb-device-xous/src/hid.rs
        modified:   services/usb-device-xous/src/hw.rs
        modified:   services/usb-device-xous/src/lib.rs
        modified:   services/usb-device-xous/src/main.rs
        modified:   services/usb-device-xous/src/main_hw.rs
        modified:   services/usb-test/src/hw.rs
        modified:   services/usb-test/src/main.rs
        modified:   services/xous-log/src/platform/atsama5d2/console.rs
        modified:   services/xous-log/src/platform/hosted/implementation.rs
        modified:   services/xous-names/src/main.rs
        modified:   services/xous-susres/Cargo.toml
        modified:   services/xous-susres/src/main.rs
        modified:   services/xous-swapper/src/main.rs
        modified:   services/xous-swapper/src/platform/cramium/hw.rs
        modified:   services/xous-swapper/src/platform/precursor/hw.rs
        modified:   svd2repl/src/generate.rs
        modified:   svd2utra/src/generate.rs
        modified:   tools/src/bin/create-image.rs
        modified:   tools/src/bin/make-renode-boot.rs
        modified:   tools/src/bin/read-tags.rs
        modified:   tools/src/bin/sign-image.rs
        modified:   tools/src/elf.rs
        modified:   tools/src/sign_image.rs
        modified:   tools/src/swap_writer.rs
        modified:   tools/src/utils.rs
        modified:   tools/src/xous_arguments.rs
        modified:   tools/wycheproof-import/src/main.rs
        modified:   xous-ipc/src/buffer.rs
        modified:   xous-ipc/src/string.rs
        modified:   xous-rs/src/arch/arm/mod.rs
        modified:   xous-rs/src/arch/hosted/mem.rs
        modified:   xous-rs/src/arch/test/mem.rs
        modified:   xous-rs/src/arch/test/mod.rs
        modified:   xous-rs/src/carton.rs
        modified:   xous-rs/src/stringbuffer.rs
        modified:   xous-rs/src/syscall.rs
        modified:   xtask/src/builder.rs
        modified:   xtask/src/main.rs
        modified:   xtask/src/utils.rs
        modified:   xtask/src/verifier.rs

Did you want me to reformat everything?

@bunnie
Copy link
Member

bunnie commented Sep 22, 2024

The latest main should already be formatted: fd0eaaa shows it passes all the format checks.

strange...

@bunnie
Copy link
Member

bunnie commented Sep 22, 2024

Really strange. I pull down your branch and check the formatting locally and it passes. Maybe it's something wrong with the CI runner.

@bunnie
Copy link
Member

bunnie commented Sep 22, 2024

Well, if you're good with the patch, we can go ahead and merge it and see what happens. I can't see why the CI is breaking, but, your patches are formatted correctly when I check it locally.

@xobs
Copy link
Member Author

xobs commented Sep 22, 2024

It's not formatted for me -- I get the same errors as the CI runner:

[7:35:04 pm] E:/Code/Xous/Core> git stash
Saved working directory and index state WIP on xobs/add-flatipc: 3eb54d2cc flatipc: add more checks to vec and string
[7:44:31 pm] E:/Code/Xous/Core> git fetch origin
remote: Enumerating objects: 478, done.
remote: Counting objects: 100% (478/478), done.
remote: Compressing objects: 100% (145/145), done.
remote: Total 478 (delta 331), reused 472 (delta 325), pack-reused 0 (from 0)
Receiving objects: 100% (478/478), 183.04 KiB | 386.00 KiB/s, done.
Resolving deltas: 100% (331/331), completed with 185 local objects.
From github.com:betrusted-io/xous-core
 * [new branch]          rkyv-0.8-migration -> origin/rkyv-0.8-migration
[7:44:39 pm] E:/Code/Xous/Core> git checkout origin/main
Note: switching to 'origin/main'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at fd0eaaade Merge pull request #573 from betrusted-io/rkyv-0.8
[7:44:42 pm] E:/Code/Xous/Core> cargo +nightly fmt
warning: both `E:\Code\Xous\Core\.cargo\config` and `E:\Code\Xous\Core\.cargo\config.toml` exist. Using `E:\Code\Xous\Core\.cargo\config`
warning: both `E:\Code\Xous\Core\.cargo\config` and `E:\Code\Xous\Core\.cargo\config.toml` exist. Using `E:\Code\Xous\Core\.cargo\config`
warning: both `E:\Code\Xous\Core\.cargo\config` and `E:\Code\Xous\Core\.cargo\config.toml` exist. Using `E:\Code\Xous\Core\.cargo\config`
error: could not load Cargo configuration

Caused by:
  could not parse TOML configuration in `E:\Code\Xous\Core\.cargo\config`

Caused by:
  TOML parse error at line 1, column 12
    |
  1 | config.toml
    |            ^
  expected `.`, `=`
[7:44:46 pm] E:/Code/Xous/Core> rm .\.cargo\config
[7:44:49 pm] E:/Code/Xous/Core> cargo +nightly fmt
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
Warning: the `version` option is deprecated. Use `style_edition` instead.
[7:44:54 pm] E:/Code/Xous/Core> cargo +nightly fmt ^C
[7:44:56 pm] E:/Code/Xous/Core> git status
HEAD detached at origin/main
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    .cargo/config
        modified:   apps/app-loader/src/api.rs
        modified:   apps/hello/src/main.rs
        modified:   apps/hidv2/src/main.rs
        modified:   apps/mtxchat/src/listen.rs
        modified:   apps/mtxcli/src/cmds/heap.rs
        modified:   apps/mtxcli/src/mtxcli.rs
        modified:   apps/repl/src/repl.rs
        modified:   apps/transientdisk/src/main.rs
        modified:   apps/vault/src/actions.rs
        modified:   apps/vault/src/main.rs
        modified:   apps/vault/src/prereqs.rs
        modified:   apps/vault/src/totp.rs
        modified:   apps/vault/src/ux/framework.rs
        modified:   apps/vault/src/vendor_commands.rs
        modified:   apps/vault/tools/vaultbackup-rs/src/authenticator.rs
        modified:   kernel/src/arch/arm/irq.rs
        modified:   kernel/src/arch/arm/mem.rs
        modified:   kernel/src/arch/arm/process.rs
        modified:   kernel/src/arch/hosted/mod.rs
        modified:   kernel/src/arch/hosted/process.rs
        modified:   kernel/src/arch/hosted/rand.rs
        modified:   kernel/src/arch/riscv/irq.rs
        modified:   kernel/src/arch/riscv/process.rs
        modified:   kernel/src/debug/gdb.rs
        modified:   kernel/src/debug/gdb/breakpoints.rs
        modified:   kernel/src/debug/gdb/multi_thread_base.rs
        modified:   kernel/src/debug/gdb/riscv.rs
        modified:   kernel/src/debug/gdb/target.rs
        modified:   kernel/src/platform/atsama5d2/aic.rs
        modified:   kernel/src/platform/atsama5d2/uart.rs
        modified:   kernel/src/platform/cramium/rand.rs
        modified:   kernel/src/platform/cramium/uart.rs
        modified:   kernel/src/platform/precursor/gdbuart.rs
        modified:   kernel/src/platform/precursor/uart.rs
        modified:   kernel/src/services.rs
        modified:   kernel/src/swap.rs
        modified:   kernel/src/test.rs
        modified:   libs/chat/src/icontray.rs
        modified:   libs/chat/src/lib.rs
        modified:   libs/chat/src/main.rs
        modified:   libs/chat/src/ui.rs
        modified:   libs/cramium-hal/src/ifram.rs
        modified:   libs/cramium-hal/src/usb/driver.rs
        modified:   libs/perflib/src/lib.rs
        modified:   libs/tls/src/danger.rs
        modified:   libs/tls/src/lib.rs
        modified:   libs/userprefs/prefsgenerator/src/lib.rs
        modified:   loader/src/main.rs
        modified:   loader/src/minielf.rs
        modified:   loader/src/phase1.rs
        modified:   loader/src/platform/atsama5d27/boot.rs
        modified:   loader/src/platform/atsama5d27/debug.rs
        modified:   loader/src/platform/atsama5d27/load.rs
        modified:   loader/src/platform/cramium/swap.rs
        modified:   loader/src/secboot.rs
        modified:   loader/src/test.rs
        modified:   services/aes/src/lib.rs
        modified:   services/aes/src/soft.rs
        modified:   services/aes/src/soft/fixslice32.rs
        modified:   services/aes/src/vex.rs
        modified:   services/codec/src/backend/tlv320aic3100.rs
        modified:   services/codec/src/lib.rs
        modified:   services/codec/src/main.rs
        modified:   services/com/src/lib.rs
        modified:   services/com/src/main.rs
        modified:   services/content-plugin-api/src/lib.rs
        modified:   services/cram-console/src/appmenu.rs
        modified:   services/cram-console/src/cmds/pddb_cmd.rs
        modified:   services/cram-console/src/main.rs
        modified:   services/cram-console/src/repl.rs
        modified:   services/cram-console/src/shell.rs
        modified:   services/cram-hal-service/src/hw/keyboard.rs
        modified:   services/cram-hal-service/src/iox_lib.rs
        modified:   services/cram-hal-service/src/keyboard.rs
        modified:   services/cram-hal-service/src/main.rs
        modified:   services/dns/src/time.rs
        modified:   services/early_settings/src/lib.rs
        modified:   services/early_settings/src/main.rs
        modified:   services/ffi-test/src/bindings.rs
        modified:   services/gam/src/bitmap.rs
        modified:   services/gam/src/bitmap/decode_png.rs
        modified:   services/gam/src/bitmap/dither.rs
        modified:   services/gam/src/layouts/menu.rs
        modified:   services/gam/src/layouts/modal.rs
        modified:   services/gam/src/lib.rs
        modified:   services/gam/src/menu.rs
        modified:   services/gam/src/modal.rs
        modified:   services/graphics-server/src/api/blitstr2/cursor.rs
        modified:   services/graphics-server/src/backend/minifb.rs
        modified:   services/graphics-server/src/blitstr2/blit.rs
        modified:   services/graphics-server/src/lib.rs
        modified:   services/graphics-server/src/main.rs
        modified:   services/graphics-server/src/wordwrap.rs
        modified:   services/ime-frontend/src/main.rs
        modified:   services/ime-plugin-api/src/lib.rs
        modified:   services/jtag/src/lib.rs
        modified:   services/keyboard/src/lib.rs
        modified:   services/keyboard/src/main.rs
        modified:   services/llio/src/i2c/hardware.rs
        modified:   services/llio/src/i2c/hosted.rs
        modified:   services/llio/src/llio_lib.rs
        modified:   services/llio/src/main.rs
        modified:   services/modals/src/api.rs
        modified:   services/modals/src/lib.rs
        modified:   services/modals/src/main.rs
        modified:   services/net/src/connection_manager.rs
        modified:   services/net/src/device.rs
        modified:   services/net/src/lib.rs
        modified:   services/net/src/main.rs
        modified:   services/net/src/protocols/dns.rs
        modified:   services/net/src/protocols/ping.rs
        modified:   services/net/src/std_tcplistener.rs
        modified:   services/net/src/std_udp.rs
        modified:   services/pddb/src/backend/basis.rs
        modified:   services/pddb/src/backend/dictionary.rs
        modified:   services/pddb/src/backend/hosted.rs
        modified:   services/pddb/src/backend/hw.rs
        modified:   services/pddb/src/backend/pagetable.rs
        modified:   services/pddb/src/frontend/pddbkey.rs
        modified:   services/pddb/src/lib.rs
        modified:   services/pddb/src/libstd/mod.rs
        modified:   services/pddb/src/main.rs
        modified:   services/pddb/src/tests.rs
        modified:   services/root-keys/src/backups.rs
        modified:   services/root-keys/src/implementation.rs
        modified:   services/root-keys/src/implementation/keywrap.rs
        modified:   services/root-keys/src/implementation/oracle.rs
        modified:   services/root-keys/src/lib.rs
        modified:   services/root-keys/src/main.rs
        modified:   services/root-keys/src/sha512_digest.rs
        modified:   services/shellchat/src/cmds/aes_cmd.rs
        modified:   services/shellchat/src/cmds/net_cmd.rs
        modified:   services/shellchat/src/cmds/pddb_cmd.rs
        modified:   services/shellchat/src/cmds/test.rs
        modified:   services/shellchat/src/cmds/trng_cmd.rs
        modified:   services/shellchat/src/main.rs
        modified:   services/spinor/src/lib.rs
        modified:   services/status/src/appmenu.rs
        modified:   services/status/src/main.rs
        modified:   services/trng/src/lib.rs
        modified:   services/trng/src/main.rs
        modified:   services/tts/src/lib.rs
        modified:   services/tts/src/main.rs
        modified:   services/usb-device-xous/src/hid.rs
        modified:   services/usb-device-xous/src/hw.rs
        modified:   services/usb-device-xous/src/lib.rs
        modified:   services/usb-device-xous/src/main.rs
        modified:   services/usb-device-xous/src/main_hw.rs
        modified:   services/usb-test/src/hw.rs
        modified:   services/usb-test/src/main.rs
        modified:   services/xous-log/src/platform/atsama5d2/console.rs
        modified:   services/xous-log/src/platform/hosted/implementation.rs
        modified:   services/xous-names/src/main.rs
        modified:   services/xous-susres/src/main.rs
        modified:   services/xous-swapper/src/main.rs
        modified:   services/xous-swapper/src/platform/cramium/hw.rs
        modified:   services/xous-swapper/src/platform/precursor/hw.rs
        modified:   svd2repl/src/generate.rs
        modified:   svd2utra/src/generate.rs
        modified:   tools/src/bin/create-image.rs
        modified:   tools/src/bin/make-renode-boot.rs
        modified:   tools/src/bin/read-tags.rs
        modified:   tools/src/bin/sign-image.rs
        modified:   tools/src/elf.rs
        modified:   tools/src/sign_image.rs
        modified:   tools/src/swap_writer.rs
        modified:   tools/src/utils.rs
        modified:   tools/src/xous_arguments.rs
        modified:   tools/wycheproof-import/src/main.rs
        modified:   xous-ipc/src/buffer.rs
        modified:   xous-ipc/src/string.rs
        modified:   xous-rs/src/arch/arm/mod.rs
        modified:   xous-rs/src/arch/hosted/mem.rs
        modified:   xous-rs/src/arch/test/mem.rs
        modified:   xous-rs/src/arch/test/mod.rs
        modified:   xous-rs/src/carton.rs
        modified:   xous-rs/src/stringbuffer.rs
        modified:   xous-rs/src/syscall.rs
        modified:   xtask/src/builder.rs
        modified:   xtask/src/main.rs
        modified:   xtask/src/utils.rs
        modified:   xtask/src/verifier.rs

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        atom-test
        emulation/betrusted.py
        emulation/emulation.sln
        emulation/log-stuff.resc
        emulation/peripherals/LoggingMemory.cs
        emulation/peripherals/SpinalUsbDevice.cs
        emulation/xous-bughunt.resc
        renode-crash/
        std-tests

no changes added to commit (use "git add" and/or "git commit -a")
[7:44:58 pm] E:/Code/Xous/Core>

@xobs
Copy link
Member Author

xobs commented Sep 22, 2024

I've crated #577 that should make the check happy once I rebase on top of that change.

@bunnie
Copy link
Member

bunnie commented Sep 22, 2024

Weird, I tried running the command on windows and I get a clean format. My tree is up to date with main as well. I wonder what's up....

@bunnie
Copy link
Member

bunnie commented Sep 22, 2024

I think I'm using a later version of nightly than what you're using...

rustc 1.83.0-nightly (04a318787 2024-09-15)

I wonder if they broke things in your nightly and reverted it?

@xobs
Copy link
Member Author

xobs commented Sep 22, 2024

My rustfmt is rustfmt 1.8.0-nightly (1d68e6dd1d 2024-09-21) and I imagine the builders are also using the latest nightly since they do a from-scratch install every time.

I believe this is what's happened:

  1. We were using version = "Two", which selected an unstable formatting version which was to define the formatting for the 2024 edition -- the default was version = "One"
  2. The version config was deprecated in favour of style_edition
  3. version = "Two" became style_edition = "2024" and version = "One" is now equivalent to style_edition = "2021", style_edition = "2018", or style_edition = "2015
  4. As they're still working on the rules for 2024, they've added sorting on import statements

So the root cause is relying on a set of formatting rules that are still in flux, and they changed.

@bunnie
Copy link
Member

bunnie commented Sep 22, 2024

OK, we'll fix formatting in a separate patch then. We definitely don't need to surf the latest edition when it comes to formatting, so, we can go to style_edition "2021 and make things more stable.

And also I definitely don't want to do a huge format pull in the middle of a big rebase for xous_ipc, that'll be really painful because I've changed a lot of dependencies to remove xous_ipc, so let's just absorb the patch with broken CI results if you think you're done with the substance of the patch.

Kind of irritating that Rust doesn't allow some of the more basic shit like width of code to be stabilized, and just subjects everyone to tyranny if they don't go with the One True Way for formatting.

@bunnie bunnie merged commit 3ce9ae8 into main Sep 22, 2024
1 of 2 checks passed
@bunnie bunnie deleted the xobs/add-flatipc branch September 22, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants