summaryrefslogtreecommitdiff
path: root/gcc/jit/docs/topics/compatibility.rst
blob: 03e3f3402a1e954580bac7a6c5ad67e9eedb7824 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
.. Copyright (C) 2015-2022 Free Software Foundation, Inc.
   Originally contributed by David Malcolm <dmalcolm@redhat.com>

   This is free software: you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see
   <https://www.gnu.org/licenses/>.

.. default-domain:: c

ABI and API compatibility
=========================

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

.. note:: 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
libgccjit.so is tagged according to the symbols that it uses.

For example, :func:`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``:

.. code-block:: bash

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

   Version References:
     required from libgccjit.so.0:
       0x00824161 0x00 04 LIBGCCJIT_ABI_1
       0x00824160 0x00 03 LIBGCCJIT_ABI_0
     required from libc.so.6:

You can see the symbol tags provided by libgccjit.so using ``objdump``:

.. code-block:: bash

   $ objdump -p libgccjit.so | less
   [...snip...]
   Version definitions:
   1 0x01 0x0ff81f20 libgccjit.so.0
   2 0x00 0x00824160 LIBGCCJIT_ABI_0
   3 0x00 0x00824161 LIBGCCJIT_ABI_1
           LIBGCCJIT_ABI_0
   [...snip...]

Programmatically checking version
*********************************

Client code can programmatically check libgccjit version using:

.. function::  int gcc_jit_version_major (void)

   Return libgccjit major version.  This is analogous to __GNUC__ in C code.

.. function::  int gcc_jit_version_minor (void)

   Return libgccjit minor version.  This is analogous to
   __GNUC_MINOR__ in C code.

.. function::  int gcc_jit_version_patchlevel (void)

   Return libgccjit patchlevel version.  This is analogous to
   __GNUC_PATCHLEVEL__ in C code.

.. note:: These entry points has been added with ``LIBGCCJIT_ABI_13``
          (see below).

ABI symbol tags
***************

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

Newer releases use the following tags.

.. _LIBGCCJIT_ABI_0:

``LIBGCCJIT_ABI_0``
-------------------

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 ``libgccjit.so`` should
continue to work, with this being handled transparently by the linker
(see `this post
<https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02126.html>`_)

.. _LIBGCCJIT_ABI_1:

``LIBGCCJIT_ABI_1``
-------------------
``LIBGCCJIT_ABI_1`` covers the addition of
:func:`gcc_jit_context_add_command_line_option`

.. _LIBGCCJIT_ABI_2:

``LIBGCCJIT_ABI_2``
-------------------
``LIBGCCJIT_ABI_2`` covers the addition of
:func:`gcc_jit_context_set_bool_allow_unreachable_blocks`

.. _LIBGCCJIT_ABI_3:

``LIBGCCJIT_ABI_3``
-------------------
``LIBGCCJIT_ABI_3`` covers the addition of switch statements via API
entrypoints:

  * :func:`gcc_jit_block_end_with_switch`

  * :func:`gcc_jit_case_as_object`

  * :func:`gcc_jit_context_new_case`

.. _LIBGCCJIT_ABI_4:

``LIBGCCJIT_ABI_4``
-------------------
``LIBGCCJIT_ABI_4`` covers the addition of timers via API
entrypoints:

  * :func:`gcc_jit_context_get_timer`

  * :func:`gcc_jit_context_set_timer`

  * :func:`gcc_jit_timer_new`

  * :func:`gcc_jit_timer_release`

  * :func:`gcc_jit_timer_push`

  * :func:`gcc_jit_timer_pop`

  * :func:`gcc_jit_timer_print`

.. _LIBGCCJIT_ABI_5:

``LIBGCCJIT_ABI_5``
-------------------
``LIBGCCJIT_ABI_5`` covers the addition of
:func:`gcc_jit_context_set_bool_use_external_driver`

.. _LIBGCCJIT_ABI_6:

``LIBGCCJIT_ABI_6``
-------------------
``LIBGCCJIT_ABI_6`` covers the addition of
:func:`gcc_jit_rvalue_set_bool_require_tail_call`

.. _LIBGCCJIT_ABI_7:

``LIBGCCJIT_ABI_7``
-------------------
``LIBGCCJIT_ABI_7`` covers the addition of
:func:`gcc_jit_type_get_aligned`

.. _LIBGCCJIT_ABI_8:

``LIBGCCJIT_ABI_8``
-------------------
``LIBGCCJIT_ABI_8`` covers the addition of
:func:`gcc_jit_type_get_vector`

.. _LIBGCCJIT_ABI_9:

``LIBGCCJIT_ABI_9``
-------------------
``LIBGCCJIT_ABI_9`` covers the addition of
:func:`gcc_jit_function_get_address`

.. _LIBGCCJIT_ABI_10:

``LIBGCCJIT_ABI_10``
--------------------
``LIBGCCJIT_ABI_10`` covers the addition of
:func:`gcc_jit_context_new_rvalue_from_vector`

.. _LIBGCCJIT_ABI_11:

``LIBGCCJIT_ABI_11``
--------------------
``LIBGCCJIT_ABI_11`` covers the addition of
:func:`gcc_jit_context_add_driver_option`

.. _LIBGCCJIT_ABI_12:

``LIBGCCJIT_ABI_12``
--------------------
``LIBGCCJIT_ABI_12`` covers the addition of
:func:`gcc_jit_context_new_bitfield`

.. _LIBGCCJIT_ABI_13:

``LIBGCCJIT_ABI_13``
--------------------
``LIBGCCJIT_ABI_13`` covers the addition of version functions via API
entrypoints:

  * :func:`gcc_jit_version_major`

  * :func:`gcc_jit_version_minor`

  * :func:`gcc_jit_version_patchlevel`

.. _LIBGCCJIT_ABI_14:

``LIBGCCJIT_ABI_14``
--------------------
``LIBGCCJIT_ABI_14`` covers the addition of
:func:`gcc_jit_global_set_initializer`

.. _LIBGCCJIT_ABI_15:

``LIBGCCJIT_ABI_15``
--------------------
``LIBGCCJIT_ABI_15`` covers the addition of API entrypoints for directly
embedding assembler instructions:

  * :func:`gcc_jit_block_add_extended_asm`
  * :func:`gcc_jit_block_end_with_extended_asm_goto`
  * :func:`gcc_jit_extended_asm_as_object`
  * :func:`gcc_jit_extended_asm_set_volatile_flag`
  * :func:`gcc_jit_extended_asm_set_inline_flag`
  * :func:`gcc_jit_extended_asm_add_output_operand`
  * :func:`gcc_jit_extended_asm_add_input_operand`
  * :func:`gcc_jit_extended_asm_add_clobber`
  * :func:`gcc_jit_context_add_top_level_asm`

.. _LIBGCCJIT_ABI_16:

``LIBGCCJIT_ABI_16``
--------------------
``LIBGCCJIT_ABI_16`` covers the addition of reflection functions via API
entrypoints:

  * :func:`gcc_jit_function_get_return_type`

  * :func:`gcc_jit_function_get_param_count`

  * :func:`gcc_jit_type_dyncast_array`

  * :func:`gcc_jit_type_is_bool`

  * :func:`gcc_jit_type_is_integral`

  * :func:`gcc_jit_type_is_pointer`

  * :func:`gcc_jit_type_is_struct`

  * :func:`gcc_jit_type_dyncast_vector`

  * :func:`gcc_jit_type_unqualified`

  * :func:`gcc_jit_type_dyncast_function_ptr_type`

  * :func:`gcc_jit_function_type_get_return_type`

  * :func:`gcc_jit_function_type_get_param_count`

  * :func:`gcc_jit_function_type_get_param_type`

  * :func:`gcc_jit_vector_type_get_num_units`

  * :func:`gcc_jit_vector_type_get_element_type`

  * :func:`gcc_jit_struct_get_field`

  * :func:`gcc_jit_struct_get_field_count`

.. _LIBGCCJIT_ABI_17:

``LIBGCCJIT_ABI_17``
-----------------------
``LIBGCCJIT_ABI_17`` covers the addition of an API entrypoint to set the
thread-local storage model of a variable:

  * :func:`gcc_jit_lvalue_set_tls_model`

.. _LIBGCCJIT_ABI_18:

``LIBGCCJIT_ABI_18``
-----------------------
``LIBGCCJIT_ABI_18`` covers the addition of an API entrypoint to set the link
section of a variable:

  * :func:`gcc_jit_lvalue_set_link_section`

.. _LIBGCCJIT_ABI_19:

``LIBGCCJIT_ABI_19``
-----------------------
``LIBGCCJIT_ABI_19`` covers the addition of API entrypoints to set the initial value
of a global with an rvalue and to use constructors:

  * :func:`gcc_jit_context_new_array_constructor`
  * :func:`gcc_jit_context_new_struct_constructor`
  * :func:`gcc_jit_context_new_union_constructor`
  * :func:`gcc_jit_global_set_initializer_rvalue`