@@ -33,9 +33,17 @@ also add the calls we need to generate the GIMPLE:
3333``` C
3434int main () {
3535 gcc_jit_context *ctxt = gcc_jit_context_acquire();
36+ // To set `-O3`, update it depending on your needs.
37+ gcc_jit_context_set_int_option (ctxt, GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, 3);
38+ // Very important option to generate the gimple format.
39+ gcc_jit_context_add_command_line_option(ctxt, "-fdump-tree-gimple");
3640 create_code(ctxt, NULL);
41+
3742 gcc_jit_context_compile (ctxt);
38- gcc_jit_context_dump_to_file(ctxt, "tmp.gimple", 1);
43+ // If you want to compile to assembly (or any other format) directly, you can
44+ // use the following call instead:
45+ // gcc_jit_context_compile_to_file(ctxt, GCC_JIT_OUTPUT_KIND_ASSEMBLER, "out.s");
46+
3947 return 0;
4048}
4149```
@@ -46,13 +54,21 @@ Then we can compile it by using:
4654gcc local.c -I `pwd`/gcc/gcc/jit/ -L `pwd`/gcc-build/gcc -lgccjit -o out
4755```
4856
57+ Before running it, I recommend running:
58+
59+ ``` console
60+ rm -rf /tmp/libgccjit-*
61+ ```
62+
63+ to make it easier for you to know which folder to look into.
64+
4965And finally when you run it:
5066
5167``` console
5268LD_LIBRARY_PATH=`pwd`/gcc-build/gcc LIBRARY_PATH=`pwd`/gcc-build/gcc ./out
5369```
5470
55- You should now have a file named ` tmp.gimple ` which contains:
71+ You should now have a file named with path looking like ` / tmp/libgccjit-9OFqkD/fake.c.006t .gimple` which contains:
5672
5773``` c
5874__attribute__ ((const))
0 commit comments