sun::driver

namespace · Source (opens in a new tab)

Discovers local package providers and coordinates their staged products.

Resolves project configuration without accessing dependency contents.

Internal checks shared by analysis and test-runner generation.

Adapts fallible entrypoints to native or JIT return values.

Internal lifetime guard for code executed by the compiler's JIT.

Writes driver debug artifacts and LLVM IR views.

Constructs drivers and manages the lifetime of JIT exit handlers.

Coordinates compilation, dependency loading, linking, and execution.

Packs source locations into relocatable program data before code is published.

Generates native exception storage and prepares libraries for JIT execution.

Generate a readable shell script exposing installed binary directories.

Generates checked Sun declarations from the target's C headers.

Checks and explicitly installs dependencies supplied by the host system.

Downloads configured inputs and assembles distributable artifacts.

Shared helpers for compiler tests, linked into sun_tests.

Prepares immutable metadata; reporting itself never parses DWARF or allocates.

Prepares exception support before generated code can execute.

Generates shell environments for configured build products.

Coordinates compiler inputs, analysis, code generation, and execution.

Coordinates compilation and generated source inputs.

Coordinates compilation, dependency loading, linking, and program execution.

Keeps the layout and native linking details out of ordinary driver construction.

Builds indexes using compiler memory, outside allocation-free execution.

Compiler driver implementation.

Coordinates compilation and execution of program entrypoints.

Compiler pipeline implementation details.

Namespaces

Classes

Structs

Functions

addExceptionSourceRegistration

public · function · Source (opens in a new tab)

void sun::driver::addExceptionSourceRegistration(llvm::orc::ObjectLinkingLayer &layer, std::shared_ptr< ExceptionSourceCallbacks > callbacks)

Registers and removes JIT indexes with the same lifetime as their code.

Related: ExceptionSourceCallbacks

addSourceDigests

public · function · Source (opens in a new tab)

void sun::driver::addSourceDigests(BuildInputs &inputs, const std::vector< std::string > &sourceFiles, const std::vector< sun::moon_bundling::SynthesizedProtoModule > &protoModules)

Append content hashes of source files and already synthesized protobuf modules.

Adds source and protobuf content digests to the build inputs.

Callers must generate source files before hashing them. Throws SunError when a source file cannot be read.

Related: BuildInputs, sun::moon_bundling::SynthesizedProtoModule, SunError

analyzeString

public · function · Source (opens in a new tab)

void sun::driver::analyzeString(const std::string &source, bool includeStdlib=false)

Parses and analyzes source in a fresh driver, throwing reported errors.

Does not run borrow checking, code generation, linking, or execution.

appendOwnSourceBytes

public · function · static · Source (opens in a new tab)

static void sun::driver::appendOwnSourceBytes(const ExprAST &node, sun::serialization::ASTSerializer &serializer, std::string &out)

Appends the serialized form of every statement the program wrote itself to out.

Blocks are flattened and imported moon scopes are skipped. Each statement is prefixed with its length so neighbours cannot run together.

Related: ExprAST, sun::serialization::ASTSerializer

buildConfigProducts

public · function · Source (opens in a new tab)

fs::path sun::driver::buildConfigProducts(const ConfigGraph &workspace, SunConfig config, const std::vector< std::string > &entrypoints)

Builds named products and their prerequisites, then installs their outputs.

Related: ConfigGraph, SunConfig

buildContextConfig

public · function · Source (opens in a new tab)

SunConfig sun::driver::buildContextConfig()

Restores a child compiler's source settings and already resolved dependencies.

Related: SunConfig

buildPackages

public · function · Source (opens in a new tab)

void sun::driver::buildPackages(const SunConfig &config, const std::vector< PackagePlan > &plans, bool archive=true)

Stages and compresses complete packages, preserving valid unchanged outputs.

Related: SunConfig, PackagePlan

checkSystemDependencies

public · function · Source (opens in a new tab)

void sun::driver::checkSystemDependencies(const SunConfig &config)

Runs declared checks and validates cached Debian artifacts against installed packages.

System dependencies without a check are left to the package manager.

Related: SunConfig

collectReachableFunctions

public · function · static · Source (opens in a new tab)

static void sun::driver::collectReachableFunctions(llvm::Function *func, std::set< llvm::Function * > &visited)

Helper: recursively collect all functions reachable from a given function.

