> * there's a name-mangling issue with gripe_divide_by_zero,
> which for me gets name-mangled by the C++ compiler (to
> "_Z20gripe_divide_by_zerov").
> For now I have a horrible hack I'm applying on the libgccjit
> side which
> special-cases this, and applies the mangling when referencing
> this symbol (am attaching it)

I had a look at fixing this properly from the libgccjit end, by having a flag to enable name-mangling on a function's name, but it's not going to be easy (the name-mangling support in gcc is all inside the C++ frontend, so it's non-trivial to refactor that out).

I think the simplest solution for this is to wrap the decl of
gripe_divide_by_zero
in gripes.h within an extern "C" thusly:
extern "C" {
extern OCTINTERP_API void
gripe_divide_by_zero (void);
}
though I'm not sure if that's going to require changes to the LLVM JIT code.

I thought it was time I posted what I have. It compiles and runs, though
there are plenty of issues.

Notes:
* I split out HAVE_LLVM to HAVE_JIT, HAVE_LLVM, and HAVE_GCCJIT

* both the LLVM and gccjit implementations are built within the same
build. This is clearly overkill, but is handy for debugging in that
one can compare what each of the two implementation produces.

The resulting preprocessor gunk is deeply ugly. Perhaps it could be
simplified by making choice of JIT backend be a configure-time thing,
rather than trying to support both within one process.

* jit.tst runs, but I had to hack out some of the tests for now. It
tries to run both the LLVM and gccjit compiler on the IR. It then
tries to run the gccjit-built code, if that succeeded; failing that
the LLVM-built code.

* I've only implemented JIT-compilation of loops for now, not functions.
I hope the latter is fairly easy to add, but I wanted to post
something.

* lots of FIXMEs, TODOs and other cruft; sorry (e.g. the configure.ac
"test", which for now just hardcodes a location of a libgccjit
checkout)

* libgccjit currently requires function names to be valid C
identifiers, so I changed some functions to obey this restriction

* there's a name-mangling issue with gripe_divide_by_zero, which for me
gets name-mangled by the C++ compiler (to "_Z20gripe_divide_by_zerov").
For now I have a horrible hack I'm applying on the libgccjit side which
special-cases this, and applies the mangling when referencing this
symbol (am attaching it)

Clearly this isn't ready yet, but I wanted some feedback from the Octave
maintainers on the direction of this.