Conversation
Rather than append a linker file, we edit the upstream supplied ones to add our section to the binaries. Works better on all platforms. Co-Authored-By: Claude <noreply@anthropic.com>
Use readelf instead of nm for great speed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WalkthroughRefactors the dynamic array linker integration from platform-specific scripts to cross-platform injection into rodata regions. Simultaneously replaces module validation from ELF symbol-based detection using Changes
Sequence Diagram(s)sequenceDiagram
participant Build as Build System
participant Script as dynarray.py
participant FS as File System
participant Linker as Linker (ld)
Build->>Script: Execute build script with PIOPLATFORM
Script->>Script: Determine platform (espressif32/8266)
alt ESP32 Path
Script->>FS: Search LIBPATH for sections.ld
alt Found in LIBPATH
Script->>FS: Copy sections.ld to $BUILD_DIR/dynarray_sections.ld
Script->>FS: Patch: inject before _rodata_end marker
Script->>Script: Rewrite LINKFLAGS (-Tsections.ld → absolute path)
else Not Found
Script->>Script: Register post-action callback
Script->>FS: Patch $BUILD_DIR/sections.ld (after generation)
end
else ESP8266 Path
Script->>Script: Register post-action callback
Script->>FS: Patch $BUILD_DIR/ld/local.eagle.app.v6.common.ld
Script->>FS: Inject before _irom0_text_end marker
end
Script->>Linker: Pass modified LINKFLAGS with injected fragments
Linker->>FS: Link ELF with patched linker scripts
sequenceDiagram
participant Build as Build System
participant Script as validate_modules.py
participant Readelf as readelf Tool
participant ELF as ELF File
participant Modules as Module Builders
Build->>Script: Validate modules in ELF
Script->>Readelf: Execute readelf --debug-dump=info on ELF
Readelf->>ELF: Parse DWARF compilation units
Readelf->>Script: Return DWARF CU headers (DW_AT_name, DW_AT_comp_dir)
Script->>Script: Iterate CU boundaries
Script->>Script: Track compilation unit metadata
Script->>Script: Match DW_AT_comp_dir against module source paths
alt Virtual path (/IDF_PROJECT)
Script->>Script: Fallback to $PROJECT_DIR substitution
end
Script->>Modules: Compare matched paths against module_lib_builders
Script->>Script: Compute confirmed module set
Script->>Script: Return confirmed modules
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pio-scripts/validate_modules.py (1)
112-112: Consider documenting the 32-bit target assumption.The hardcoded
ENTRY_SIZE = 4is correct for current ESP8266/ESP32 targets (both 32-bit), but the assumption could be made explicit for future maintainability.📝 Suggested documentation
- ENTRY_SIZE = 4 # sizeof(Usermod*) on 32-bit targets + ENTRY_SIZE = 4 # sizeof(Usermod*); all supported WLED platforms are 32-bit🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pio-scripts/validate_modules.py` at line 112, The hardcoded ENTRY_SIZE = 4 assumes 32-bit targets; update the code around ENTRY_SIZE to document that assumption explicitly (e.g., "ENTRY_SIZE = 4 # sizeof(Usermod*) on 32-bit targets (ESP8266/ESP32)"). Also add a short note about future-proofing: either compute the pointer size dynamically (using struct.calcsize('P')) or add a runtime assertion/guard that raises a clear error if the platform pointer size is not 4, so callers of ENTRY_SIZE (the ENTRY_SIZE symbol) will behave correctly on non-32-bit platforms.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pio-scripts/validate_modules.py`:
- Line 112: The hardcoded ENTRY_SIZE = 4 assumes 32-bit targets; update the code
around ENTRY_SIZE to document that assumption explicitly (e.g., "ENTRY_SIZE = 4
# sizeof(Usermod*) on 32-bit targets (ESP8266/ESP32)"). Also add a short note
about future-proofing: either compute the pointer size dynamically (using
struct.calcsize('P')) or add a runtime assertion/guard that raises a clear error
if the platform pointer size is not 4, so callers of ENTRY_SIZE (the ENTRY_SIZE
symbol) will behave correctly on non-32-bit platforms.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f57b7275-5745-45ee-a088-10b393377fdb
📒 Files selected for processing (4)
pio-scripts/dynarray.pypio-scripts/validate_modules.pytools/dynarray_espressif32.ldwled00/dynarray.h
💤 Files with no reviewable changes (2)
- tools/dynarray_espressif32.ld
- wled00/dynarray.h
Bring in the dynarray/usermod improvements from the V5 work in progress. This improves the system to support LTO and framework = arduino, esp-idf, as well as fixes some issues with dynarray linkage on RISCV platforms.
#5497, but for main - with one more commit to finish cleaning up some of the messaging.
Summary by CodeRabbit