Inspect the Compilation Pipeline
This guide shows how to look inside the compiler while it processes a single source file: emitting intermediate representations, choosing backends, tuning codegen, and adjusting lint levels.
Every command below compiles a file named input.g. Add --with-stdlib when your file uses names such as println, Vec, Option, Result, String, or Box — the flag prepends the assembled standard library so those names resolve without explicit use statements:
1glyim input.g --with-stdlib --emit mirEmit intermediate representations
Section titled “Emit intermediate representations”The --emit flag selects the output artifact:
1glyim input.g --emit mir # MIR after lowering — useful for debugging lowering2glyim input.g --emit llvm-ir # LLVM IR from the LLVM backend3glyim input.g --emit asm # target assembly4glyim input.g --emit obj # native object file (default)5glyim input.g --emit exec -o hello # runnable executable6glyim input.g --emit cdylib # dynamic library, used for proc-macro cratesWrite the artifact to a specific path with -o:
1glyim input.g --emit llvm-ir -o out.llCompare the two backends
Section titled “Compare the two backends”The --backend flag selects between llvm (default) and bytecode. The bytecode backend emits compact stack-machine bytecode that the glyim-bytecode-vm crate executes — useful for testing and embedded execution:
1glyim input.g --backend bytecode --emit objTune optimization and codegen units
Section titled “Tune optimization and codegen units”1glyim input.g -O2 --lto thin # optimization level 2, thin LTO2glyim input.g --codegen-units 4 # partition into 4 codegen units-O/--opt-levelranges from 0 (default) to 3.--codegen-unitsdefaults to the available parallelism capped at 16, mirroring rustc’s-C codegen-unitspolicy.--ltoacceptsoff(default),fat, orthin.fatrequires multi-CGU support, which is not yet implemented, and errors cleanly.thinrequires thellvm-lto2tool from the LLVM distribution the backend was built against.
Cross-compile
Section titled “Cross-compile”1glyim input.g --target aarch64-unknown-linux-gnuOverride the system linker and pass extra flags when needed:
1glyim input.g --linker /path/to/ld --link-flags "-L/opt/lib -lmylib"Get machine-readable diagnostics
Section titled “Get machine-readable diagnostics”Editors and tooling consume diagnostics as JSON, one object per diagnostic:
1glyim input.g --error-format jsonThe default human format renders diagnostics with miette, including source snippets and labels.
Use procedural macros
Section titled “Use procedural macros”Compile proc-macro dependency sources to host cdylibs first, then reference them with a comma-separated list:
1glyim proc_macro_dep.g --emit cdylib2glyim main.g --proc-macro-deps proc_macro_dep.gAdjust lint levels
Section titled “Adjust lint levels”The compiler currently ships two lints: unsafe_fn_call (alias unsafe) and unused_generic_params (alias unused_generics). Set their levels with repeatable flags:
1glyim input.g -D unsafe # promote to error2glyim input.g -A unsafe_fn_call # suppress3glyim input.g -W unused_generic_params # set back to warning (the default)4glyim -W help # list all available lints-A allows (suppresses), -W warns (default), and -D denies, which aborts compilation at the pipeline’s error gate. See the lint reference for details.
