Skip to content

Latest commit

 

History

History
135 lines (105 loc) · 5.01 KB

File metadata and controls

135 lines (105 loc) · 5.01 KB
title Compiler Package
audience developers, maintainers, contributors
prerequisites contributor architecture guide, native compiler toolchain
related ../architecture.md, index.md, pipeline.md, runtime.md, ../workflows/quality-assurance.md
status maintained
publication draft

Compiler Package

Purpose And Boundaries

prik/compiler/ receives explicit source, object, include, library, flag, and link inputs and turns them into native commands. It owns compiler-family profiles, command construction and execution, and native-support installation. It does not preprocess source, discover build order, probe datatype meaning, or decide wrapper policy.

Local Structure

prik/compiler/
├── __init__.py
├── compiler_profiles.py
├── objects.py
├── compilers.py
└── native_support.py

What This Stage Receives And Produces

explicit ObjectFile and link inputs from prik.pipeline
  -> coherent compiler-family profile
  -> compile/link argv
  -> recorded or executed native process
  -> object file or shared extension

The selected Fortran compiler family supplies its matching C driver and family-specific switches. The pipeline owns dependency-ready batches; the compiler executes one request at a time.

Directory Tour

Module Main entrypoints and contents Change it when
prik/compiler/__init__.py Deliberately empty package boundary; callers use the owning modules or pipeline APIs. Establishing a small compiler-package public import surface.
prik/compiler/compiler_profiles.py Profile data and fortran_compiler_family() map a Fortran executable to its compatible C driver and flags. Supporting a compiler family or changing family-specific build settings.
prik/compiler/objects.py ObjectFile is the immutable description of one source-to-object request. A compilation input needs another explicit field or validation rule.
prik/compiler/compilers.py Compiler builds, records, runs, and reports compile/link commands; get_condaless_search_path() isolates environment lookup. Command spelling, subprocess execution, or command reporting changes.
prik/compiler/native_support.py install_native_support() copies the bundled support payload and creates the NumPy API-version header. The pipeline needs a different support-installation result; edit the payload itself under runtime/native_support/.

Execution Examples

Compiler-family selection:

python3 prik/compiler/compiler_profiles.py
Selected family: gfortran
Compiler profile: GNU
Matching C executable: gcc
Fortran module-output flag: -J

One immutable compilation request:

python3 prik/compiler/objects.py
Compile input: generated/bridge.f90 -> build/bridge.o
Language: fortran
Flags: ('-O2',)
Include directories: build/modules

Record-only command construction:

python3 prik/compiler/compilers.py
Compiler profile: GNU
Compile input: demo.c -> demo.o
Recorded without execution: True
Contains compile switch: True
Contains requested flag: True
Commands recorded: 1

Bundled runtime installation:

python3 prik/compiler/native_support.py
Installed directory: binding_support
Binding header present: True
NumPy version header present: True

Together these outputs prove that profile selection, request construction, native command mechanics, and support installation remain separate operations.

Tests And What They Prove

Change Routes

  • Change driver families or flags in compiler_profiles.py.
  • Change compile/link argv or subprocess reporting in compilers.py.
  • Change build order, parallel scheduling, manifests, or artifact names in prik/pipeline/build.py.
  • Change native payload contents in prik/runtime/native_support/; change only their installation here.

Invariants And Common Mistakes

  • Never infer ownership, dtype, Python API shape, or wrapper support here.
  • Never silently mix a selected Fortran driver with an unrelated C profile.
  • Each invocation receives explicit inputs; hidden project discovery belongs upstream.