# Build Process for Creating Cross-Compiled Binaries for Multiple Platforms in Reasonix

> Learn the Reasonix build process for cross-compiled binaries. Create static Go binaries for six platforms using CGO_ENABLED=0 and a Makefile.

- Repository: [YHH/DeepSeek-Reasonix](https://github.com/esengine/DeepSeek-Reasonix)
- Tags: how-to-guide
- Published: 2026-06-27

---

**Reasonix uses a Makefile-driven build system that produces static Go binaries for six platforms (Darwin, Linux, and Windows on both AMD64 and ARM64) by setting `CGO_ENABLED=0` and iterating over OS/architecture pairs.**

The `esengine/DeepSeek-Reasonix` repository ships as a single static Go binary designed for maximum portability. According to the source code, the entire build process is automated through a **Makefile** that handles both local development builds and full cross-compilation for distribution. This approach eliminates runtime dependencies by disabling CGO, ensuring each binary contains only the Go runtime and Reasonix code.

## How the Cross-Compilation Pipeline Works

The cross-compilation logic resides in the `Makefile` at the repository root, which defines the `cross` target for multi-platform builds.

### Build Targets and Environment Setup

The pipeline begins by preparing a `dist/` directory to store output artifacts. For each target platform, the build system configures three critical environment variables:

- **`CGO_ENABLED=0`** – Disables CGO to produce fully static binaries without external library dependencies
- **`GOOS`** – Specifies the target operating system (`darwin`, `linux`, or `windows`)
- **`GOARCH`** – Specifies the target CPU architecture (`amd64` or `arm64`)

These settings ensure the resulting binaries run on any system of the specified architecture without requiring libc or other system-specific libraries.

### The Cross-Compilation Loop

The `make cross` command executes a shell loop that iterates over six predefined OS/architecture pairs. As implemented in the `Makefile`, the loop parses each pair to extract the OS and architecture components, then conditionally sets an extension variable for Windows executables:

```make
@for p in darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64; do \
    os=$${p%/*}; arch=$${p#*/}; ext=; [ $$os = windows ] && ext=.exe; \
    echo "build $$os/$$arch"; \
    CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -ldflags "$(LDFLAGS)" \
        -o dist/reasonix-$$os-$$arch$$ext ./cmd/reasonix; \
done

```

The build injects version information through `LDFLAGS` that embed the current git tag or defaults to "dev" when no tag exists. The entry point for compilation is [`./cmd/reasonix/main.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/./cmd/reasonix/main.go), which serves as the CLI binary's main package.

## Supported Platform Targets

Reasonix officially supports six platform combinations through its cross-compilation matrix:

- **darwin/amd64** – macOS on Intel processors
- **darwin/arm64** – macOS on Apple Silicon (M1/M2/M3)
- **linux/amd64** – Linux on 64-bit x86 processors
- **linux/arm64** – Linux on 64-bit ARM processors
- **windows/amd64** – Windows on 64-bit x86 processors
- **windows/arm64** – Windows on 64-bit ARM processors

Each binary receives a descriptive filename following the pattern `reasonix-$os-$arch`, with Windows targets automatically receiving the `.exe` extension.

## Build Commands and Usage

Developers can invoke two primary build targets from the repository root:

**Single-platform build** (for the host machine):

```bash
make build

```

This produces `bin/reasonix` (or `bin/reasonix.exe` on Windows) for local development and testing.

**Cross-compilation** (for all supported platforms):

```bash
make cross

```

This generates six static binaries in the `dist/` directory:
- `dist/reasonix-darwin-amd64`
- `dist/reasonix-darwin-arm64`
- `dist/reasonix-linux-amd64`
- `dist/reasonix-linux-arm64`
- `dist/reasonix-windows-amd64.exe`
- `dist/reasonix-windows-arm64.exe`

Running `make cross` requires Go 1.22+ and completes in seconds on modern hardware, as the Go compiler handles cross-compilation natively without requiring platform-specific toolchains.

## Key Build Configuration

The build process is defined in `Makefile` at the repository root, which also includes targets for `vet`, `fmt`, `test`, and `clean`. The [`docs/SPEC.md`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/docs/SPEC.md) file documents the "single static binary" philosophy underlying these build decisions, emphasizing zero-dependency distribution across operating systems.

Because the build explicitly disables CGO (`CGO_ENABLED=0`), the resulting executables contain only the Go runtime and Reasonix application code. This design choice prevents dynamic linking issues and makes the binaries ideal for containerized environments and direct distribution to end users.

## Summary

- **Makefile-driven**: The `Makefile` provides both `make build` for local development and `make cross` for distribution.
- **Six-platform support**: Automated generation for Darwin, Linux, and Windows on AMD64 and ARM64 architectures.
- **Static binaries**: `CGO_ENABLED=0` ensures fully static executables with no external dependencies.
- **Version embedding**: LDFLAGS inject git tags or "dev" into the binary at compile time.
- **Entry point**: All builds compile `./cmd/reasonix` to produce the final CLI binary.

## Frequently Asked Questions

### Why does Reasonix disable CGO for cross-compilation?

Reasonix sets `CGO_ENABLED=0` to eliminate dependencies on system C libraries, ensuring the binary runs on any Linux, macOS, or Windows system regardless of the libc version or availability. This produces a fully static binary that contains only the Go runtime and Reasonix code, making distribution and deployment significantly simpler across heterogeneous environments.

### What Go version is required to build Reasonix binaries?

The repository recommends Go 1.22 or later for building Reasonix. While earlier versions may work, Go 1.22+ provides improved cross-compilation performance and compatibility with modern standard library features used in the codebase.

### How does the build process handle version information?

The `Makefile` defines LDFLAGS that pass version information to the linker during compilation. When running `make cross` or `make build`, the system injects the current git tag into the binary; if no tag exists, it defaults to "dev". This enables the `reasonix` binary to report its exact version via CLI commands without manual code changes.

### Can I add additional platforms to the cross-compilation list?

Yes, you can modify the `cross` target in the `Makefile` to include additional OS/architecture pairs supported by the Go toolchain, such as `freebsd/amd64` or `linux/386`. Simply append the desired pair to the space-separated list in the for-loop, following the `os/arch` format used for the existing six platforms.