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

Automatic adaption to 64bit architectures in guest code #1163

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cpetig
Copy link

@cpetig cpetig commented Feb 11, 2025

No description provided.

@pavelsavara
Copy link
Collaborator

cc @jsturtevant for C#

@cpetig
Copy link
Author

cpetig commented Feb 11, 2025

Sorry for the extensive patch, basically this changes the Rust and C code generation (in this case passing a list) to

#[cfg_attr(target_pointer_width = "64", repr(align(8)))]
#[cfg_attr(target_pointer_width = "32", repr(align(4)))]
struct RetArea(
    [::core::mem::MaybeUninit<u8>; 2 * core::mem::size_of::<*const u8>()],
);
let mut ret_area = RetArea(
    [::core::mem::MaybeUninit::uninit(); 2 * core::mem::size_of::<*const u8>()],
);

*base.add(core::mem::size_of::<*const u8>()).cast::<usize>() = len0;
*base.add(0).cast::<*mut u8>() = ptr0.cast_mut();

@cpetig
Copy link
Author

cpetig commented Feb 11, 2025

cc @jsturtevant for C#

I wasn't able to output the proper code for C# because I don't know enough of it, but Rust or C should give a good template.

@cpetig
Copy link
Author

cpetig commented Feb 11, 2025

The publish test will be fixed by the next wasm-tools release (blocked there)

@cpetig
Copy link
Author

cpetig commented Feb 11, 2025

Also part of #1098

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks great to me, thanks! I'll work on getting a wasm-tools release out next week in order to merge this.

@alexcrichton
Copy link
Member

The wasm-tools update is at bytecodealliance/wasm-tools#2054 which is coupled with some extra testing in Wasmtime. I also want to do some more testing in this repository before publishing to ensure that not too much is broken here.

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.

3 participants