@@ -33,9 +33,17 @@ also add the calls we need to generate the GIMPLE:
33
33
``` C
34
34
int main () {
35
35
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");
36
40
create_code(ctxt, NULL);
41
+
37
42
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
+
39
47
return 0;
40
48
}
41
49
```
@@ -46,13 +54,21 @@ Then we can compile it by using:
46
54
gcc local.c -I `pwd`/gcc/gcc/jit/ -L `pwd`/gcc-build/gcc -lgccjit -o out
47
55
```
48
56
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
+
49
65
And finally when you run it:
50
66
51
67
``` console
52
68
LD_LIBRARY_PATH=`pwd`/gcc-build/gcc LIBRARY_PATH=`pwd`/gcc-build/gcc ./out
53
69
```
54
70
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:
56
72
57
73
``` c
58
74
__attribute__ ((const))
0 commit comments