compileFile

public · function · Source (opens in a new tab)

void sun::driver::compileFile(const std::string &filename, bool includeStdlib=false)

Compiles a source file, optionally loading the standard library.

compileFileWithStdlib

public · function · Source (opens in a new tab)

void sun::driver::compileFileWithStdlib(const std::string &filename)

Compile with stdlib preloaded.

compileFiles

public · function · Source (opens in a new tab)

void sun::driver::compileFiles(const std::vector< std::string > &sourceFiles, const std::vector< MoonImport > &moonImports={})

Compile multiple source files using the merged-AST model.

Related: MoonImport

compileString

public · function · Source (opens in a new tab)

void sun::driver::compileString(const std::string &source, bool includeStdlib=false)

Compiles source text, optionally loading the standard library.

compileStringWithStdlib

public · function · Source (opens in a new tab)

void sun::driver::compileStringWithStdlib(const std::string &source)

Compile with stdlib preloaded.

compileToExecutable

public · function · Source (opens in a new tab)

bool sun::driver::compileToExecutable(llvm::Module &module, const std::string &outputPath, std::string &errorMsg, bool keepObjectFile=false, const LinkOptions &linkOpts={}, bool optimize=true)

Compiles a standalone executable with the requested optimization setting.

Returns true on success, false on failure

Related: LinkOptions

computeFileDigest

public · function · Source (opens in a new tab)

std::string sun::driver::computeFileDigest(const std::string &path, const char *what)

Digest of a file's bytes, as lowercase hex.

Reads an input file and computes its content digest.

what names the file's role in the error ("source", "native archive"). Throws SunError when it cannot be read.

Related: SunError

computeInputHash

public · function · Source (opens in a new tab)

std::string sun::driver::computeInputHash(const BuildInputs &inputs)

The hash of inputs and of the running compiler, as lowercase hex.

Computes a digest covering the inputs and settings of a build.

Throws SunError when an imported bundle cannot be read.

Related: BuildInputs, SunError

computeOwnSourceHash

public · function · static · Source (opens in a new tab)

static std::string sun::driver::computeOwnSourceHash(const BlockExprAST &blockAst)

Returns a hash that identifies a program by its own statements.

Imported moon scopes are left out because they already carry their own identity.

Related: BlockExprAST

computeStaticInitOrder

public · function · static · Source (opens in a new tab)

static uint32_t sun::driver::computeStaticInitOrder(const std::vector< std::string > &importedModuleKeys, const std::vector< sun::moon_bundling::MoonImport > &moonImports)

Works out where the startup function of the code being compiled runs relative to those of the bundles it imports: zero when it imports nothing, otherwise one more than the highest value recorded by an import.

Lower values run first, so every import's globals are initialized before this code's startup function reads them.

Related: sun::moon_bundling::MoonImport

configForBuildDirectory

configForBuildDirectory(const std::filesystem::path &directory, const std::string &target)

public · function · Source (opens in a new tab)

std::optional< SunConfig > sun::driver::configForBuildDirectory(const std::filesystem::path &directory, const std::string &target)

Finds a selected project's config for source or generated source directories.

Related: SunConfig

configForBuildDirectory(const fs::path &directory, const std::string &target)

public · function · Source (opens in a new tab)

std::optional< SunConfig > sun::driver::configForBuildDirectory(const fs::path &directory, const std::string &target)

No documentation comment.

Related: SunConfig

configTargetKey

public · function · Source (opens in a new tab)

std::string sun::driver::configTargetKey(const std::string &targetTriple)

Returns the canonical config target key, retaining architecture and ABI.

configWorkspaceRoot

public · function · Source (opens in a new tab)

fs::path sun::driver::configWorkspaceRoot(const SunConfig &config)

Returns the selected workspace root, or the standalone config directory.

Related: SunConfig

configureBuildPaths

public · function · Source (opens in a new tab)

SunConfig sun::driver::configureBuildPaths(const ConfigGraph &graph, SunConfig config)

Applies the selected root's generated and installed paths to one project.

Related: SunConfig, ConfigGraph

declaresStdlibString

public · function · Source (opens in a new tab)

bool sun::driver::declaresStdlibString(const BlockExprAST &block)

Does this block declare class String directly inside module std?

Reports whether source declarations supply the standard String type.

