Skip to content

Build Integration

View as Markdown

Use this page when you need to compile a C program against the installed SDK instead of just reading header-level reference docs.

Start with Set Up Thru DevKit, then install the C SDK surfaces with:

Terminal window
thru dev toolchain install
thru dev sdk install c

The CLI installs the C SDK under ~/.thru/sdk/c and the toolchain under ~/.thru/sdk/toolchain.

Terminal window
test -d ~/.thru/sdk/c
test -f ~/.thru/sdk/c/thru-sdk/thru_c_program.mk
test -d ~/.thru/sdk/toolchain/bin
test -x ~/.thru/sdk/toolchain/bin/riscv64-unknown-elf-gcc || test -x ~/.thru/sdk/toolchain/bin/riscv64-none-elf-gcc

The downstream makefiles auto-detect either riscv64-unknown-elf- or riscv64-none-elf-, so either compiler prefix is valid.

The installed downstream build hook is thru_c_program.mk.

Its job is to:

  • require THRU_C_SDK_DIR
  • add SDK include paths through CPPFLAGS
  • add SDK library paths through LDFLAGS
  • include machine and config files for the Thru VM toolchain
THRU_C_SDK_DIR := $(HOME)/.thru/sdk/c/thru-sdk
include $(THRU_C_SDK_DIR)/thru_c_program.mk
$(call make-bin,my_program_c,my_program,,-ltn_sdk)

Point it at the installed SDK root that contains:

  • thru_c_program.mk
  • include/
  • lib/
  • config/

For the default CLI install, that means:

THRU_C_SDK_DIR := $(HOME)/.thru/sdk/c/thru-sdk
my-program/
├── GNUmakefile
└── examples/
├── Local.mk
├── my_program.c
└── my_program.h
NeedRecommendation
One or two small programsKeep a single GNUmakefile plus per-directory Local.mk files.
Multiple example binariesAdd more make-bin calls in Local.mk.
SDK extrasUse SDK_EXTRAS when you intentionally want extra configuration layers.

For the standard downstream project layout used in the C guide, the built binary lands under:

build/thruvm/bin/

That is the path shape the rest of the docs currently assume for deployment examples.

  • The docs page is the right place to learn the installed entrypoint. The repo-local sdks/c/setup.sh is not the end-user install path you should default to.
  • If a task is “build a downstream program,” start with thru_c_program.mk, not the SDK’s internal GNUmakefile.