← Wave Programming Language Blog
2026-04-01

Patch #311: Precision in Linking: Introducing -C link-sysroot and Enhanced Validation

When building software for different architectures or embedded systems, managing the "sysroot"—the directory containing the target's standard headers and libraries—is one of the most critical steps. Our latest update to the `wavec` CLI makes this process more transparent and less error-prone by introducing a dedicated linking-stage sysroot option and improved safety checks.

Patch #311: Precision in Linking: Introducing -C link-sysroot and Enhanced Validation cover image

Patch #311: Precision in Linking: Introducing -C link-sysroot and Enhanced Validation

When building software for different architectures or embedded systems, managing the "sysroot"—the directory containing the target's standard headers and libraries—is one of the most critical steps. Our latest update to the wavec CLI makes this process more transparent and less error-prone by introducing a dedicated linking-stage sysroot option and improved safety checks.

1. The Challenge: Compiler vs. Linker Sysroots

In complex build environments, developers often provide a --sysroot to the compiler. However, when using a custom linker (via -C linker=...), the linker doesn't always automatically inherit this path. This can lead to confusing "library not found" errors during the final link stage, even if the compilation itself was successful.

2. New Option: -C link-sysroot=<path>

To solve this ambiguity, we have introduced the -C link-sysroot option. This allows you to explicitly pass a sysroot path specifically for the linking stage.

  • Role: It ensures that your custom linker knows exactly where to look for system libraries and start-up files.
  • Flexibility: By separating the compiler's sysroot from the linker's sysroot, Wave provides the granular control needed for advanced toolchain configurations.

3. Safety First: Custom Linker Validation

We’ve added a new validation pass to the wavec build pipeline to prevent silent failures.

The New Rule: If you specify both a custom linker (-C linker=...) and a general sysroot (--sysroot=...), the compiler will now require you to explicitly define the linker's sysroot using -C link-sysroot.

This requirement eliminates the guesswork. Instead of wondering why a custom linker isn't picking up the general sysroot, the compiler now guides you to provide the explicit path, ensuring a predictable and successful build every time.

4. Robust Internal Management

Behind the scenes, we've implemented several helper utilities to manage these arguments:

  • Deduplication: The compiler now intelligently checks for duplicate or conflicting sysroot arguments.
  • Safe Propagation: Ensures that sysroot flags are passed to the underlying Clang/Linker call in the correct order and format.

How to use it

If you are cross-compiling with a custom toolchain, your command might now look like this:

wavec build my_app.wave \
    --target=riscv64-unknown-none-elf \
    --sysroot=/path/to/riscv/toolchain \
    -C linker=riscv64-unknown-elf-ld \
    -C link-sysroot=/path/to/riscv/toolchain

Conclusion

These CLI enhancements might seem small, but they are vital for the reliability of the Wave toolchain in professional and embedded environments. By enforcing explicit configuration where ambiguity exists, we ensure that wavec remains a robust and trustworthy tool for systems programming.

Check out the updated wavec build --help for more details on these new flags!

Link