Add native Portduino malloc shim#10677
Open
h3lix1 wants to merge 8 commits into
Open
Conversation
Contributor
|
@h3lix1 looks good. You still have it in draft for a reason? |
Contributor
⚡ Try this PR in the Web FlasherWarning This is an automated, unreviewed CI test build. Back up your device configuration Supported boards built by this PR (21)
Build artifacts expire on 2026-07-10. Updated for |
Contributor
Firmware Size Report22 targets | vs
Show 17 more target(s)
Updated for be211ba |
thebentern
approved these changes
Jun 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Portduino-local malloc.h compatibility shim so native macOS (Darwin) builds can compile code that includes the Linux header name <malloc.h>, by redirecting to Darwin’s <malloc/malloc.h> and providing a memalign() implementation.
Changes:
- Introduces
variants/native/portduino/malloc.hto satisfy<malloc.h>includes in native Portduino builds. - On
__APPLE__, includes<malloc/malloc.h>/<stdlib.h>and implementsmemalign()viaposix_memalign(). - On non-Apple platforms, defers to the real system
<malloc.h>via#include_next.
Honestly I don't think it matters that much, but if it makes copilot happy, return ret if something weird happens. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
@thebentern will need a re-approval after applying the thing copilot recommended. |
thebentern
approved these changes
Jun 12, 2026
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.
Add Darwin
malloc.hShim For PortduinoBranch:
codex/native-portduino-malloc-shimTarget:
meshtastic/firmware:developWhy
Some native macOS build paths encounter code that includes
<malloc.h>, which is a Linux header name. On Darwin, the equivalent allocator declarations live in<malloc/malloc.h>, andmemalign()is not provided directly.What
This adds a small Portduino-local compatibility header:
<malloc/malloc.h>and<stdlib.h>.memalign()throughposix_memalign().<malloc.h>withinclude_next.The file is scoped to
variants/native/portduino, so firmware targets and Linux native builds keep their existing behavior.How
flowchart LR LGFX["Code includes <malloc.h>"] --> Shim["variants/native/portduino/malloc.h"] Shim --> Apple{"__APPLE__?"} Apple -->|yes| Darwin["malloc/malloc.h + posix_memalign"] Apple -->|no| Native["include_next <malloc.h>"]Validation
trunk fmt variants/native/portduino/malloc.h~/.platformio/penv/bin/platformio run -e native-macosThe native build progressed past the original
<malloc.h>failure.Test Notes
No unit test is needed for this header shim. The useful check is a macOS native build in an environment with the documented native prerequisites installed.