rules/odin/toolchain.js

Developer reference: this page includes exported implementation details. BUILD authors should prefer the User API reference.

ODIN_TOOL

const ODIN_TOOL

Undocumented.

odinCacheKey()

odinCacheKey(version, plat)

Return the named-cache key for an Odin toolchain version and platform.

ParameterTypeDescription
versionstring
plat{ os: string, arch: string }

Returns: string

odinArtifactName()

odinArtifactName(version, plat)

Return the Odin release artifact filename for a version and platform.

ParameterTypeDescription
versionstring
plat{ os: string, arch: string }

Returns: string

odinDownloadUrl()

odinDownloadUrl(version, plat)

Return the Odin release download URL for a version and platform.

ParameterTypeDescription
versionstring
plat{ os: string, arch: string }

Returns: string

odinSupportedPlatforms()

odinSupportedPlatforms()

Return the platforms Odin publishes release archives for.

Returns: Array<{ os: string, arch: string }>

OdinToolchain (implementation class)

class OdinToolchain

Implementation class. BUILD files should use odinToolchain().

Undocumented.

odinToolchain()

odinToolchain(version, opts = {})

Declare an Odin toolchain version and optionally set it as the default. defaults to the bundled //rules/odin/odin.lock. Point this at your own lock (regenerate via imp goal gen-lockfiles) when pinning a version the bundled lock does not know. matching lockfile entry (warns instead of failing). moldGraphToolchain()'s { tool, version } shape, //rules/c/mold) Odin should use instead of the gcc toolchain's default ld. Read back via odinLinkerFor()/defaultOdinLinkerToolchain(). step to the mingw-CRT path (-no-crt plus the gcc/mingw runtime archives) instead of the default, which leaves Odin's own MSVC CRT linking in place. Set this when this workspace's Windows C/C++ deps (e.g. cmakeProject()/ccLibrary() built via //rules/c/gcc's default gcc toolchain) are themselves mingw-built and so need mingw's CRT/UCRT symbols rather than MSVC's (operator new, __CxxFrameHandler4, __security_cookie, ...). Only meaningful alongside opts.lldOnWindows — see that option's own docstring. Read back via odinUsesMingwCrt()/ defaultOdinUsesMingwCrt(). step from the default system link.exe to Odin's bundled lld-link.exe. Off by default: system link.exe auto-detects the Visual Studio/Windows SDK install and needs no further plumbing from this workspace. Set this only when this workspace's Windows C/C++ deps include gcc/mingw-built object code — lld-link reads both MSVC- and GCC-style COFF objects, system link.exe reliably only reads MSVC's — and be prepared to also supply the MSVC LIB/INCLUDE search path yourself (e.g. via //rules/c/msvc's msvcEnv()), since unlike system link.exe, lld-link does not auto-detect it. Read back via odinUsesLldOnWindows()/ defaultOdinUsesLldOnWindows().

ParameterTypeDescription
versionstringOdin release version (matches .odin-version).
[opts]object
[opts.default=false]booleanSet as the default toolchain.
[opts.lockfile]stringLockfile address pinning download SHA-256s;
[opts.unverified=false]booleanAllow downloading without a
[opts.linker]objectGraph-native linker toolchain handle (e.g.
[opts.mingwCrt=false]booleanOn Windows, switch Odin's lld-link
[opts.lldOnWindows=false]booleanOn Windows, switch Odin's link

Returns: object Tool handle for this Odin toolchain.

odinLinkerFor()

odinLinkerFor(version)

Return the graph-native linker handle declared for an Odin toolchain version via odinToolchain(version, { linker }), or null if none was set.

ParameterTypeDescription
versionstring

Returns: object|null

defaultOdinLinkerToolchain()

defaultOdinLinkerToolchain()

Return the linker handle declared for the currently configured default Odin toolchain version, or null if none is declared or no linker was set.

Returns: object|null

odinUsesMingwCrt()

odinUsesMingwCrt(version)

Whether an Odin toolchain version was declared with odinToolchain(version, { mingwCrt: true }) — see that option's own docstring.

ParameterTypeDescription
versionstring

Returns: boolean

defaultOdinUsesMingwCrt()

defaultOdinUsesMingwCrt()

Whether the currently configured default Odin toolchain version was declared with odinToolchain(version, { mingwCrt: true }).

Returns: boolean

odinUsesLldOnWindows()

odinUsesLldOnWindows(version)

Whether an Odin toolchain version was declared with odinToolchain(version, { lldOnWindows: true }) — see that option's own docstring.

ParameterTypeDescription
versionstring

Returns: boolean

defaultOdinUsesLldOnWindows()

defaultOdinUsesLldOnWindows()

Whether the currently configured default Odin toolchain version was declared with odinToolchain(version, { lldOnWindows: true }).

Returns: boolean

odinGenLockfiles()

odinGenLockfiles(version, opts = {})

The [GEN_LOCKFILES] root for an Odin toolchain version. This is a separate function from odinToolchain(). odinToolchain() returns a frozen tool() handle. Other rules use that handle directly through exec.tool(). A frozen object cannot hold an extra property. one declared on the toolchain. Defaults to the address odinToolchain(version, { lockfile }) declared, so a workspace states it once.

ParameterTypeDescription
[version]string
[opts]object
[opts.lockfile]stringWrite this lockfile address instead of the

Returns: object { [GEN_LOCKFILES]: ... }.

odinGraphTool()

odinGraphTool(version)

Build a verified Odin compiler as an ordinary graph tool.

resolveOdinToolchainVersion()

resolveOdinToolchainVersion(version)

Resolve an explicit or default Odin toolchain version.

ParameterTypeDescription
[version]string

Returns: string

defaultOdinToolchainVersion()

defaultOdinToolchainVersion()

Return the currently configured default Odin toolchain version.

Returns: string|null

defaultOdinToolchain()

defaultOdinToolchain()

Return the currently configured default Odin toolchain target handle.

Returns: object|null