Swift Compiler Inspection Workflow
Inspect the Swift compilation pipeline while distinguishing supported driver behavior from version-sensitive compiler internals.
Workflow
- Inspect repository guidance and determine whether SwiftPM, Xcode, another build system, or a standalone compiler invocation owns the real build.
- Resolve toolchain ownership:
- inspect Swiftly with
swiftly use --print-location and swift --version
- inspect Xcode with
xcode-select -p, xcrun --find swiftc, and xcrun swiftc --version
- choose the owner matching the actual build and keep all compiler, SDK, plugin, and module paths within it
- Reproduce the narrowest compiler phase that answers the question:
- parse
- type check
- print driver jobs
- dependency scan
- emit or inspect AST
- emit SIL or LLVM IR
- emit module, interface, or diagnostics
- Run experiments against copied or temporary inputs unless the user asked to change the repository.
- Capture the complete command, toolchain identity, target triple, SDK, language mode, conditional flags, module paths, and relevant environment.
- Classify every surface using references/compiler-surfaces.md: supported CLI, version-sensitive diagnostic surface, or compiler-internal surface.
- Compare artifacts only across intentionally matched configurations.
- Hand full package or Xcode builds and tests to their owning workflow.
Driver Boundary
- Treat
swift and swiftc as compiler-driver entry points that plan and coordinate frontend and linker jobs.
- Treat
swift-driver as the driver implementation, not a second compiler frontend.
- Prefer driver options over invoking
swift-frontend directly.
- Use
swift-frontend only when a documented compiler-development workflow or unavailable driver surface requires it, and label the command internal and version-sensitive.
Toolchain Contract
- Use Swiftly-selected toolchains for Swift.org release or snapshot comparison, cross-platform compiler behavior, and
.swift-version-controlled repositories.
- Use Xcode-selected tools through
xcrun for Apple SDK imports, Xcode build reproduction, Xcode-bundled SourceKit behavior, and Apple target triples.
- Do not combine Swiftly's compiler with Xcode's private toolchain libraries or combine Xcode's compiler with Swiftly's host plugins.
- Recognize
swiftly use xcode as a proxy into the selected Xcode toolchain and record both selectors.
Output
Return the question, selected compiler phase, toolchain owner and version, exact invocation, artifact stability class, result, and limitations.
Guardrails
- Do not claim compiler dump formats are stable interchange formats.
- Do not infer optimizer or runtime behavior from a Debug-only or parse-only artifact.
- Do not omit compiler arguments when reproducing a type-check or module failure.
- Do not run multiple SwiftPM or Xcode compiler validations concurrently.
- Do not mutate the global Swiftly or Xcode selection for inspection alone.
1---2name: swift-compiler-inspection-workflow3description: Inspect Swift toolchain selection, driver jobs, diagnostics, AST, SIL, LLVM IR, dependencies, modules, and interfaces. Use for compiler behavior, lowering, build-job, or emitted-artifact investigations.4license: Apache-2.05---67# Swift Compiler Inspection Workflow89Inspect the Swift compilation pipeline while distinguishing supported driver behavior from version-sensitive compiler internals.1011## Workflow12131. Inspect repository guidance and determine whether SwiftPM, Xcode, another build system, or a standalone compiler invocation owns the real build.142. Resolve toolchain ownership:15 - inspect Swiftly with `swiftly use --print-location` and `swift --version`16 - inspect Xcode with `xcode-select -p`, `xcrun --find swiftc`, and `xcrun swiftc --version`17 - choose the owner matching the actual build and keep all compiler, SDK, plugin, and module paths within it183. Reproduce the narrowest compiler phase that answers the question:19 - parse20 - type check21 - print driver jobs22 - dependency scan23 - emit or inspect AST24 - emit SIL or LLVM IR25 - emit module, interface, or diagnostics264. Run experiments against copied or temporary inputs unless the user asked to change the repository.275. Capture the complete command, toolchain identity, target triple, SDK, language mode, conditional flags, module paths, and relevant environment.286. Classify every surface using [references/compiler-surfaces.md](references/compiler-surfaces.md): supported CLI, version-sensitive diagnostic surface, or compiler-internal surface.297. Compare artifacts only across intentionally matched configurations.308. Hand full package or Xcode builds and tests to their owning workflow.3132## Driver Boundary3334- Treat `swift` and `swiftc` as compiler-driver entry points that plan and coordinate frontend and linker jobs.35- Treat `swift-driver` as the driver implementation, not a second compiler frontend.36- Prefer driver options over invoking `swift-frontend` directly.37- Use `swift-frontend` only when a documented compiler-development workflow or unavailable driver surface requires it, and label the command internal and version-sensitive.3839## Toolchain Contract4041- Use Swiftly-selected toolchains for Swift.org release or snapshot comparison, cross-platform compiler behavior, and `.swift-version`-controlled repositories.42- Use Xcode-selected tools through `xcrun` for Apple SDK imports, Xcode build reproduction, Xcode-bundled SourceKit behavior, and Apple target triples.43- Do not combine Swiftly's compiler with Xcode's private toolchain libraries or combine Xcode's compiler with Swiftly's host plugins.44- Recognize `swiftly use xcode` as a proxy into the selected Xcode toolchain and record both selectors.4546## Output4748Return the question, selected compiler phase, toolchain owner and version, exact invocation, artifact stability class, result, and limitations.4950## Guardrails5152- Do not claim compiler dump formats are stable interchange formats.53- Do not infer optimizer or runtime behavior from a Debug-only or parse-only artifact.54- Do not omit compiler arguments when reproducing a type-check or module failure.55- Do not run multiple SwiftPM or Xcode compiler validations concurrently.56- Do not mutate the global Swiftly or Xcode selection for inspection alone.