Interpolation desugars to std.String and std.HeapAllocator, so the stdlib's own sources satisfy it without importing stdlib.moon — which they cannot do, being that library.

Related: BlockExprAST

defaultConfigEntrypoints

public · function · Source (opens in a new tab)

std::vector< std::string > sun::driver::defaultConfigEntrypoints(const SunConfig &config)

Returns exported product names, or all names for an unnamed project.

Related: SunConfig

defineExceptionRuntimeStorage

public · function · Source (opens in a new tab)

bool sun::driver::defineExceptionRuntimeStorage(llvm::Module &module, std::string &error)

Defines the depth constant and TLS block when emitting a native object.

Defines native storage at object emission, keeping TLS out of portable Moon bitcode.

effectiveLinkTriple

public · function · Source (opens in a new tab)

llvm::Triple sun::driver::effectiveLinkTriple(const std::string &targetTriple)

The triple a link is actually for: the explicit target, or the host.

embedBuildRecord

public · function · Source (opens in a new tab)

void sun::driver::embedBuildRecord(llvm::Module &module, const BuildRecord &record)

Add record to module so that it ends up in the object file, and in any executable linked from it.

Stores build provenance in the generated LLVM module.

Call once per module, just before emitting it.

Related: BuildRecord, record

embeddedExceptionRuntime

public · function · Source (opens in a new tab)

llvm::StringRef sun::driver::embeddedExceptionRuntime()

Returns the host runtime archive embedded in this compiler.

embeddedExceptionRuntimeSource

public · function · Source (opens in a new tab)

llvm::StringRef sun::driver::embeddedExceptionRuntimeSource()

Returns self-contained runtime source for compilation by a cross toolchain.

emitObjectFile

public · function · Source (opens in a new tab)

bool sun::driver::emitObjectFile(llvm::Module &module, const std::string &outputPath, std::string &errorMsg, bool optimize=true)

Emits an object file with the requested backend optimization setting.

Returns true on success, false on failure

executeFiles

public · function · Source (opens in a new tab)

void sun::driver::executeFiles(const std::vector< std::string > &sourceFiles, const std::vector< MoonImport > &moonImports={})

Execute multiple source files using the merged-AST model.

Related: MoonImport

executeString

public · function · Source (opens in a new tab)

SunValue sun::driver::executeString(const std::string &source, int argc=0, char **argv=nullptr, bool includeStdlib=false)

Execute and log SunError to stderr, then rethrow.

Related: SunValue, SunError

executeStringWithReachableIR

public · function · Source (opens in a new tab)

SunValue sun::driver::executeStringWithReachableIR(const std::string &source, int argc=0, char **argv=nullptr, bool includeStdlib=false)

Execute and dump all reachable IR (includes stdlib functions).

Related: SunValue

executeStringWithStdlib

public · function · Source (opens in a new tab)

SunValue sun::driver::executeStringWithStdlib(const std::string &source, int argc=0, char **argv=nullptr)

Execute with stdlib preloaded.

Related: SunValue

executeTestsWithStdlib

public · function · Source (opens in a new tab)

SunValue sun::driver::executeTestsWithStdlib(const std::string &source, int argc=0, char **argv=nullptr)

Execute in test mode: tests kept, the runner main synthesized, stdlib preloaded.

Returns the runner's exit code (0 = every test passed).

Related: SunValue

expandVariables

public · function · static · Source (opens in a new tab)

static std::optional< std::string > sun::driver::expandVariables(const std::string &input, const SunConfig *config, bool required)

Expands configured paths, optionally tolerating undefined variables.

Related: SunConfig

findConfigEntrypoints

public · function · Source (opens in a new tab)

std::vector< const ConfigEntrypoint * > sun::driver::findConfigEntrypoints(const SunConfig &config, const std::vector< std::string > &names)

Finds products by config name, reporting unknown names without reading sources.

Returned pointers borrow the config's entrypoints.

Related: ConfigEntrypoint, SunConfig

generateCBinding

public · function · Source (opens in a new tab)

void sun::driver::generateCBinding(const CBindingOptions &options)

Parses a C header with libclang and atomically writes checked Sun bindings.

Related: CBindingOptions

generateCBindings

public · function · Source (opens in a new tab)

void sun::driver::generateCBindings(const std::string &baseDir, const std::string &targetTriple)

Writes configured C bindings before resolving or reading manifest sources.

