# 04 — Profiles, target selection and toolchains Implementation status: IMPLEMENTED & VERIFIED (2026-11-26). See [STATE](../agent-workflow/STATE.md) and [VERIFICATION](../agent-workflow/VERIFICATION.md) for implemented files and observed checks. ## Requirements and ownership - Requirements: R-003, R-011, R-015, R-019. - Delivery phase: Core native engine. - Intended configured role: sol_implementer at XHigh; fresh astra_reviewer acceptance. - Dependencies: 01/02 profile protocol; 03 action/usage types; platform operations in 06. - Proposed exclusive implementation scope: src/toolchain/, include/vbs/toolchain/, tests/toolchain/; profile public schema root-owned. Before dispatch, reconcile these paths with the real HEAD, write a full task spec, lint it, and transfer shared-file ownership explicitly. Paths that do not yet exist are NEW. Source-disjoint work still coordinates shared state, ports and build directories. ## Design and interfaces - Resolve named C++ profiles with explicit inheritance and overrides, rejecting unknown parents and cycles. Built-in debug/release defaults are reproducible; target language standard is independent of the C++26 host. - ProfileContext contains target/build machine facts, resolved compiler family/path/identity, sysroot/stdlib and effective flags/features. Evaluate build.cpp separately for each selected context. - Model target selection as the requested target/profile combinations, validating all names before scheduling. Keep mutable outputs, response files, generated files, PCH/BMI and foreign trees isolated below each profile identity. - Identify drivers, helpers, sysroots, configured search roots, options and relevant environment. Version text alone is insufficient. Support installed cross-toolchain descriptions without accidentally executing target binaries during probes. - Generate structured argv and response files via GCC/Clang adapters. Detect language standard, depfile/scanner and requested optimization/sanitizer capabilities using bounded probes. - Begin with observed GCC16.2 and Clang23.1.3 target environments. Older versions and other systems enter the matrix only after tests establish support; never silently downgrade an explicitly requested feature. ## Implementation sequence 1. Implement profile resolution and canonical effective-context identities. 2. Implement host/target driver discovery and capability cache keyed by complete toolchain context. 3. Add command generation for normal compile/archive/link and response-file handling. 4. Expose cross-toolchain settings and coordinate overall jobs across selected profiles; connect modern feature drivers in 08. ## Failure behavior and boundaries - Missing compiler/helper/sysroot or incompatible library ABI is a diagnostic, not an unannounced compiler fallback. - Do not use host preprocessor conditionals to select target-specific flags. - Do not hold a global build lock that prevents independent profiles, but serialize competing writers to one profile. - Explicit unsupported flags/features fail before expensive builds where possible. ## Acceptance scenarios 1. Same source built in debug/release and GCC/Clang profiles has isolated outputs and correct argv. 2. Changing compiler binary, sysroot, flags, response contents or relevant environment invalidates identity. 3. Cross profile probe never runs a target-only executable on the host. 4. Unknown profile, inheritance cycle and incompatible sanitizer/LTO settings fail clearly. 5. Paths with spaces and long argv preserve exact compiler arguments. ## Verification and integration gate NEW future driver fixtures plus actual GCC/Clang compile/link probes run under dev cpp-gcc and dev cpp. Log target-driver versions and feature outcomes separately from host bootstrap success. Acceptance requires observed results for these scenarios, the affected regression suite, reviewed cross-component contracts, and a fresh independent review. Record unrun checks and environment limitations; tests passing alone do not waive an invariant. No merge, push or deployment is authorized by a review verdict. ## VoidLibrary reuse and upstream candidates Void process/path helpers with explicit error results. Capability caching belongs in VBS; reusable process and environment wrappers are upstream candidates. Shared invariants and input/publication policies are defined in [ARCHITECTURE](ARCHITECTURE.md); requirement authority is [REQUIREMENTS](REQUIREMENTS.md). Return implementation evidence to [VERIFICATION](../agent-workflow/VERIFICATION.md).