BlyxDocumentation
Browse chapters
Documentation / Local toolchain

Build a native executable

Compile a typed Blyx program and compare the executable with the interpreter on the same input.

Start with a known result

Run the project source through the interpreter and keep a small expected output. When trying a native build for the first time, use the generated hello project or the capstone. Both have simple results that you can check by eye.

Build for your host

Install a Rust compiler and host linker. From inside your Blyx project, run the command below. The native backend translates supported Blyx syntax to Rust and invokes rustc to produce an optimized executable for the build machine.

blyxc build src/main.blyx

Choose the output location

An explicit output name makes scripts easier to read. On Linux or macOS, run the executable using a relative path. Use a separate output path from the source file.

blyxc build src/main.blyx -o hello
./hello

Build on Windows

In PowerShell, use an .exe suffix and the current-directory prefix. The resulting executable runs independently of blyxc and rustc on a compatible machine.

blyxc build src/main.blyx -o hello.exe
.\hello.exe

Compare the two paths

Give numeric operands matching types and add explicit return types to functions that return values. The interpreter can promote mixed integer/float operations that a native build rejects. Check the executable's output using the same ordinary and boundary inputs you used for the interpreted run.

Build a program with imports

Native builds resolve local use paths and built-in host modules. The native runner builds the program and runs it in one step. Put program arguments after --. Use a normal build to keep an executable for repeated runs.

blyxc native-run src/main.blyx

Practice

Build the capstone source as a native executable, run it and compare the complete output with the chapter’s expected output.

Hint

Save the complete capstone program to src/main.blyx first.

Worked solution

The four readings sum to 123.5, two exceed 30, and the empty call prints no readings. Those three lines should agree across both execution paths.