Skip to content

Commit a7d8b8e

Browse files
Add guide to add new attributes support in libgccjit
1 parent e39f3a2 commit a7d8b8e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/add-attribute.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add support for a new function attribute
2+
3+
To add support for a new function attribute in libgccjit, you need to do the following steps:
4+
5+
1. Copy the corresponding function from `c-family/c-attribs.cc` into `jit/dummy-frontend.cc`. For example if you add the `target` attribute, the function name will be `handle_target_attribute`.
6+
2. Copy the corresponding entry from the `c_common_attribute_table` variable in the `c-family/c-attribs.cc` file into the `jit_attribute_table` variable in `jit/dummy-frontend.cc`.
7+
3. Add a new variant in the `gcc_jit_fn_attribute` enum in the `jit/libgccjit.h` file.
8+
4. Add a test to ensure the attribute is correctly applied in `gcc/testsuite/jit.dg/`. Take a look at `gcc/testsuite/jit.dg/test-nonnull.c` if you want an example.
9+
5. Run the example like this (in your `gcc-build` folder): `make check-jit RUNTESTFLAGS="-v -v -v jit.exp=jit.dg/test-nonnull.c"`
10+
11+
Once done, you need to update the [gccjit.rs] crate to add the new enum variant in the corresponding enum (`FnAttribute`).
12+
13+
Finally, you need to update this repository by calling the relevant API you added in [gccjit.rs].
14+
15+
To test it, build `gcc`, run `cargo update -p gccjit` and then you can test the generated output for a given Rust crate.
16+
17+
[gccjit.rs]: https://github.com/antoyo/gccjit.rs

0 commit comments

Comments
 (0)