sdk: ship kernel/compiler.h and retire raw __attribute__/__builtin_ uses - #2098
Merged
Merged
Conversation
gmarull
marked this pull request as draft
September 17, 2026 13:36
gmarull
force-pushed
the
sdk-compiler-h
branch
2 times, most recently
from
September 17, 2026 13:42
4c14eaf to
198b49b
Compare
gmarull
marked this pull request as ready for review
September 17, 2026 13:43
jplexer
approved these changes
Sep 17, 2026
The SDK generator copies exported declarations verbatim into pebble.h, so any PBL_* attribute macro used in an exported header reached apps undefined; exported headers worked around it with raw __attribute__, and SpeakerNote did not (pebble.h carried "typedef struct PACKED" with no definition). Copy compiler.h and its backends into the SDK include tree and include it from pebble.h/pebble_worker.h, so exported headers can use the same macros as the rest of the tree. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Convert every remaining direct use to the pbl/kernel/compiler.h macro, including the headers exported into the SDK now that pebble.h includes the same header. __builtin_strchr in log_hashing.h becomes plain strchr, which GCC folds identically for constant arguments. golf drops its private UNUSED for PBL_UNUSED. The vendored DUMA under tests/vendor and the libclang fake libc are left alone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
The builtin resource table and the app-side appinfo.c were the last generated C carrying raw __attribute__. Both consumers now see pbl/kernel/compiler.h (the firmware directly, apps through pebble.h), so emit PBL_ALIGNED()/PBL_SECTION() instead and refresh the checked-in fixture accordingly. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
gmarull
force-pushed
the
sdk-compiler-h
branch
from
September 22, 2026 08:31
198b49b to
3fc4098
Compare
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.
Follow-up to #2094 (now merged; rebased onto main).
Summary
pbl/kernel/compiler.hwith the SDK. The generator copies exported declarations verbatim intopebble.h, so anyPBL_*macro in an exported header reached apps undefined — exported headers worked around it with raw__attribute__, andSpeakerNotedidn't (pebble.honmaincarriestypedef struct PACKEDwith no definition).compiler.h+ backends are now copied intosdk/<platform>/include/pbl/kernel/and included frompebble.h/pebble_worker.h, via bothgenerate_pebble_native_sdk_files.py(firmware build) andbuild_sdk.py.__attribute__/__builtin_*use in the tree with thecompiler.hmacros, including exported applib headers andpebble_process_info.h.__builtin_strchrinlog_hashing.hbecomes plainstrchr(GCC folds it identically; verified below).golfdrops its privateUNUSED. Vendored DUMA and the libclang fake libc are left alone.tools/resources/generators.py,tools/generate_appinfo.py) emitPBL_ALIGNED()/PBL_SECTION(); the checked-inbuiltin_resources.auto.cfixture is refreshed.Verification
pbl test333/333.strchrswap is codegen-neutral).build/sdk/wafagainst the packaged flint SDK, usingSpeakerNote, aPBL_PACKEDstruct with a_Static_asserton its size, andPBL_UNUSED;appinfo.auto.ccomes out withPBL_SECTION(".pbl_header")and the section lands in the object as before.🤖 Generated with Claude Code