Skip to content

Improve allocators set up#140

Closed
febo wants to merge 4 commits into
mainfrom
febo/static-allocator
Closed

Improve allocators set up#140
febo wants to merge 4 commits into
mainfrom
febo/static-allocator

Conversation

@febo
Copy link
Copy Markdown
Collaborator

@febo febo commented Apr 22, 2025

Problem

Currently, the "fallback" panic handler and allocator set up creates different problems when using cargo test or cargo test-sbf. This happens since tests in general depend on the std and therefore create a conflict when the fallback tries to set up a panic handler or global allocator.

Solution

This PR improves the set up of the fallbacks by simply linking the std library instead of trying to set them up, avoiding conflicts if another library links the std. Note that the std is only linked in targets different than "solana", so no_std programs are not affected.

It also addresses a couple of comments from #136:

  • deprecate entrypoint macro in favour of entrypoint_with_allocator_and_panic_handler
  • deprecate no_allocator macro in favour of static_allocator
  • remove the need for feature(const_mut_refs)

cc: @publicqi

@febo febo requested a review from joncinque April 22, 2025 09:41
@febo febo force-pushed the febo/static-allocator branch from 012d4ae to fada003 Compare April 22, 2025 09:43
Copy link
Copy Markdown
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks great! I'm a big fan of the lengthy and clear comments.

Just a tiny nit

Comment thread sdk/pinocchio/src/entrypoint/mod.rs Outdated
Comment thread sdk/pinocchio/src/entrypoint/mod.rs Outdated
@febo febo requested a review from joncinque April 23, 2025 01:21
@febo
Copy link
Copy Markdown
Collaborator Author

febo commented Apr 29, 2025

The refactoring for the static_allocator will be added to a separate crate.

@febo febo closed this Apr 29, 2025
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