3.1. Compiler and Tool Overview
The DQ tools turn .dq source modules into native programs. The compiler uses
LLVM to generate machine code and a Clang linker driver to combine that code
with the DQ runtime and native libraries.
| Tool | Purpose |
|---|---|
dq-comp |
Compile a source module or .dqproj project and link an executable. |
dq-run |
Compile and run a single source file. |
dq-atrun |
Compile and execute the repository's autotests. |
3.1.1 Install and Check the Tools
Use a DQ release package for your
host platform. Keep its bin, stdpkg, and bundled toolchain directories
together, since the tools discover supporting files relative to the compiler.
Follow Linux Development Environment or Windows Development Environment for installation. To work on the compiler itself, see Building the Compiler from Source.
dq-comp --version
dq-comp --help
dq-run --help
3.1.2 Compile a Program
Save this as hello.dq:
use print
func *Main():
PrintLn("Hello, DQ!")
endfunc
Run it directly:
dq-run hello.dq
Or keep the compiled executable:
dq-comp -g -O0 hello.dq
./hello
On Windows, the output is hello.exe; run it with .\hello.exe in PowerShell.
*Main is the DQ program entry point. The selected runtime supplies the native
startup code on hosted targets.
3.1.3 Choose a Workflow
Use dq-run for small examples. Compiler options go before the source filename;
program arguments go after it, optionally separated by --:
dq-run -O2 hello.dq -- first second
When no compiler options are supplied, dq-run selects -g -O0. These flags
provide source information for debugging and runtime backtraces.
Use dq-comp for explicit output names, reusable builds, and cross targets.
A project file keeps a longer set of options together.
Imported DQ modules and runtime modules are compiled as needed; you do not need
to list every imported source file on the command line.
The next chapters describe program execution, compiler options, and the generated build artifacts.