Unchanged outputs are preserved. Only manifest-listed files are compiled. Header generation uses the compiler's linked libclang.

getCompilerDigest

public · function · Source (opens in a new tab)

const std::string & sun::driver::getCompilerDigest()

Digest of the running executable's bytes, so output from a rebuilt compiler is never mistaken for output from the one before it.

Returns the compiler digest stored by this object.

Read once per process.

getStdlibMoonImports

public · function · Source (opens in a new tab)

std::vector< MoonImport > sun::driver::getStdlibMoonImports()

Get the stdlib.moon path for test preloading.

Related: MoonImport

gitDependencyBuildOptions

public · function · Source (opens in a new tab)

const sun::moon_bundling::MoonBuildOptions * sun::driver::gitDependencyBuildOptions()

Borrows the active Git dependency settings, or returns null outside a build.

Related: sun::moon_bundling::MoonBuildOptions

hasStdlibImport

public · function · Source (opens in a new tab)

bool sun::driver::hasStdlibImport(const std::vector< MoonImport > &moonImports)

Check if stdlib.moon is included in moon imports.

Reports whether explicit imports supply the standard library.

Related: MoonImport

haveTool

public · function · Source (opens in a new tab)

bool sun::driver::haveTool(const std::string &tool)

Whether tool exists on PATH.

indexExceptionSources

public · function · Source (opens in a new tab)

llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > sun::driver::indexExceptionSources(llvm::Module &module, llvm::MemoryBufferRef object)

Packs the object's DWARF locations into its reserved index before linking.

initTestEnvironment

public · function · Source (opens in a new tab)

void sun::driver::initTestEnvironment()

Set SUN_PATH to cwd if not already set (for VS Code Test Explorer).

installConfigDependencies

public · function · Source (opens in a new tab)

void sun::driver::installConfigDependencies(const ConfigGraph &graph, const std::vector< SunConfig > &configs, bool dryRun, bool yes)

Installs requirements and prebuilt artifacts, fetching source configs without builds.

Related: ConfigGraph, SunConfig

installSystemDependencies

public · function · Source (opens in a new tab)

void sun::driver::installSystemDependencies(const SunConfig &config, bool dryRun, bool yes)

Requests native dependency installation, or prints a plan when dryRun is true.

Passing checks skip installation; unchecked packages go to the package manager. Refuses host package-manager operations for a foreign compilation target.

Related: SunConfig

isCurrentlyBuildingDependency

public · function · Source (opens in a new tab)

bool sun::driver::isCurrentlyBuildingDependency()

Reports whether configured dependency resolution is active on this thread.

isCurrentlyBuildingGitDependency

public · function · Source (opens in a new tab)

bool sun::driver::isCurrentlyBuildingGitDependency()

Reports whether a Git dependency build is currently active.

isVoid

public · function · Source (opens in a new tab)

bool sun::driver::isVoid(const SunValue &v)

Helper to check if value is void.

Related: SunValue

linkExecutable

public · function · Source (opens in a new tab)

bool sun::driver::linkExecutable(const std::string &objectPath, const std::string &outputPath, std::string &errorMsg, const LinkOptions &linkOpts={}, bool collectDebugSymbols=false)

Links the object file to create an executable.

When requested, collects Darwin debug symbols before deleting the extracted runtime archive. Uses the explicitly selected driver, or the target-appropriate default Returns true on success, false on failure

Related: LinkOptions

linkerCommandFor

public · function · Source (opens in a new tab)

std::string sun::driver::linkerCommandFor(const std::string &targetTriple, bool staticLink=false)

Pick the link driver for a target.

SUN_CC overrides the choice entirely.

Static Linux links require a musl toolchain for the target architecture (<arch>-linux-musl-gcc). Missing musl never selects glibc or dynamic linkage implicitly; users must request dynamic or set SUN_CC explicitly.

A macOS target links with Apple's own cc on a Mac; from any other host there is no driver to pick — linking Mach-O needs the Apple SDK, which cannot ship with a Linux toolchain — so stop at emit-obj and link the object on a Mac.

Otherwise: host builds use cc; cross builds prefer a triple-prefixed GCC (aarch64-linux-gnu-gcc), falling back to clang --target=<triple>. Returns "" when no capable link driver exists on this machine.

loadConfigGraph

