#4464·tock

Tracking: Add tock as a supported OS for target triples

Author: ppannutoCreated Jun 11, 2025Updated Aug 25, 2026
Labelstracking

Meta: This isn't directly an issue for the Tock kernel, but as the Tock kernel is the center point for a lot of external work, I think this makes the most sense for a holding place for a tracking issue.

Motivation / Rationale

Currently, toolchains around the Tock ecosystem all use generic, bare metal targets (e.g. none). In practice, the Tock ecosystem actually has more stringent requirements (i.e., our own syscall ABI; required use of position-independent code; etc). What this means is that while we can use "out of the box" bare metal compilers, we build our own standard libraries (e.g.), and configuration for userspace is a somewhat delicate, and increasingly-complicated mapping of compilers to other toolchain components.

Early on, this made a lot of sense, but frankly Tock is big enough now and used enough places, that it's quite reasonable to be a "real" target (e.g., zephyr has been since 2021).

Especially as we grow the number of platforms (i.e., this was driven by starting to implement more of our machinery for i386 in libtock-c), we will be much served as an integrated, upstream platform in toolchains. Short-term, it will alleviate configuration and installation burdens (as we can simply package whole "tock toolchains" the "normal" way); I suspect it will also help the visibility of Tock. Long-term, it will allow for more interesting Tock-specific enhancements to various standard libraries (at the cost of doing such things via upstream patches, rather than local changes).

Roadmap

Note on strategy: Zephyr's LLVM/GCC/binutils toolchains actually use a vendor-field convention (arm-zephyr-eabi) rather than a real OS entry, which required zero upstream patches but also gives no compiler-level awareness of OS-specific requirements (PIC defaults, syscall ABI, etc.) and no upstream visibility.

We're deliberately not following that shortcut — this roadmap targets genuine OS-level support in each toolchain, consistent with the motivation above.

There's a few parallel paths here:

GNU-family Tooling

Useful reference to start from: https://wiki.osdev.org/Porting_GCC_to_your_OS

  1. Add Tock as a target to config.sub — this is copied/inherited by the rest of the GNU ecosystem
  2. Tock support in binutils
  3. Tock support in GCC
    • Includes config.gcc target entry, t-tock makefile fragment, crt startup file conventions — this is where Tock-specific behavior (PIC-by-default, syscall ABI awareness) actually lives, distinct from basic target recognition
  4. Tock support in newlib
  5. Tock support in picolibc
    • picolibc split from newlib years ago and maintains its own independent OS/board support layer; this can proceed in parallel with (not after) newlib support
  6. gdb/gdbserver support for debugging over Tock's syscall ABI

LLVM-family Tooling

Reference: https://clang.llvm.org/docs/CrossCompilation.html and existing OS ports under clang/lib/Driver/ToolChains/ for the general shape of an OS port.

  1. Add Tock to LLVM's target triple parser (Triple::OSType in llvm/include/llvm/TargetParser/Triple.h / llvm/lib/TargetParser/Triple.cpp)
  2. Add a Clang driver toolchain for Tock (clang/lib/Basic/Targets.cpp switch-case + new clang/lib/Driver/ToolChains/Tock.{h,cpp})
  3. compiler-rt builtins support for Tock's syscall ABI / PIC requirements
  4. lld linker support for Tock's PIC/PIE userspace app model
  5. Decide libc path for LLVM-based builds — share newlib/picolibc from the GNU track, or use llvm-libc

Rust Tooling

Reference: https://doc.rust-lang.org/rustc/target-tier-policy.html#adding-a-new-target

  1. Settle on target triple naming (e.g. riscv32imc-unknown-tock-elf) consistent with existing libtock-rs triples
  2. Identify a named target maintainer (required by tier-3 policy)
  3. Implement and validate the target spec against upstream rustc (compiler/rustc_target/src/spec/targets/)
  4. Write platform-support/<target>.md from the template; update SUMMARY.md and platform-support.md
  5. Submit PR applying for tier3 status (tier-3 policy checklist in PR description, r? compiler)