Compiler (conjurec)

The conjurec command is the Conjure compiler. It compiles Conjure source files (.cjr) into executables, object files, or C source code.

Basic Usage

conjurec <source-files...> [options]

Compile a single file:

conjurec main.cjr -o myprogram

Compile multiple files:

conjurec main.cjr utils.cjr -o myprogram

Output Options

-o, --output

Specifies the output file path.

conjurec main.cjr -o build/myprogram

--emit

Controls the output type. Available options:

  • binary (default) - Produces an executable
  • object - Produces an object file
  • c-source - Produces C source code
# Generate C source instead of binary
conjurec main.cjr --emit c-source -o output.c

Compilation Options

-O, --optimize

Sets the optimization level (0-3). Default is 0.

# No optimization (fastest compile)
conjurec main.cjr -O0

# Maximum optimization (slowest compile, fastest runtime)
conjurec main.cjr -O3

-g, --debug

Includes debug information in the output. Enables the DEBUG global constant.

conjurec main.cjr -g -o myprogram_debug

--fast

Enables fast compilation mode. Uses smaller names and skips some optimizations for faster builds during development.

conjurec main.cjr --fast -o myprogram

Entry Point Options

--entry-fn

Specifies the entry function name. Default is main.

conjurec main.cjr --entry-fn start -o myprogram

--no-entry

Library mode. Compiles without generating an entry point, suitable for creating libraries.

conjurec mylib.cjr --no-entry -o mylib.o --emit object

Target Options

--target

Specifies a target triple (e.g., x86_64-linux-gnu).

conjurec main.cjr --target x86_64-linux-gnu -o myprogram

--platform

Sets the target operating system: linux, darwin, or windows.

conjurec main.cjr --platform linux -o myprogram_linux

--arch

Sets the target architecture: x86_64 or arm64.

conjurec main.cjr --arch arm64 -o myprogram_arm

C Backend Options

Conjure compiles to C as an intermediate representation, then uses a C compiler to produce the final binary.

--cc

Specifies the C compiler path. By default, the compiler auto-detects tcc, clang, or gcc.

conjurec main.cjr --cc /usr/bin/clang -o myprogram

--cc-flags

Passes additional flags to the C compiler.

conjurec main.cjr --cc-flags "-march=native" -o myprogram

Linking Options

-L, --library-path

Adds a library search path.

conjurec main.cjr -L /opt/lib -o myprogram

-l, --library

Links with a library.

conjurec main.cjr -l pthread -l m -o myprogram

-I, --include-path

Adds an include search path for C headers.

conjurec main.cjr -I /opt/include -o myprogram

Runtime Options

--runtime

Sets the runtime mode:

  • application (default) - Full runtime for standalone programs
  • library - Minimal runtime for libraries
  • test - Runtime with test harness
  • minimal - Bare minimum runtime
conjurec mylib.cjr --runtime library -o mylib

--no-runtime

Skips runtime inclusion entirely. Equivalent to --runtime minimal.

conjurec bare.cjr --no-runtime -o bare

Other Options

--cache-dir

Directory for intermediate files. Default is .conjure in the source file’s directory.

conjurec main.cjr --cache-dir /tmp/conjure-cache -o myprogram

--verbose

Enables verbose output for debugging compilation issues.

conjurec main.cjr --verbose -o myprogram

--build-config

Path to a build configuration file (typically generated by a build script).

conjurec main.cjr --build-config build.cfg -o myprogram

Examples

Development Build

Fast compilation with debug info:

conjurec main.cjr -g --fast -o debug_build

Release Build

Optimized build for production:

conjurec main.cjr -O3 -o release_build

Cross-Compilation

Build for a different platform:

conjurec main.cjr --platform linux --arch x86_64 -o linux_build

Library Build

Create a library without an entry point:

conjurec mylib.cjr --no-entry --emit object -o mylib.o

Linking External Libraries

Build with external library dependencies:

conjurec game.cjr -L /usr/local/lib -l SDL2 -l SDL2_image -o mygame

Exit Codes

  • 0 - Compilation successful
  • 1 - Compilation failed (errors in source code or configuration)