Interfacing with external code using libgccjit

Basile Starynkevitch basile@starynkevitch.net
Fri Jun 16 19:07:54 GMT 2023


On 6/16/23 19:27, David Malcolm via Jit wrote:
> On Thu, 2023-06-15 at 21:59 +0200, Anselm Schüler wrote:
>> Hi, I’m very new to libgccjit and was hoping to use it to implement a
>> DSL that abstracts over some high-precision mathematics.
> Hi!
>
>> However, to do that, I need to interface with a high-precision
>> library
>> such as GMP or MPFR.
>> I’m wondering if that’s possible.
> It ought to be possible, but you need some way to express the
> declarations from the library's headers via the ligccjit API; we don't
> yet have a convenient way to take a header and express it in libgccjit
> form.  As you note, doing it "by hand" is laborious; sorry that we
> don't yet have an automated way of doing this.  Possible approaches
> would be to use a library that can parse C headers, such as:
>    https://github.com/vnmakarov/mir
> or perhaps using libabigail to work with the ABI representation:
>    https://sourceware.org/libabigail/
> (which would be parsing the debug data)
>

Another possible approach might be to use some GCC plugin (perhaps 
inspired by some code from https://github.com/bstarynk/bismon ...) to 
parse the GMP or MPFR header files, and later inject some constants 
(describing the external code, such as GMP or MPFR) into libgccjit




Maybe future GCC support for C++ 2x modules could be also relevant

Cheers

-- 
Basile Starynkevitch                  <basile@starynkevitch.net>
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/



More information about the Jit mailing list