loadConfigGraph(const std::filesystem::path &file, const std::string &target="")

public · function · Source (opens in a new tab)

ConfigGraph sun::driver::loadConfigGraph(const std::filesystem::path &file, const std::string &target="")

Loads an explicit root config and its included configs without merging them.

Warns and skips projects that do not support the selected target.

Related: ConfigGraph

loadConfigGraph(const fs::path &file, const std::string &target)

public · function · Source (opens in a new tab)

ConfigGraph sun::driver::loadConfigGraph(const fs::path &file, const std::string &target)

No documentation comment.

Related: ConfigGraph

loadExceptionRuntime

public · function · Source (opens in a new tab)

std::shared_ptr< void > sun::driver::loadExceptionRuntime(unsigned depth)

Links isolated JIT storage against the runtime archive; null selects the host runtime.

Links program-specific storage against the shared runtime archive before execution.

Each driver owns its library so different JIT layouts never share TLS records.

loadMoonScopes

public · function · static · Source (opens in a new tab)

static std::vector< std::unique_ptr< sun::ast::MoonScopeAST > > sun::driver::loadMoonScopes(Parser &parser, const std::vector< MoonImport > &moonImports)

Validates listed bundles, collects their explicit and embedded scopes, and retains their readers for linking.

Embedded scopes are deduplicated and hidden from source lookup; explicit scopes preserve manifest aliases.

Related: sun::ast::MoonScopeAST, Parser, MoonImport

loadNativeLibraries

public · function · Source (opens in a new tab)

NativeLibraries sun::driver::loadNativeLibraries(const LinkOptions &opts)

Make libraries named by -l visible to the JIT.

The JIT resolves externs through DynamicLibrarySearchGenerator over the current process, so a shared library only has to be dlopen'd into this process for its symbols to become reachable. A name that resolves to a static archive instead (lib<name>.a in a -L directory, or an explicit .a path) is returned in archives for the JIT to link itself.

Related: NativeLibraries, LinkOptions

mergeASTs

public · function · static · Source (opens in a new tab)

static std::unique_ptr< BlockExprAST > sun::driver::mergeASTs(std::vector< std::unique_ptr< BlockExprAST > > &parsedFiles)

Merge multiple parsed BlockExprASTs into a single unified AST.

Same-named modules are merged together.

Related: BlockExprAST

operator<<

public · function · Source (opens in a new tab)

std::ostream & sun::driver::operator<<(std::ostream &os, const SunValue &v)

Helper to print a SunValue.

Related: SunValue

operator==

operator==(T expected, const SunValue &v)

public · function · Source (opens in a new tab)

template <typename T>
bool sun::driver::operator==(T expected, const SunValue &v)

Compares the stored values for equality.

Related: SunValue

operator==(const SunValue &v, T expected)

public · function · Source (opens in a new tab)

template <typename T>
bool sun::driver::operator==(const SunValue &v, T expected)

Comparison helpers for testing.

Related: SunValue

packageConfigProducts

public · function · Source (opens in a new tab)

void sun::driver::packageConfigProducts(const ConfigGraph &workspace, SunConfig config, const std::vector< std::string > &entrypoints)

Creates the config's declared packages from products that were already built.

Related: ConfigGraph, SunConfig

packageEntrypointResources

public · function · Source (opens in a new tab)

std::vector< ConfigResource > sun::driver::packageEntrypointResources(const SunConfig &config, const ConfigEntrypoint &entry)

Resolves entrypoint-relative resources for an install or package layout.

Related: ConfigResource, SunConfig, ConfigEntrypoint

packageFileHash

packageFileHash(const fs::path &path)

public · function · Source (opens in a new tab)

std::string sun::driver::packageFileHash(const fs::path &path)

No documentation comment.

packageFileHash(const std::filesystem::path &path)

public · function · Source (opens in a new tab)

std::string sun::driver::packageFileHash(const std::filesystem::path &path)

Returns the SHA-256 digest of a file, reporting unreadable inputs.

planPackages

public · function · Source (opens in a new tab)

std::vector< PackagePlan > sun::driver::planPackages(const SunConfig &config, const std::vector< PackageArtifact > &artifacts)

Checks membership and output locations before compiling production files.

Related: PackagePlan, SunConfig, PackageArtifact

prepareExceptionSources

public · function · Source (opens in a new tab)

