Some basic questions
David Malcolm
dmalcolm@redhat.com
Sun Jan 1 00:00:00 GMT 2017
On Thu, 2017-07-06 at 17:51 +0100, Mahdi Mohammadinasab wrote:
> I have some basic questions regarding libgccjit. I could not find the
> answer in the documentation.
>
> 1. Does libgccjit do optimizations when generating the machine code?
By default, no, but you can enable optimizations using
GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL:
e.g.
gcc_jit_context_set_int_option(ctxt,
GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
2);
for the equivalent of -O2.
https://gcc.gnu.org/onlinedocs/jit/topics/contexts.html#GCC_JIT_INT_OPT
ION_OPTIMIZATION_LEVEL
You can also enable specific optimizations using:
gcc_jit_context_add_command_line_option
e.g.:
gcc_jit_context_add_command_line_option (ctxt, "-ffast-math");
> 2. Does it support other OSs like Windows?
In theory, yes, but I don't know of anyone who's used it on Windows,
and so in practice there are likely to be bugs that need solving.
I know people have used it on OS X (using an out-of-tree patch, which
is in the OS X Homebrew packages: see
https://github.com/Homebrew/homebrew-core/blob/master/Formula/gcc.rb#L4
6
which is an OS X-specific patch for
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64089 )
> 3. If the output application depends on a static library (.a) I will
> need to generate object file using libgccjit (call
> gcc_jit_context_compile_to_file with GCC_JIT_OUTPUT_KIND_OBJECT_FILE
> option) and use system linker to link it with the library. Is that
> the
> correct approach?
https://gcc.gnu.org/onlinedocs/jit/topics/compilation.html#GCC_JIT_OUTP
UT_KIND_EXECUTABLE says "There is currently no support for specifying
libraries to link against.". Given that limitation, the approach you
suggest sounds correct.
Alternatively we could add support for passing linker options for use
with GCC_JIT_OUTPUT_KIND_EXECUTABLE (one might think that
gcc_jit_context_add_command_line_option could be used, but options
added this way are used in a different place).
> 4. Is there any planned feature missing from current codebase which
> prevents it moving out of alpha stage?
Not AFAIK.
Hope this is helpful
Dave
More information about the Jit
mailing list