-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add std flag #1266
Add std flag #1266
Conversation
@@ -48,7 +48,7 @@ | |||
compile_error!("'testutils' feature is not supported on 'wasm' target"); | |||
|
|||
// When used in a no_std contract, provide a panic handler as one is required. | |||
#[cfg(all(not(feature = "alloc"), target_family = "wasm"))] | |||
#[cfg(all(not(feature = "alloc"), not(feature = "std"), target_family = "wasm"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be breaking for someone, can't it? No-one would have the new feature enabled, so handle_panic
may disappear suddenly. Wouldn't it be safer to add a feature that disables handle_panic
on-demand?
There's a variety of situations that we could support, and so I'm not sure using 'std' as the name of this feature is most appropriate because of the possible variety of interpretations. Here's a matrix of configurations that could be supported. Only the two configurations with text in there are the ones currently supported. The text in the boxes is the feature enabled to get those things. Today we have:
If this PR is merged, the result would be support for:
If we wanted to support all these things, we could add the following features:
To that end, I think this PR's new feature could be named |
@heytdep Circling back onto this because we're doing some assessment if there's a need for std support with contracts that get deployed to chain. Most of std is stubbed on wasm targets, and we're currently exploring building contracts to a different wasm32 target that doesn't yet exist but @graydon is proposing. There's some details here, but it's possible the target won't ship with a std at all: Is the change in this PR so that libstd can be used with contracts and deployed on chain? What's the reason for doing that, or what's not available without it? |
@leighmcculloch sorry for seeing this late. I think this pr can be closed overall. The initial reason for this was because we're compiling the soroban sdk within the zephyr sdk (which compiles with std) to allow working with soroban types within you data flows (which works like a charm!). This pr was to enable that without having to rely on the allocator forced by the soroban sdk when the std flag was enabled, but we eventually decided that using the soroban-packed allocator is fine. Regarding the new target not compiling with std, that shouldn't be a problem assuming the sdk doesn't change and limits functionality depending on the target (so everything should be fine assuming we can still compile the current sdk functionality within an std-dependant zephyr program and target the current wasm target without the sdk locking features behind the new proposed target). I'm not advocating for std use on-chain (also because wasmi, especially when run onchain, is generally not suited for the memory-intensive tasks that the std would probably be used for) |
Thanks for returning to share more details on the use.
This is notable feedback. Admittedly not hearing feedback like this I would have likely put a compiler error into the sdk if used with the Thanks @heytdep. |
Great, thanks for taking this into account! Lmk if I can help on my end fwiw. I don't think limiting builds to |
What
Adds a new feature and disables allocator when std flag is set.
Why
Allows to use the std while having a custom allocator.
Known limitations
N/A