void sun::driver::prepareExceptionSources(llvm::Module &module, bool jit)

Reserves an index whose function pointers receive normal linker relocations.

processMoonImports

public · function · static · Source (opens in a new tab)

static void sun::driver::processMoonImports(BlockExprAST &blockAst, Parser &parser, const std::vector< MoonImport > &moonImports)

Process moon imports: collect stubs, deduplicate, check for collisions with source modules and between moons, then prepend to AST.

Related: BlockExprAST, Parser, MoonImport

readBuildContext

public · function · Source (opens in a new tab)

llvm::json::Object sun::driver::readBuildContext()

Reads the immutable context inherited by custom build commands.

readBuildRecord

public · function · Source (opens in a new tab)

std::optional< BuildRecord > sun::driver::readBuildRecord(const std::string &path)

The record inside the executable or object file at path.

Reads build provenance from a compiled artifact.

Empty when the file is missing or carries no record. Moon libraries expose the same flags.

Related: BuildRecord

readMoonInputHash

public · function · Source (opens in a new tab)

std::optional< std::string > sun::driver::readMoonInputHash(const std::string &path)

The input hash a .moon bundle was built from.

Reads the recorded input digest from a Moon library.

Empty when the file is missing or is not a readable bundle.

renameOwnExterns

public · function · static · Source (opens in a new tab)

static void sun::driver::renameOwnExterns(BlockExprAST &block, const std::map< std::string, std::string > &renames, std::vector< std::string > &unmapped)

Bind the program's own C externs to the archives the bundle being built carries: an extern whose link name is a key of renames is emitted, and recorded in the bundle's metadata, under the prefixed value.

Imported bundles' scopes are left alone; their externs were bound when they were built. Link names no rename applies to are collected in unmapped.

Related: BlockExprAST

requiresNativeExceptions

public · function · static · Source (opens in a new tab)

static bool sun::driver::requiresNativeExceptions(const sun::ast::ExprAST &expression)

Retains the exception ABI requirement even for uninstantiated generic bodies.

Related: sun::ast::ExprAST

resolveConfigDependency

public · function · Source (opens in a new tab)

fs::path sun::driver::resolveConfigDependency(const SunConfig &config, const std::string &name, const std::string &relativePath="")

Resolves a configured dependency to a verified local directory on demand, without building its tests.

Related: SunConfig

resolveGitDependency

public · function · Source (opens in a new tab)

std::filesystem::path sun::driver::resolveGitDependency(const SunConfig &consumer, const std::string &name)

Checks out a Git dependency, builds it, and returns its install directory.

A source-file dependency uses the consumer's compiler settings. A dependency with package selections builds the named libraries and executables together, including their prerequisites, without running tests. Generated files and compiled products go in the build cache, outside the checkout. Fails if a selected package or product is missing or dependencies form a cycle.

Related: SunConfig

resolveGitEntrypoint

public · function · Source (opens in a new tab)

std::string sun::driver::resolveGitEntrypoint(const ConfigEntrypoint &entry, bool refresh=false)

Fetches a versioned checkout once and returns its entrypoint's absolute path.

Uses SUN_GIT_CACHE or .sun/cache/git beneath the current working directory and Git's normal authentication. Refresh fetches a new snapshot while preserving previous checkouts. Reports fetch failures and paths escaping the checkout as compiler errors.

Related: ConfigEntrypoint

resolveLibraryReference

public · function · static · Source (opens in a new tab)

static std::string sun::driver::resolveLibraryReference(const std::string &reference, const std::string &baseDir, const SunConfig *config, const std::string &targetTriple)

Resolve a package library without treating its identity as a filesystem path.

Same-package imports use built prerequisites; external packages remain declared dependencies. Compiler libraries use the ordinary bundle search directories.

Related: SunConfig

resolveLocalDependency

public · function · Source (opens in a new tab)

std::optional< fs::path > sun::driver::resolveLocalDependency(const SunConfig &consumer, const std::string &name)

Prefers a matching local provider; an absent provider permits external resolution.

Related: SunConfig

setBuildConfiguration

public · function · Source (opens in a new tab)

void sun::driver::setBuildConfiguration(const std::string &name, bool force)

Selects the output configuration and whether preparation steps must rerun.

setConfiguredBuildRoots

public · function · Source (opens in a new tab)

