Table Of Contents

Previous topic

Source Locations

Next topic

Internals

This Page

Compiling a context

Once populated, a gccjit::context can be compiled to machine code, either in-memory via gccjit::context::compile() or to disk via gccjit::context::compile_to_file().

You can compile a context multiple times (using either form of compilation), although any errors that occur on the context will prevent any future compilation of that context.

In-memory compilation

gcc_jit_result* gccjit::context::compile()

This calls into GCC and builds the code, returning a gcc_jit_result *.

This is a thin wrapper around the gcc_jit_context_compile() API entrypoint.

Ahead-of-time compilation

Although libgccjit is primarily aimed at just-in-time compilation, it can also be used for implementing more traditional ahead-of-time compilers, via the gccjit::context::compile_to_file() method.

void gccjit::context::compile_to_file(enum gcc_jit_output_kind, const char* output_path)

Compile the gccjit::context to a file of the given kind.

This is a thin wrapper around the gcc_jit_context_compile_to_file() API entrypoint.