Repository navigation
targets: add default malloc wrappers for esp32 and esp32s3 - #6852
Draft
davecheney wants to merge 1 commit into
Draft
davecheney wants to merge 1 commit into
davecheney wants to merge 1 commit into
Conversation
tinygo-org#5283 and tinygo-org#5510 added --wrap=malloc, --wrap=calloc, --wrap=realloc and --wrap=free to the esp32s3 and esp32 linker flags, for espradio. Only espradio defined __wrap_malloc and the other three wrappers. Without espradio, a program with C code that called malloc did not link, and ld.lld reported "undefined symbol: __wrap_malloc". tinyfs/fatfs is one such program. With this change, weak __wrap_malloc, __wrap_calloc, __wrap_realloc and __wrap_free call the __real_ functions, which are the TinyGo allocator. The strong wrappers in espradio replace them when espradio is linked.
Member
|
@davecheney I did not test on hardware, all I did was build for xiao-esp32s3 and esp32-coreboard-v2. Here are the comments from the machine: A cgo program that calls |
Contributor
Author
|
Let me check again, I had this in my queue for a while and a lot has changed. |
davecheney
marked this pull request as draft
December 5, 2026 23:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#5283 and #5510 added --wrap=malloc, --wrap=calloc, --wrap=realloc and --wrap=free to the esp32s3 and esp32 linker flags, for espradio. Only espradio defined __wrap_malloc and the other three wrappers. Without espradio, a program with C code that called malloc did not link, and ld.lld reported "undefined symbol: __wrap_malloc". tinyfs/fatfs is one such program.
With this change, weak __wrap_malloc, __wrap_calloc, __wrap_realloc and __wrap_free call the _real functions, which are the TinyGo allocator. The strong wrappers in espradio replace them when espradio is linked.