From fd871b8898d8706f71aaebcc03b09f8c11c952cb Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 27 Aug 2026 00:10:07 -0500 Subject: [PATCH] Precompile a curated core-header prefix on host --- .github/workflows/ci-docker.yml | 4 +++- esphome/components/host/__init__.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 0ddef1153f..c39dd76921 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -206,7 +206,7 @@ jobs: # platforms where it must work. Excluded: bk72xx/rtl87xx/ln882x # (libretiny GCC rejects its own pch until a toolchain bump), # esp32-*-platformio (no pch; the toolchain is being dropped), - # nrf52 and host (no pch) + # nrf52 (no pch) include: - id: esp8266-arduino pch_strict: "1" @@ -218,6 +218,8 @@ jobs: pch_strict: "1" - id: rp2040-arduino pch_strict: "1" + - id: host + pch_strict: "1" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Download image artifact diff --git a/esphome/components/host/__init__.py b/esphome/components/host/__init__.py index bd074ab6b5..f99b7985cd 100644 --- a/esphome/components/host/__init__.py +++ b/esphome/components/host/__init__.py @@ -1,3 +1,4 @@ +from esphome.build_helpers.pch import pch_extra_scripts import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import ( @@ -10,7 +11,7 @@ from esphome.const import ( ThreadModel, ) from esphome.core import CORE -from esphome.platformio.toolchain import copy_ccache_script +from esphome.platformio.toolchain import copy_ccache_script, copy_pch_script from esphome.types import ConfigType from .const import KEY_HOST @@ -55,9 +56,18 @@ async def to_code(config: ConfigType) -> None: cg.add_platformio_option("platform", "platformio/native") cg.add_platformio_option("lib_ldf_mode", "off") cg.add_platformio_option("lib_compat_mode", "strict") - cg.add_platformio_option("extra_scripts", ["pre:ccache.py"]) + cg.add_platformio_option("extra_scripts", ["pre:ccache.py", *pch_extra_scripts()]) + # Curated prefix for the pch (the script folds these plus defines.h): + # host has no framework force-includes, and the per-TU cost is the STL + # closure behind these core headers. Measured -43% compile CPU. + # macOS system clang cannot load a GCC .gch; the load probe falls back. + cg.add_platformio_option( + "build_src_flags", + "-include esphome/core/application.h -include esphome/core/automation.h", + ) # Called by writer.py def copy_files() -> None: copy_ccache_script() + copy_pch_script()