CodeSampleX

Sample

llvmlite 0.49.0rc1: binding.create_mcjit_compiler

Verified sample for pypi llvmlite 0.49.0rc1: binding.create_mcjit_compiler. The contract ran on python 3.12 · linux debian/x64 · docker and passed.

sha256:f20775a4605b008c741b95d64029ea8a39cec91dd62ee0c2e50035885d5282d5

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip 24

Verification-run environments

Environment Contract Stages Run
python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104…
2026-09-07

Case

HOW
Goal
verify pkg:pypi/llvmlite@0.49.0rc1
Packages
Symbols
  • llvmlite.binding.create_mcjit_compiler
Environment
python 3.12
Created
2026-09-07T07:02:19Z

Contract

  1. llvmlite.binding native target and asmprinter initialization
  2. llvmlite.ir.Module and IRBuilder construct typed functions with arithmetic instructions
  3. llvmlite.binding.parse_assembly parses IR assembly string into verified ModuleRef
  4. llvmlite.binding.create_mcjit_compiler compiles module and retrieves executable function pointer

Files

  • PROMPT.md
  • csx.json
  • requirements.txt
  • spec.json
  • test/contract.py

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:pypi/llvmlite@0.49.0rc1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/llvmlite@0.49.0rc1

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:0894e9153d28ab0c975f32f37a3ea658a87b5b4d08bcf00a5ec5cfd1441f4c71","contract":["llvmlite.binding native target and asmprinter initialization","llvmlite.ir.Module and IRBuilder construct typed functions with arithmetic instructions","llvmlite.binding.parse_assembly parses IR assembly string into verified ModuleRef","llvmlite.binding.create_mcjit_compiler compiles module and retrieves executable function pointer"],"goal":"verify pkg:pypi/llvmlite@0.49.0rc1","kind":"HOW","packages":["pkg:pypi/llvmlite@0.49.0rc1"],"schemaVersion":1,"symbols":["llvmlite.binding.create_mcjit_compiler"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","moduleSystem":"standard","os":"linux","osVersionBucket":"24","packageManager":"pip","packageManagerVersion":"24.0","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/llvmlite@0.49.0rc1"],"schemaVersion":1,"subject":"pkg:pypi/llvmlite@0.49.0rc1","symbols":["llvmlite.binding.create_mcjit_compiler"],"verifierAdapter":"python@1"}
requirements.txt
llvmlite==0.49.0rc1
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/llvmlite@0.49.0rc1",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/llvmlite@0.49.0rc1"
  ],
  "symbols": [
    "llvmlite.binding.create_mcjit_compiler"
  ]
}
test/contract.py
import ctypes
import llvmlite
import llvmlite.binding as llvm
import llvmlite.ir as ir


def test_native_initialization() -> None:
    llvm.initialize_native_target()
    llvm.initialize_native_asmprinter()
    triple = llvm.get_default_triple()
    assert isinstance(triple, str) and len(triple) > 0


def test_ir_module_builder() -> str:
    module = ir.Module(name="mcjit_contract_mod")
    i32 = ir.IntType(32)
    func_type = ir.FunctionType(i32, [i32, i32])
    func = ir.Function(module, func_type, name="compute")
    block = func.append_basic_block(name="entry")
    builder = ir.IRBuilder(block)

    a, b = func.args
    prod = builder.mul(a, b, name="prod")
    result = builder.add(prod, ir.Constant(i32, 7), name="res")
    builder.ret(result)

    ir_str = str(module)
    assert "compute" in ir_str
    assert "mul" in ir_str
    assert "add" in ir_str
    assert "ret i32" in ir_str
    return ir_str


def test_parse_assembly_and_verify(ir_str: str) -> llvm.ModuleRef:
    mod = llvm.parse_assembly(ir_str)
    assert mod is not None
    mod.verify()
    return mod


def test_create_mcjit_compiler_and_execute(mod: llvm.ModuleRef) -> None:
    target = llvm.Target.from_default_triple()
    target_machine = target.create_target_machine()
    backing_mod = llvm.parse_assembly("")
    engine = llvm.create_mcjit_compiler(backing_mod, target_machine)
    assert engine is not None

    engine.add_module(mod)
    engine.finalize_object()
    engine.run_static_constructors()

    func_ptr = engine.get_function_address("compute")
    assert func_ptr != 0, "Function pointer must not be null"

    c_func = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_int32, ctypes.c_int32)(func_ptr)
    # (5 * 6) + 7 = 37
    assert c_func(5, 6) == 37
    # (0 * 10) + 7 = 7
    assert c_func(0, 10) == 7


def main() -> None:
    test_native_initialization()
    ir_str = test_ir_module_builder()
    mod = test_parse_assembly_and_verify(ir_str)
    test_create_mcjit_compiler_and_execute(mod)
    print("All contract assertions passed successfully.")


if __name__ == "__main__":
    main()

Origin Seeder

anonymous