void sun::driver::setConfiguredBuildRoots(const std::vector< std::string > &roots)

Registers explicitly selected config roots for read-only editor resolution.

setProductCompiler

public · function · Source (opens in a new tab)

void sun::driver::setProductCompiler(ProductCompiler compiler)

Installs the CLI compiler callback; readers can resolve already staged outputs.

Related: ProductCompiler

shellQuote

public · function · Source (opens in a new tab)

std::string sun::driver::shellQuote(const std::string &s)

Quote a string for safe use as a single argument in a /bin/sh command.

The link command runs through std::system, and -l/-L values come from the user, so they must not be able to inject shell syntax.

stripUnreachableForExecutable

public · function · static · Source (opens in a new tab)

static void sun::driver::stripUnreachableForExecutable(llvm::Module &module)

Strip library code the program never uses before optimizing an executable.

Both optimization and ORC compilation otherwise process unused definitions. Internalize everything except entry points, then GlobalDCE drops anything main cannot reach (references through vtables/globals are preserved).

supportsJITReturn

public · function · static · Source (opens in a new tab)

static bool sun::driver::supportsJITReturn(const sun::types::TypePtr &type)

Reports whether the JIT can safely call a function returning this type.

Related: sun::types::TypePtr

toDouble

public · function · Source (opens in a new tab)

double sun::driver::toDouble(const SunValue &v)

Helper to get numeric value as double (for backward compatibility).

Related: SunValue

validateGitSource

public · function · Source (opens in a new tab)

void sun::driver::validateGitSource(const ConfigEntrypoint &entry)

Rejects invalid Git URLs, invalid revisions, and escaping source paths.

Related: ConfigEntrypoint

warnAboutArchiveSet

public · function · static · Source (opens in a new tab)

static void sun::driver::warnAboutArchiveSet(const std::vector< std::string > &archives, const std::vector< std::string > &bareExterns)

What the linker will not say.

Two archives with one file name under different hashes mean two versions of a library go into the program, each bound to the code that came with it. A plain extern naming a symbol that a bundle carries only in prefixed form binds to whatever the final link provides under the bare name, which is rarely what was meant.

wrapOwnBundle

public · function · static · Source (opens in a new tab)

static void sun::driver::wrapOwnBundle(BlockExprAST &blockAst, const std::string &scopeName)

Move everything the program declares itself (every top-level node that is not an imported bundle's scope) into one MoonScopeAST for the bundle being built, named by its $hash$ prefix.

Imported scopes stay where they are.

Related: BlockExprAST, MoonScopeAST

wrapStaticCtorsForJIT

public · function · static · Source (opens in a new tab)

static bool sun::driver::wrapStaticCtorsForJIT(llvm::Module &module)

Make a module's global initializers callable under the JIT.

They are internal functions registered in llvm.global_ctors — one per linked module, uniquified by the IR linker — and the JIT resolves symbols by name, which cannot reach an internal function. So wrap every ctor entry in a single external runner for the driver to look up and call before main, in the same order the AOT init_array would use. Returns false when the module has no constructors and there is nothing to run.

writeEnvScript

public · function · Source (opens in a new tab)

void sun::driver::writeEnvScript(const ConfigGraph &graph, const std::string &targetTriple)

Write a sourceable PATH script for installed projects in the selected build.

For example, a viewer binary becomes available after sourcing env.sh. param

  • graph: The composed projects and their shared output root.

  • targetTriple: The target whose installed binaries should be exposed.

Related: ConfigGraph

Variables

ExitOnErr

public · variable · static · Source (opens in a new tab)

llvm::ExitOnError sun::driver::ExitOnErr

No documentation comment.

Type Aliases

ProductCompiler

public · typedef · Source (opens in a new tab)

using sun::driver::ProductCompiler =  std::function<void(
    const SunConfig&, const ConfigEntrypoint&, const std::filesystem::path&)>

Compiles one configured product into its workspace output path.

Related: SunConfig, ConfigEntrypoint

SunValue

public · typedef · Source (opens in a new tab)

using sun::driver::SunValue =  std::variant<VoidValue,   
                              bool,        
                              int8_t,      
                              int16_t,     
                              int32_t,     
                              int64_t,     
                              float,       
                              double,      
                              std::string  
                              >

SunValue can hold any primitive type that main() might return.

Related: VoidValue, SunValue, main()