2.8.2 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 gcc_jit_context_compile_to_file() API entrypoint.

For linking in object files, use gcc_jit_context_add_driver_option().

C Function: void gcc_jit_context_compile_to_file (gcc_jit_context *ctxt, enum gcc_jit_output_kind output_kind, const char *output_path)

Compile the gcc_jit_context * to a file of the given kind.

gcc_jit_context_compile_to_file() ignores the suffix of output_path, and insteads uses the given enum gcc_jit_output_kind to decide what to do.

Note: This is different from the gcc program, which does make use of the suffix of the output file when determining what to do.

C Type: enum gcc_jit_output_kind

The available kinds of output are:

Output kindTypical suffix
GCC_JIT_OUTPUT_KIND_ASSEMBLER.s
GCC_JIT_OUTPUT_KIND_OBJECT_FILE.o
GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY.so or .dll
GCC_JIT_OUTPUT_KIND_EXECUTABLENone, or .exe
C Macro: GCC_JIT_OUTPUT_KIND_ASSEMBLER

Compile the context to an assembler file.

C Macro: GCC_JIT_OUTPUT_KIND_OBJECT_FILE

Compile the context to an object file.

C Macro: GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY

Compile the context to a dynamic library.

C Macro: GCC_JIT_OUTPUT_KIND_EXECUTABLE

Compile the context to an executable.