Table Of Contents

Previous topic

Compiling a context

Next topic

C++ bindings for libgccjit

This Page

ABI and API compatibility

The libgccjit developers strive for ABI and API backward-compatibility: programs built against stand a good chance of running without recompilation against newer versions of, and ought to recompile without modification against newer versions of libgccjit.h.


The libgccjit++.h C++ API is more experimental, and less locked-down at this time.

API compatibility is achieved by extending the API rather than changing it. For ABI compatiblity, we avoid bumping the SONAME, and instead use symbol versioning to tag each symbol, so that a binary linked against is tagged according to the symbols that it uses.

For example, gcc_jit_context_add_command_line_option() was added in LIBGCCJIT_ABI_1. If a client program uses it, this can be detected from metadata by using objdump:

$ objdump -p testsuite/jit/test-extra-options.c.exe | tail -n 8

Version References:
  required from
    0x00824161 0x00 04 LIBGCCJIT_ABI_1
    0x00824160 0x00 03 LIBGCCJIT_ABI_0
  required from

You can see the symbol tags provided by using objdump:

$ objdump -p | less
Version definitions:
1 0x01 0x0ff81f20
2 0x00 0x00824160 LIBGCCJIT_ABI_0
3 0x00 0x00824161 LIBGCCJIT_ABI_1

ABI symbol tags

The initial release of libgccjit (in gcc 5.1) did not use symbol versioning.

Newer releases use the following tags.


All entrypoints in the initial release of libgccjit are tagged with LIBGCCJIT_ABI_0, to signify the transition to symbol versioning.

Binaries built against older copies of should continue to work, with this being handled transparently by the linker (see this post)


LIBGCCJIT_ABI_1 covers the addition of gcc_jit_context_add_command_line_option()


LIBGCCJIT_ABI_2 covers the addition of gcc_jit_context_set_bool_allow_unreachable_blocks()


LIBGCCJIT_ABI_3 covers the addition of switch statements via API entrypoints: