Skip to content

sdk: ship kernel/compiler.h and retire raw __attribute__/__builtin_ uses - #2098

Merged
gmarull merged 3 commits into
coredevices:mainfrom
teslabs:sdk-compiler-h
Sep 22, 2026
Merged

gmarull merged 3 commits into
coredevices:mainfrom
teslabs:sdk-compiler-h

Conversation

@gmarull

@gmarull gmarull commented Sep 17, 2026

Copy link
Copy Markdown
Member

Follow-up to #2094 (now merged; rebased onto main).

Summary

  • Ship pbl/kernel/compiler.h with the SDK. The generator copies exported declarations verbatim into pebble.h, so any PBL_* macro in an exported header reached apps undefined — exported headers worked around it with raw __attribute__, and SpeakerNote didn't (pebble.h on main carries typedef struct PACKED with no definition). compiler.h + backends are now copied into sdk/<platform>/include/pbl/kernel/ and included from pebble.h/pebble_worker.h, via both generate_pebble_native_sdk_files.py (firmware build) and build_sdk.py.
  • Replace every remaining raw __attribute__/__builtin_* use in the tree with the compiler.h macros, including exported applib headers and pebble_process_info.h. __builtin_strchr in log_hashing.h becomes plain strchr (GCC folds it identically; verified below). golf drops its private UNUSED. Vendored DUMA and the libclang fake libc are left alone.
  • Generators (tools/resources/generators.py, tools/generate_appinfo.py) emit PBL_ALIGNED()/PBL_SECTION(); the checked-in builtin_resources.auto.c fixture is refreshed.

Verification

  • asterix, gabbro, obelix, getafix build warning-free; pbl test 333/333.
  • Per-symbol size comparison against the kernel: add compiler.h, retire util/attributes.h and util/likely.h #2094 tip on asterix and getafix: identical (so the strchr swap is codegen-neutral).
  • A template app built with build/sdk/waf against the packaged flint SDK, using SpeakerNote, a PBL_PACKED struct with a _Static_assert on its size, and PBL_UNUSED; appinfo.auto.c comes out with PBL_SECTION(".pbl_header") and the section lands in the object as before.

🤖 Generated with Claude Code

@gmarull
gmarull requested a review from jplexer as a code owner September 17, 2026 13:25
@gmarull
gmarull marked this pull request as draft September 17, 2026 13:36
@gmarull
gmarull force-pushed the sdk-compiler-h branch 2 times, most recently from 4c14eaf to 198b49b Compare September 17, 2026 13:42
@gmarull
gmarull marked this pull request as ready for review September 17, 2026 13:43
gmarull and others added 3 commits September 22, 2026 10:15
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
gmarull merged commit 2ea9ec1 into coredevices:main Sep 22, 2026
49 checks passed
@gmarull
gmarull deleted the sdk-compiler-h branch September 22, 2026 08:39
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