compiler

package
v0.16.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagMaxMemory  = "max-memory"   // bytes (RLIMIT_AS)
	FlagMaxCPUTime = "max-cpu-time" // seconds (RLIMIT_CPU)
)

Flag names used to pass per-compilation resource limits to the compile-sierra child process. They are shared by the parent (which builds the child's argv) and the child command (which defines the flags and applies the limits to itself).

Variables

This section is empty.

Functions

func ApplySelfRLimits added in v0.16.3

func ApplySelfRLimits(cpuSeconds, memoryBytes uint64) error

ApplySelfRLimits caps the CPU time (RLIMIT_CPU, seconds) and address space (RLIMIT_AS, bytes) of the calling process. A zero value leaves the corresponding limit unchanged.

It is called by the compile-sierra child at startup, before any compilation work, so the limits are in force for the whole compile with no race window. unix.Setrlimit applies process-wide on Linux.

func CPURlimitExceeded added in v0.16.3

func CPURlimitExceeded(err error) bool

CPURlimitExceeded reports whether err indicates the compile-sierra child was killed by the kernel for exceeding an applied rlimit: RLIMIT_CPU raises SIGXCPU and then SIGKILL. It turns the otherwise opaque "signal: killed" exec error into a diagnosable resource-limit message.

func CompileFFI added in v0.15.20

func CompileFFI(sierra *starknet.SierraClass) (*starknet.CasmClass, error)

CompileFFI performs Sierra-to-CASM compilation via direct CGo FFI.

Types

type Compiler added in v0.15.20

type Compiler interface {
	Compile(ctx context.Context, sierra *starknet.SierraClass) (
		*starknet.CasmClass, error,
	)
}

Compiler compiles Sierra classes to CASM.

func New added in v0.15.20

func New(cfg *Config, binaryPath string, logger log.StructuredLogger) Compiler

New creates a Compiler that runs Sierra-to-CASM compilation in isolated child processes with per-process resource control.

func NewUnsafe added in v0.15.20

func NewUnsafe() Compiler

NewUnsafe returns a Compiler that compiles in the same process Juno is running. It can be unsafe if the compilation process get stuck.

type Config added in v0.16.3

type Config struct {
	// MaxMemory is the address-space limit (RLIMIT_AS) in bytes
	// applied to each compilation process. Exceeding it aborts that
	// compilation. Enforced on Linux only. 0 disables the limit.
	MaxMemory uint64
	// MaxCPUTime is the CPU-time limit (RLIMIT_CPU) in seconds
	// applied to each compilation process. Exceeding it kills that
	// compilation. Enforced on Linux only. 0 disables the limit.
	MaxCPUTime uint64
}

Config bounds the resources used by compilation child processes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL