Context
We currently maintain multiple bash scripts (build_debug_asan.sh, riscv_spacemit/build_debug.sh, etc.) to handle diverse build configurations. This fragmentation makes it hard for Agents to reliably "build the project." We need a single Python source of truth (src/tools/builder.py) that abstracts these flags.
Objective
Upgrade the run_build python tool to support a profile argument that maps to our specific CMake presets.
Scope of Work
- Profile Registry: Implement the following profiles in
builder.py:
HOST_DEBUG: Standard RelWithDebInfo.
HOST_ASAN: Clang + LD_PRELOAD + ASAN flags (Derived from build_debug_asan.sh).
RISCV_FIRESIM: Bare-metal cross-compilation using riscv_firesim.toolchain.cmake and linker specs.
RISCV_SPACEMIT: Linux cross-compilation for SpacemiT K1 using riscv.toolchain.cmake.
- Environment Management:
- Auto-detect
RISCV_TOOLCHAIN_ROOT or fail gracefully.
- Handle
LD_PRELOAD injection for Python subprocesses when running ASAN builds.
Acceptance Criteria
- Test 1 (Host):
builder.py build --profile host_debug -> Success if iree-compile is generated.
- Test 2 (ASAN):
builder.py build --profile host_asan -> Success if libclang_rt.asan.so is correctly preloaded and binary runs without segfault.
- Test 3 (RISC-V):
builder.py build --profile riscv_firesim -> Success if it invokes the specific gcc linker script (htif.ld) defined in the toolchain file.
Context
We currently maintain multiple bash scripts (
build_debug_asan.sh,riscv_spacemit/build_debug.sh, etc.) to handle diverse build configurations. This fragmentation makes it hard for Agents to reliably "build the project." We need a single Python source of truth (src/tools/builder.py) that abstracts these flags.Objective
Upgrade the
run_buildpython tool to support aprofileargument that maps to our specific CMake presets.Scope of Work
builder.py:HOST_DEBUG: Standard RelWithDebInfo.HOST_ASAN: Clang + LD_PRELOAD + ASAN flags (Derived frombuild_debug_asan.sh).RISCV_FIRESIM: Bare-metal cross-compilation usingriscv_firesim.toolchain.cmakeand linker specs.RISCV_SPACEMIT: Linux cross-compilation for SpacemiT K1 usingriscv.toolchain.cmake.RISCV_TOOLCHAIN_ROOTor fail gracefully.LD_PRELOADinjection for Python subprocesses when running ASAN builds.Acceptance Criteria
builder.py build --profile host_debug-> Success ifiree-compileis generated.builder.py build --profile host_asan-> Success iflibclang_rt.asan.sois correctly preloaded and binary runs without segfault.builder.py build --profile riscv_firesim-> Success if it invokes the specificgcclinker script (htif.ld) defined in the toolchain file.